@@ -35,9 +35,12 @@ discard block |
||
| 35 | 35 | $this->initialResponse = $this->createMock(ResponseInterface::class); |
| 36 | 36 | $this->finalResponse = $this->createMock(ResponseInterface::class); |
| 37 | 37 | |
| 38 | - $this->controller = new class ($this) extends Controller { |
|
| 38 | + $this->controller = new class ($this) extends Controller |
|
| 39 | + { |
|
| 39 | 40 | public $called; |
| 40 | - public function __construct(protected ControllerTest $test) { } |
|
| 41 | + public function __construct(protected ControllerTest $test) |
|
| 42 | + { |
|
| 43 | +} |
|
| 41 | 44 | |
| 42 | 45 | public function process(int $foo, string $bar = 'red'): static { |
| 43 | 46 | $this->called = __FUNCTION__; |
@@ -124,14 +127,19 @@ discard block |
||
| 124 | 127 | |
| 125 | 128 | public function testBefore() |
| 126 | 129 | { |
| 127 | - $controller = new class ($this) extends Controller { |
|
| 128 | - function __construct(protected ControllerTest $test) { } |
|
| 130 | + $controller = new class ($this) extends Controller |
|
| 131 | + { |
|
| 132 | + function __construct(protected ControllerTest $test) |
|
| 133 | + { |
|
| 134 | +} |
|
| 129 | 135 | |
| 130 | - function before() { |
|
| 136 | + function before() |
|
| 137 | + { |
|
| 131 | 138 | return $this->paymentRequired(); |
| 132 | 139 | } |
| 133 | 140 | |
| 134 | - function process() { |
|
| 141 | + function process() |
|
| 142 | + { |
|
| 135 | 143 | $this->test->fail("Process should not be called"); |
| 136 | 144 | } |
| 137 | 145 | }; |
@@ -149,9 +157,12 @@ discard block |
||
| 149 | 157 | |
| 150 | 158 | public function testClassGuard() |
| 151 | 159 | { |
| 152 | - $controller = new #[PaymentRequired] class ($this) extends Controller { |
|
| 160 | + $controller = new #[PaymentRequired] class ($this) extends Controller |
|
| 161 | + { |
|
| 153 | 162 | public $called; |
| 154 | - public function __construct(protected ControllerTest $test) { } |
|
| 163 | + public function __construct(protected ControllerTest $test) |
|
| 164 | + { |
|
| 165 | +} |
|
| 155 | 166 | |
| 156 | 167 | public function process(): static { |
| 157 | 168 | $this->called = __FUNCTION__; |
@@ -174,12 +185,16 @@ discard block |
||
| 174 | 185 | |
| 175 | 186 | public function testMethodGuard() |
| 176 | 187 | { |
| 177 | - $controller = new class ($this) extends Controller { |
|
| 188 | + $controller = new class ($this) extends Controller |
|
| 189 | + { |
|
| 178 | 190 | public $called; |
| 179 | - function __construct(protected ControllerTest $test) { } |
|
| 191 | + function __construct(protected ControllerTest $test) |
|
| 192 | + { |
|
| 193 | +} |
|
| 180 | 194 | |
| 181 | 195 | #[PaymentRequired] |
| 182 | - function process() { |
|
| 196 | + function process() |
|
| 197 | + { |
|
| 183 | 198 | $this->called = __FUNCTION__; |
| 184 | 199 | return $this->ok(); |
| 185 | 200 | } |
@@ -200,9 +215,12 @@ discard block |
||
| 200 | 215 | |
| 201 | 216 | public function testNopGuard() |
| 202 | 217 | { |
| 203 | - $controller = new #[NopGuard] class ($this) extends Controller { |
|
| 218 | + $controller = new #[NopGuard] class ($this) extends Controller |
|
| 219 | + { |
|
| 204 | 220 | public $called; |
| 205 | - public function __construct(protected ControllerTest $test) { } |
|
| 221 | + public function __construct(protected ControllerTest $test) |
|
| 222 | + { |
|
| 223 | +} |
|
| 206 | 224 | |
| 207 | 225 | public function process(): static { |
| 208 | 226 | $this->called = __FUNCTION__; |
@@ -4,7 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | trait InContextOf |
| 6 | 6 | { |
| 7 | - public function inContextOf(object $object, \Closure $function) { |
|
| 7 | + public function inContextOf(object $object, \Closure $function) |
|
| 8 | + { |
|
| 8 | 9 | return $function->bindTo($this, $object)(); |
| 9 | 10 | } |
| 10 | 11 | } |
@@ -61,14 +61,18 @@ |
||
| 61 | 61 | $response = $this->createMock(ResponseInterface::class); |
| 62 | 62 | $response->method('getStatusCode')->willReturn($code); |
| 63 | 63 | |
| 64 | - $controller = new class ($this, $response) extends Controller { |
|
| 65 | - public function __construct(public TestCase $test, protected ResponseInterface $response) {} |
|
| 64 | + $controller = new class ($this, $response) extends Controller |
|
| 65 | + { |
|
| 66 | + public function __construct(public TestCase $test, protected ResponseInterface $response) |
|
| 67 | + { |
|
| 68 | +} |
|
| 66 | 69 | |
| 67 | 70 | protected function getResponse(): ResponseInterface { |
| 68 | 71 | return $this->response; |
| 69 | 72 | } |
| 70 | 73 | |
| 71 | - public function assertResponseStatus(string $type) { |
|
| 74 | + public function assertResponseStatus(string $type) |
|
| 75 | + { |
|
| 72 | 76 | $this->test->assertSame($type === 'informational', $this->isInformational(), 'isInformational'); |
| 73 | 77 | $this->test->assertSame($type === 'successful', $this->isSuccessful(), 'isSuccessful'); |
| 74 | 78 | $this->test->assertSame($type === 'redirect', $this->isRedirection(), 'isRedirection'); |
@@ -34,14 +34,18 @@ |
||
| 34 | 34 | $request = $this->createMock(ServerRequestInterface::class); |
| 35 | 35 | $request->method('getMethod')->willReturn($method); |
| 36 | 36 | |
| 37 | - $controller = new class ($this, $request) extends Controller { |
|
| 38 | - public function __construct(public CheckRequestTest $test, protected ServerRequestInterface $request) {} |
|
| 37 | + $controller = new class ($this, $request) extends Controller |
|
| 38 | + { |
|
| 39 | + public function __construct(public CheckRequestTest $test, protected ServerRequestInterface $request) |
|
| 40 | + { |
|
| 41 | +} |
|
| 39 | 42 | |
| 40 | 43 | protected function getRequest(): ServerRequestInterface { |
| 41 | 44 | return $this->request; |
| 42 | 45 | } |
| 43 | 46 | |
| 44 | - public function assertRequestMethod(string $method) { |
|
| 47 | + public function assertRequestMethod(string $method) |
|
| 48 | + { |
|
| 45 | 49 | $this->test->assertEquals($method === 'GET', $this->isGetRequest()); |
| 46 | 50 | $this->test->assertEquals($method === 'POST', $this->isPostRequest()); |
| 47 | 51 | $this->test->assertEquals($method === 'PUT', $this->isPutRequest()); |