Commit e320f506 authored by Bas de Nooijer's avatar Bas de Nooijer

Added support for declaring an endpoint as default at the time of creation

parent 7ba16cad
......@@ -245,9 +245,10 @@ class Client extends Configurable
* after setting the key, by using the addEndpoint method.
*
* @param mixed $options
* @param boolean $setAsDefault
* @return Endpoint
*/
public function createEndpoint($options = null)
public function createEndpoint($options = null, $setAsDefault = false)
{
if (is_string($options)) {
$endpoint = new Endpoint;
......@@ -258,6 +259,9 @@ class Client extends Configurable
if ($endpoint->getKey() !== null) {
$this->addEndpoint($endpoint);
if ($setAsDefault == true) {
$this->setDefaultEndpoint($endpoint);
}
}
return $endpoint;
......
......@@ -173,6 +173,13 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$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()
{
$options = array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment