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
e320f506
Commit
e320f506
authored
Jan 15, 2013
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for declaring an endpoint as default at the time of creation
parent
7ba16cad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
library/Solarium/Core/Client/Client.php
library/Solarium/Core/Client/Client.php
+5
-1
tests/Solarium/Tests/Core/Client/ClientTest.php
tests/Solarium/Tests/Core/Client/ClientTest.php
+7
-0
No files found.
library/Solarium/Core/Client/Client.php
View file @
e320f506
...
@@ -245,9 +245,10 @@ class Client extends Configurable
...
@@ -245,9 +245,10 @@ class Client extends Configurable
* after setting the key, by using the addEndpoint method.
* after setting the key, by using the addEndpoint method.
*
*
* @param mixed $options
* @param mixed $options
* @param boolean $setAsDefault
* @return Endpoint
* @return Endpoint
*/
*/
public
function
createEndpoint
(
$options
=
null
)
public
function
createEndpoint
(
$options
=
null
,
$setAsDefault
=
false
)
{
{
if
(
is_string
(
$options
))
{
if
(
is_string
(
$options
))
{
$endpoint
=
new
Endpoint
;
$endpoint
=
new
Endpoint
;
...
@@ -258,6 +259,9 @@ class Client extends Configurable
...
@@ -258,6 +259,9 @@ class Client extends Configurable
if
(
$endpoint
->
getKey
()
!==
null
)
{
if
(
$endpoint
->
getKey
()
!==
null
)
{
$this
->
addEndpoint
(
$endpoint
);
$this
->
addEndpoint
(
$endpoint
);
if
(
$setAsDefault
==
true
)
{
$this
->
setDefaultEndpoint
(
$endpoint
);
}
}
}
return
$endpoint
;
return
$endpoint
;
...
...
tests/Solarium/Tests/Core/Client/ClientTest.php
View file @
e320f506
...
@@ -173,6 +173,13 @@ class ClientTest extends \PHPUnit_Framework_TestCase
...
@@ -173,6 +173,13 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$this
->
assertThat
(
$endpoint
,
$this
->
isInstanceOf
(
'Solarium\Core\Client\Endpoint'
));
$this
->
assertThat
(
$endpoint
,
$this
->
isInstanceOf
(
'Solarium\Core\Client\Endpoint'
));
}
}
public
function
testCreateEndpointWithSetAsDefault
()
{
$this
->
client
->
createEndpoint
(
'key3'
,
true
);
$endpoint
=
$this
->
client
->
getEndpoint
();
$this
->
assertEquals
(
'key3'
,
$endpoint
->
getKey
());
}
public
function
testCreateEndpointWithArray
()
public
function
testCreateEndpointWithArray
()
{
{
$options
=
array
(
$options
=
array
(
...
...
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