public function testJsonEncode_returnsExpectedData() { $testJob = 'job'; $testCommand = 'command'; $expected = json_encode(['job' => $testJob, 'command' => $testCommand]); $this->commandMock->expects($this->once())->method('jsonSerialize')->willReturn($testCommand); $this->beanieJobMock->expects($this->once())->method('jsonSerialize')->willReturn($testJob); $this->assertJsonStringEqualsJsonString($expected, json_encode($this->job)); }
/** * @param Exception $exception * @param CommandInterface $command * @throws Exception */ protected function handlePutFailure(Exception $exception, CommandInterface $command) { $this->logger->alert('Failed to queue command due to unexpected exception', ['exception' => $exception, 'producer' => $this->producer, 'command' => $command]); if ($this->fallbackEnabled === true) { $command->execute(); } else { throw $exception; } }
/** * @dataProvider queueParamsProvider * @param array $params */ public function testQueue_fallbackEnabled_serverExceptionMeansTryAgain(array $params) { $testData = 'test'; $this->qMan->enableFallback(); $this->commandMock->expects($this->once())->method('execute'); $this->serializerMock->expects($this->once())->method('serialize')->with($this->commandMock)->willReturn($testData); $serverExceptionMock = $this->getMockBuilder(AbstractServerException::class)->disableOriginalConstructor()->getMockForAbstractClass(); $invocationMocker = $this->producerMock->expects($this->once())->method('put'); $invocationMocker = call_user_func_array([$invocationMocker, 'with'], array_merge([$testData], $params)); $invocationMocker->willThrowException($serverExceptionMock); call_user_func_array([$this->qMan, 'queue'], array_merge([$this->commandMock, self::TEST_TUBE], $params)); }
/** * @return bool */ public function execute() { return $this->command->execute(); }