Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
97ec474d
Commit
97ec474d
authored
Jan 22, 2013
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added endpoint __toString support
parent
4b1017f6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
library/Solarium/Core/Client/Endpoint.php
library/Solarium/Core/Client/Endpoint.php
+22
-0
tests/Solarium/Tests/Core/Client/EndpointTest.php
tests/Solarium/Tests/Core/Client/EndpointTest.php
+31
-0
No files found.
library/Solarium/Core/Client/Endpoint.php
View file @
97ec474d
...
@@ -258,4 +258,26 @@ class Endpoint extends Configurable
...
@@ -258,4 +258,26 @@ class Endpoint extends Configurable
'password'
=>
$this
->
getOption
(
'password'
),
'password'
=>
$this
->
getOption
(
'password'
),
);
);
}
}
/**
* Magic method enables a object to be transformed to a string
*
* Get a summary showing significant variables in the object
* note: uri resource is decoded for readability
*
* @return string
*/
public
function
__toString
()
{
$output
=
__CLASS__
.
'::__toString'
.
"
\n
"
.
'base uri: '
.
$this
->
getBaseUri
()
.
"
\n
"
.
'host: '
.
$this
->
getHost
()
.
"
\n
"
.
'port: '
.
$this
->
getPort
()
.
"
\n
"
.
'path: '
.
$this
->
getPath
()
.
"
\n
"
.
'core: '
.
$this
->
getCore
()
.
"
\n
"
.
'timeout: '
.
$this
->
getTimeout
()
.
"
\n
"
.
'authentication: '
.
print_r
(
$this
->
getAuthentication
(),
1
);
return
$output
;
}
}
}
tests/Solarium/Tests/Core/Client/EndpointTest.php
View file @
97ec474d
...
@@ -127,4 +127,35 @@ class EndpointTest extends \PHPUnit_Framework_TestCase
...
@@ -127,4 +127,35 @@ class EndpointTest extends \PHPUnit_Framework_TestCase
$this
->
endpoint
->
getAuthentication
()
$this
->
endpoint
->
getAuthentication
()
);
);
}
}
public
function
testToString
()
{
$options
=
array
(
'host'
=>
'192.168.0.1'
,
'port'
=>
123
,
'path'
=>
'/mysolr/'
,
'core'
=>
'mycore'
,
'timeout'
=>
3
,
'username'
=>
'x'
,
'password'
=>
'y'
);
$this
->
endpoint
->
setOptions
(
$options
);
$this
->
assertEquals
(
'Solarium\Core\Client\Endpoint::__toString
base uri: http://192.168.0.1:123/mysolr/mycore/
host: 192.168.0.1
port: 123
path: /mysolr
core: mycore
timeout: 3
authentication: Array
(
[username] => x
[password] => y
)
'
,
(
string
)
$this
->
endpoint
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment