| @@ 88-104 (lines=17) @@ | ||
| 85 | assertThat($msgs, is(identicalTo([$this->messageA, $this->messageC]))); |
|
| 86 | } |
|
| 87 | ||
| 88 | public function testHandleWorkerWithThrownException() |
|
| 89 | { |
|
| 90 | $handler = $this->handler; |
|
| 91 | ||
| 92 | $this->messageA->shouldReceive('isValid')->once()->withNoArgs()->andReturn(true); |
|
| 93 | $this->messageB->shouldReceive('isValid')->once()->withNoArgs()->andReturn(true); |
|
| 94 | ||
| 95 | $this->adapter->shouldReceive('acknowledge')->once()->with([$this->messageA]); |
|
| 96 | ||
| 97 | $this->setExpectedException('RuntimeException', 'foo'); |
|
| 98 | ||
| 99 | $handler($this->messages, $this->adapter, function ($msg) { |
|
| 100 | if ($msg === $this->messageB) { |
|
| 101 | throw new RuntimeException('foo'); |
|
| 102 | } |
|
| 103 | }); |
|
| 104 | } |
|
| 105 | } |
|
| 106 | ||
| @@ 94-111 (lines=18) @@ | ||
| 91 | assertThat($msgs, is(identicalTo([$this->messageA, $this->messageC]))); |
|
| 92 | } |
|
| 93 | ||
| 94 | public function testHandleWorkerWithThrownException() |
|
| 95 | { |
|
| 96 | $handler = $this->handler; |
|
| 97 | ||
| 98 | $this->messageA->shouldReceive('isValid')->once()->withNoArgs()->andReturn(true); |
|
| 99 | $this->messageB->shouldReceive('isValid')->once()->withNoArgs()->andReturn(true); |
|
| 100 | ||
| 101 | // @see https://github.com/padraic/mockery/issues/331 |
|
| 102 | $this->adapter->shouldReceive('acknowledge')->once()->with(m::mustBe([$this->messageA])); |
|
| 103 | ||
| 104 | $this->setExpectedException('RuntimeException', 'foo'); |
|
| 105 | ||
| 106 | $handler($this->messages, $this->adapter, function ($msg) { |
|
| 107 | if ($msg === $this->messageB) { |
|
| 108 | throw new RuntimeException('foo'); |
|
| 109 | } |
|
| 110 | }); |
|
| 111 | } |
|
| 112 | } |
|
| 113 | ||