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

Fixed or removed todo's (if no longer relevant)

parent d6104fc7
...@@ -217,6 +217,23 @@ class Client extends Configurable ...@@ -217,6 +217,23 @@ class Client extends Configurable
*/ */
protected $adapter; protected $adapter;
/**
* Constructor.
*
* If options are passed they will be merged with {@link $options} using
* the {@link setOptions()} method.
*
* If an EventDispatcher instance is provided this will be used instead of creating a new instance
*
* @param array|\Zend_Config $options
* @param EventDispatcher $eventDispatcher
*/
public function __construct($options = null, $eventDispatcher = null)
{
$this->eventDispatcher = $eventDispatcher;
parent::__construct($options);
}
/** /**
* Create a endpoint instance. * Create a endpoint instance.
* *
...@@ -276,7 +293,6 @@ class Client extends Configurable ...@@ -276,7 +293,6 @@ class Client extends Configurable
} }
//double add calls for the same endpoint are ignored, but non-unique keys cause an exception //double add calls for the same endpoint are ignored, but non-unique keys cause an exception
//@todo add trigger_error with a notice for double add calls?
if (array_key_exists($key, $this->endpoints) && $this->endpoints[$key] !== $endpoint) { if (array_key_exists($key, $this->endpoints) && $this->endpoints[$key] !== $endpoint) {
throw new InvalidArgumentException('An endpoint must have a unique key'); throw new InvalidArgumentException('An endpoint must have a unique key');
} else { } else {
...@@ -1144,8 +1160,9 @@ class Client extends Configurable ...@@ -1144,8 +1160,9 @@ class Client extends Configurable
*/ */
protected function init() protected function init()
{ {
//@todo use injection if ($this->eventDispatcher === null) {
$this->eventDispatcher = new EventDispatcher(); $this->eventDispatcher = new EventDispatcher();
}
foreach ($this->options as $name => $value) { foreach ($this->options as $name => $value) {
switch ($name) { switch ($name) {
......
...@@ -110,7 +110,6 @@ class WeightedRandomChoice ...@@ -110,7 +110,6 @@ class WeightedRandomChoice
} }
// continue until a non-excluded value is found // continue until a non-excluded value is found
// @todo optimize?
$result = null; $result = null;
while (1) { while (1) {
$result = $this->values[$this->getKey()]; $result = $this->values[$this->getKey()];
......
...@@ -319,7 +319,6 @@ class FacetSet extends AbstractComponent ...@@ -319,7 +319,6 @@ class FacetSet extends AbstractComponent
} }
//double add calls for the same facet are ignored, but non-unique keys cause an exception //double add calls for the same facet are ignored, but non-unique keys cause an exception
//@todo add trigger_error with a notice for double add calls?
if (array_key_exists($key, $this->facets) && $this->facets[$key] !== $facet) { if (array_key_exists($key, $this->facets) && $this->facets[$key] !== $facet) {
throw new InvalidArgumentException('A facet must have a unique key value within a query'); throw new InvalidArgumentException('A facet must have a unique key value within a query');
} else { } else {
......
...@@ -152,7 +152,6 @@ class Stats extends AbstractComponent ...@@ -152,7 +152,6 @@ class Stats extends AbstractComponent
} }
//double add calls for the same field are ignored, but non-unique keys cause an exception //double add calls for the same field are ignored, but non-unique keys cause an exception
//@todo add trigger_error with a notice for double add calls?
if (array_key_exists($key, $this->fields) && $this->fields[$key] !== $field) { if (array_key_exists($key, $this->fields) && $this->fields[$key] !== $field) {
throw new InvalidArgumentException('A field must have a unique key value'); throw new InvalidArgumentException('A field must have a unique key value');
} else { } else {
......
...@@ -634,7 +634,6 @@ class Query extends BaseQuery ...@@ -634,7 +634,6 @@ class Query extends BaseQuery
} }
//double add calls for the same FQ are ignored, but non-unique keys cause an exception //double add calls for the same FQ are ignored, but non-unique keys cause an exception
//@todo add trigger_error with a notice for double add calls?
if (array_key_exists($key, $this->filterQueries) && $this->filterQueries[$key] !== $filterQuery) { if (array_key_exists($key, $this->filterQueries) && $this->filterQueries[$key] !== $filterQuery) {
throw new InvalidArgumentException('A filterquery must have a unique key value within a query'); throw new InvalidArgumentException('A filterquery must have a unique key value within a query');
} else { } else {
......
...@@ -121,9 +121,16 @@ class ClientTest extends \PHPUnit_Framework_TestCase ...@@ -121,9 +121,16 @@ class ClientTest extends \PHPUnit_Framework_TestCase
*/ */
public function testGetEventDispatcher() { public function testGetEventDispatcher() {
$this->assertInstanceOf('\Symfony\Component\EventDispatcher\EventDispatcherInterface', $this->client->getEventDispatcher()); $this->assertInstanceOf('\Symfony\Component\EventDispatcher\EventDispatcherInterface', $this->client->getEventDispatcher());
$event_dispatcher = $this->getMock('\Symfony\Component\EventDispatcher\EventDispatcherInterface'); $eventDispatcher = $this->getMock('\Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->client->setEventDispatcher($event_dispatcher); $this->client->setEventDispatcher($eventDispatcher);
$this->assertSame($event_dispatcher, $this->client->getEventDispatcher()); $this->assertSame($eventDispatcher, $this->client->getEventDispatcher());
}
public function testEventDispatcherInjection()
{
$eventDispatcher = $this->getMock('\Symfony\Component\EventDispatcher\EventDispatcherInterface');
$client = new Client(null, $eventDispatcher);
$this->assertSame($eventDispatcher, $client->getEventDispatcher());
} }
public function testConfigModeWithoutKeys() public function testConfigModeWithoutKeys()
......
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