Example #1
0
 public function testSendToAllCallsFailureCallback()
 {
     $command = 'stats';
     $connection1 = $this->getMockConnection('id-123');
     $connection1->expects($this->any())->method($command)->will($this->throwException(new RuntimeException()));
     $connection2 = $this->getMockConnection('id-456');
     $connection2->expects($this->any())->method($command)->will($this->throwException(new RuntimeException()));
     $failed = 0;
     $onFailure = function () use(&$failed) {
         $failed++;
     };
     $collection = new Collection([$connection1, $connection2]);
     $collection->sendToAll($command, [], null, $onFailure);
     $this->assertEquals(2, $failed);
 }