|
16 | 16 | use BeastBytes\Wizard\Exception\RuntimeException; |
17 | 17 | use BeastBytes\Wizard\Wizard; |
18 | 18 | use Generator; |
| 19 | +use HttpSoft\Message\Response; |
19 | 20 | use HttpSoft\Message\ResponseFactory; |
20 | 21 | use HttpSoft\Message\ServerRequest; |
21 | 22 | use InvalidArgumentException; |
22 | 23 | use PHPUnit\Framework\Attributes\DataProvider; |
23 | 24 | use PHPUnit\Framework\TestCase; |
24 | 25 | use ReflectionClass; |
| 26 | +use Yiisoft\DataResponse\DataResponse; |
25 | 27 | use Yiisoft\EventDispatcher\Dispatcher\Dispatcher; |
26 | 28 | use Yiisoft\EventDispatcher\Provider\ListenerCollection; |
27 | 29 | use Yiisoft\EventDispatcher\Provider\Provider; |
@@ -189,9 +191,7 @@ public function test_start_wizard(): void |
189 | 191 | $steps, |
190 | 192 | self::$session->get(Wizard::SESSION_KEY . '.' . Wizard::STEPS_KEY) |
191 | 193 | ); |
192 | | - $this->assertSame(Status::FOUND, $result->getStatusCode()); |
193 | | - $this->assertTrue($result->hasHeader(Header::LOCATION)); |
194 | | - $this->assertSame([self::STEP_ROUTE_PATTERN], $result->getHeader(Header::LOCATION)); |
| 194 | + $this->assertSame(Status::OK, $result->getStatusCode()); |
195 | 195 | } |
196 | 196 |
|
197 | 197 | /** |
@@ -311,7 +311,7 @@ public function test_end_on_get(): void |
311 | 311 | ->step(new ServerRequest(method: Method::GET)) |
312 | 312 | ; |
313 | 313 |
|
314 | | - if ($result->getHeader(Header::LOCATION) === [self::STEP_ROUTE_PATTERN]) { |
| 314 | + if ($this->events[AfterWizard::class] === 0) { |
315 | 315 | $result = $this |
316 | 316 | ->wizard |
317 | 317 | ->step(new ServerRequest(method: Method::POST)) |
@@ -1218,10 +1218,6 @@ public function step(Step $event): void |
1218 | 1218 | { |
1219 | 1219 | $this->events[Step::class]++; |
1220 | 1220 |
|
1221 | | - if ($event->getWizard()->getCurrentStep() === self::END_STEP && $this->endOnGet) { |
1222 | | - $event->continue(false); |
1223 | | - } |
1224 | | - |
1225 | 1221 | if ($event->getRequest()->getMethod() === Method::POST) { |
1226 | 1222 | $step = $event->getWizard()->getCurrentStep(); |
1227 | 1223 | if ($step === self::REPEAT_STEP) { |
@@ -1263,6 +1259,11 @@ public function step(Step $event): void |
1263 | 1259 | default: |
1264 | 1260 | break; |
1265 | 1261 | } |
| 1262 | + } else { |
| 1263 | + if ($this->endOnGet && $event->getWizard()->getCurrentStep() === self::END_STEP) { |
| 1264 | + $event->continue(false); |
| 1265 | + } |
| 1266 | + $event->setData(new Response()); |
1266 | 1267 | } |
1267 | 1268 | } |
1268 | 1269 |
|
|
0 commit comments