Skip to content

Commit

Permalink
Catch method calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
petehouston committed Sep 26, 2018
1 parent 4ba7a3b commit 8b83f7d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Tests/Unit/Service/Worker/AbstractWorkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ private function getAbstractWorker()
{
/** @var \PHPUnit_Framework_MockObject_MockObject|AbstractWorker $client */
$worker = $this->getMockBuilder(AbstractWorker::class)
->setMethods(['preExecute', 'postExecute', 'onSucceeded', 'onFailed'])
->getMockForAbstractClass();

return $worker;
Expand Down Expand Up @@ -51,6 +52,10 @@ public function testProcessWithNormalMessage()
->method('execute')
->with($message)
->willReturn(true);
$worker->expects($this->once())->method(('preExecute'))->with($message);
$worker->expects($this->once())->method(('postExecute'))->with($message);
$worker->expects($this->once())->method('onSucceeded');
$worker->expects($this->never())->method('onFailed');

$result = $worker->process($message);

Expand All @@ -71,6 +76,10 @@ public function testProcessInFailure()
->method('execute')
->with($message)
->willThrowException(new \Exception());
$worker->expects($this->once())->method(('preExecute'))->with($message);
$worker->expects($this->once())->method(('postExecute'))->with($message);
$worker->expects($this->once())->method('onFailed');
$worker->expects($this->never())->method('onSucceeded');

$result = $worker->process($message);

Expand Down

0 comments on commit 8b83f7d

Please sign in to comment.