Exemple #1
0
 public function testListTubes()
 {
     $expected = ['test1', 'test2', 'test3', 'test4'];
     $this->collection->expects($this->any())->method('sendToAll')->will($this->returnCallback(function ($command, $args, $success, $failure) use($expected) {
         $success(['connection' => null, 'response' => array_slice($expected, 0, 2)]);
         $success(['connection' => null, 'response' => array_slice($expected, 2, 1)]);
         $success(['connection' => null, 'response' => array_slice($expected, 2, 2)]);
     }));
     $actual = $this->pool->listTubes();
     sort($actual);
     // this is so they match
     $this->assertEquals($expected, $actual);
 }
Exemple #2
0
 /**
  * @expectedException \Phlib\Beanstalk\Exception\RuntimeException
  */
 public function testSendToOneThrowsTheLastError()
 {
     $command = 'stats';
     $identifier1 = 'id-123';
     $connection1 = $this->getMockConnection($identifier1);
     $connection1->expects($this->any())->method($command)->will($this->throwException(new RuntimeException()));
     $identifier2 = 'id-456';
     $connection2 = $this->getMockConnection($identifier2);
     $connection2->expects($this->once())->method($command)->will($this->throwException(new RuntimeException()));
     $this->strategy->expects($this->any())->method('pickOne')->will($this->onConsecutiveCalls($identifier1, $identifier2));
     $collection = new Collection([$connection1, $connection2], $this->strategy);
     $collection->sendToOne($command);
 }