/** * Test run receiver and control control notification error */ public function testRunReceiverControlNotificationError() { $iterations = 0; $existsControlError = false; $this->adapter->expects($this->any())->method('isNextReceive')->with()->will($this->returnCallback(function () use(&$iterations) { if ($iterations > 0) { return false; } $iterations++; return true; })); $message = new Message(); $this->adapter->expects($this->any())->method('getMessage')->with()->will($this->returnValue($message)); $this->notification->expects($this->any())->method('send')->with($message)->will($this->returnCallback(function () { throw new SendException(SendException::ERROR_UNPACK_RESPONSE, null, null); })); $controlError = function (SendException $error) use(&$existsControlError) { $existsControlError = true; }; $queue = new Queue($this->adapter, $this->notification); $queue->setNotificationErrorHandler($controlError); $queue->runReceiver(); $this->assertTrue($existsControlError, 'Not call to callback for control notification error.'); }