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
*/
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.
*
......@@ -276,7 +293,6 @@ class Client extends Configurable
}
//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) {
throw new InvalidArgumentException('An endpoint must have a unique key');
} else {
......@@ -1144,8 +1160,9 @@ class Client extends Configurable
*/
protected function init()
{
//@todo use injection
if ($this->eventDispatcher === null) {
$this->eventDispatcher = new EventDispatcher();
}
foreach ($this->options as $name => $value) {
switch ($name) {
......
......@@ -110,7 +110,6 @@ class WeightedRandomChoice
}
// continue until a non-excluded value is found
// @todo optimize?
$result = null;
while (1) {
$result = $this->values[$this->getKey()];
......
......@@ -319,7 +319,6 @@ class FacetSet extends AbstractComponent
}
//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) {
throw new InvalidArgumentException('A facet must have a unique key value within a query');
} else {
......
......@@ -152,7 +152,6 @@ class Stats extends AbstractComponent
}
//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) {
throw new InvalidArgumentException('A field must have a unique key value');
} else {
......
......@@ -634,7 +634,6 @@ class Query extends BaseQuery
}
//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) {
throw new InvalidArgumentException('A filterquery must have a unique key value within a query');
} else {
......
......@@ -121,9 +121,16 @@ class ClientTest extends \PHPUnit_Framework_TestCase
*/
public function testGetEventDispatcher() {
$this->assertInstanceOf('\Symfony\Component\EventDispatcher\EventDispatcherInterface', $this->client->getEventDispatcher());
$event_dispatcher = $this->getMock('\Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->client->setEventDispatcher($event_dispatcher);
$this->assertSame($event_dispatcher, $this->client->getEventDispatcher());
$eventDispatcher = $this->getMock('\Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->client->setEventDispatcher($eventDispatcher);
$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()
......
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