| @@ 25-44 (lines=20) @@ | ||
| 22 | $this->broker = new Broker(); |
|
| 23 | } |
|
| 24 | ||
| 25 | public function testCanAppendMiddleware(): void |
|
| 26 | { |
|
| 27 | // Mock |
|
| 28 | $mw1 = $this->mockMiddleware(); |
|
| 29 | $mw2 = $this->mockMiddleware(); |
|
| 30 | ||
| 31 | $this->broker->append($mw1->get(), $mw2->get()); |
|
| 32 | ||
| 33 | // Execute |
|
| 34 | $response = $this->broker->process( |
|
| 35 | $this->mockRequest()->get(), |
|
| 36 | $this->mockHandler()->get() |
|
| 37 | ); |
|
| 38 | ||
| 39 | // Verify |
|
| 40 | Phony::inOrder( |
|
| 41 | $mw1->process->once()->called(), |
|
| 42 | $mw2->process->once()->called() |
|
| 43 | ); |
|
| 44 | } |
|
| 45 | ||
| 46 | public function testCanPrependMiddleware(): void |
|
| 47 | { |
|
| @@ 46-66 (lines=21) @@ | ||
| 43 | ); |
|
| 44 | } |
|
| 45 | ||
| 46 | public function testCanPrependMiddleware(): void |
|
| 47 | { |
|
| 48 | // Mock |
|
| 49 | $mw1 = $this->mockMiddleware(); |
|
| 50 | $mw2 = $this->mockMiddleware(); |
|
| 51 | ||
| 52 | $this->broker->append($mw1->get()); |
|
| 53 | $this->broker->prepend($mw2->get()); |
|
| 54 | ||
| 55 | // Execute |
|
| 56 | $response = $this->broker->process( |
|
| 57 | $this->mockRequest()->get(), |
|
| 58 | $this->mockHandler()->get() |
|
| 59 | ); |
|
| 60 | ||
| 61 | // Verify |
|
| 62 | Phony::inOrder( |
|
| 63 | $mw2->process->once()->called(), |
|
| 64 | $mw1->process->once()->called() |
|
| 65 | ); |
|
| 66 | } |
|
| 67 | ||
| 68 | public function testCannotHandleWithoutMiddleware(): void |
|
| 69 | { |
|