|
26 | 26 | use Symfony\Component\Form\Forms; |
27 | 27 | use Symfony\Component\Form\Tests\Fixtures\Flow\Data\UserSignUp; |
28 | 28 | use Symfony\Component\Form\Tests\Fixtures\Flow\Extension\UserSignUpTypeExtension; |
| 29 | +use Symfony\Component\Form\Tests\Fixtures\Flow\LastStepSkippedType; |
29 | 30 | use Symfony\Component\Form\Tests\Fixtures\Flow\UserSignUpType; |
30 | 31 | use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory; |
31 | 32 | use Symfony\Component\Validator\Mapping\Loader\AttributeLoader; |
@@ -932,4 +933,40 @@ public function testStepValidationGroups() |
932 | 933 | // Check that validation groups are updated |
933 | 934 | self::assertEquals(['Default', 'professional'], $flow->getConfig()->getOption('validation_groups')($flow)); |
934 | 935 | } |
| 936 | + |
| 937 | + public function testLastStepSkippedMarkFlowAsFinished() |
| 938 | + { |
| 939 | + $flow = $this->factory->create(LastStepSkippedType::class, ['currentStep' => 'step1']); |
| 940 | + |
| 941 | + self::assertSame('step1', $flow->getCursor()->getCurrentStep()); |
| 942 | + self::assertFalse($flow->isSubmitted()); |
| 943 | + self::assertNull($flow->getClickedButton()); |
| 944 | + self::assertTrue($flow->has('step1')); |
| 945 | + self::assertTrue($flow->has('navigator')); |
| 946 | + |
| 947 | + $navigatorForm = $flow->get('navigator'); |
| 948 | + self::assertCount(1, $navigatorForm->all()); |
| 949 | + self::assertTrue($navigatorForm->has('next')); |
| 950 | + |
| 951 | + $flow->submit([ |
| 952 | + 'step1' => 'foo', |
| 953 | + 'navigator' => [ |
| 954 | + 'next' => '', |
| 955 | + ], |
| 956 | + ]); |
| 957 | + |
| 958 | + self::assertSame('step1', $flow->getCursor()->getCurrentStep()); |
| 959 | + self::assertTrue($flow->isSubmitted()); |
| 960 | + self::assertTrue($flow->isValid()); |
| 961 | + self::assertFalse($flow->isFinished()); |
| 962 | + self::assertNotNull($button = $flow->getClickedButton()); |
| 963 | + self::assertTrue($button->isNextAction()); |
| 964 | + self::assertTrue($button->isClicked()); |
| 965 | + |
| 966 | + $button->handle(); // $flow->moveNext() is called internally |
| 967 | + |
| 968 | + self::assertTrue($flow->isFinished()); |
| 969 | + self::assertNotSame($flow, $flow->getStepForm()); |
| 970 | + self::assertSame(['currentStep' => 'step1', 'step1' => 'foo'], $flow->getData()); |
| 971 | + } |
935 | 972 | } |
0 commit comments