1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace Predis\Configuration\Option;
- use PredisTestCase;
- class AggregateTest extends PredisTestCase
- {
-
- public function testDefaultOptionValue()
- {
- $option = new Aggregate();
- $options = $this->getMock('Predis\Configuration\OptionsInterface');
- $this->assertNull($option->getDefault($options));
- }
-
- public function testAcceptsCallableAsConnectionInitializer()
- {
- $option = new Aggregate();
- $options = $this->getMock('Predis\Configuration\OptionsInterface');
- $connection = $this->getMock('Predis\Connection\AggregateConnectionInterface');
- $callable = $this->getMock('stdClass', array('__invoke'));
- $callable
- ->expects($this->once())
- ->method('__invoke')
- ->with($this->isInstanceOf('Predis\Configuration\OptionsInterface'))
- ->will($this->returnValue($connection));
- $this->assertInstanceOf('Closure', $initializer = $option->filter($options, $callable));
- $this->assertSame($connection, $initializer($parameters = array()));
- }
-
- public function testThrowsExceptionOnInvalidReturnTypeOfConnectionInitializer()
- {
- $option = new Aggregate();
- $options = $this->getMock('Predis\Configuration\OptionsInterface');
- $connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
- $callable = $this->getMock('stdClass', array('__invoke'));
- $callable
- ->expects($this->once())
- ->method('__invoke')
- ->with($this->isInstanceOf('Predis\Configuration\OptionsInterface'))
- ->will($this->returnValue($connection));
- $this->assertInstanceOf('Closure', $initializer = $option->filter($options, $callable));
- $initializer($parameters = array());
- }
-
- public function testThrowsExceptionOnInstanceOfAggregateConnectionInterface()
- {
- $option = new Aggregate();
- $options = $this->getMock('Predis\Configuration\OptionsInterface');
- $cluster = $this->getMock('Predis\Connection\AggregateConnectionInterface');
- $option->filter($options, $cluster);
- }
- }
|