Skip to content

Commit c304e46

Browse files
Add a scenario for testing the new IntegerType
1 parent be46a14 commit c304e46

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

features/bootstrap/FeatureContext.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ private function getOutput()
108108
*/
109109
public function theCommandHasFinishedSuccessfully()
110110
{
111-
Assert::assertEquals(0, $this->tester->getStatusCode());
111+
if ($this->tester->getStatusCode() !== 0) {
112+
throw new RuntimeException(
113+
"Expected the command to succeed. Command output:\n" . $this->getOutput()
114+
);
115+
}
112116
}
113117

114118
/**

features/interactive.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ Feature: It is possible to interactively fill in a form from the CLI
4848
)
4949
"""
5050

51+
Scenario: Provide an integer
52+
When I run the command "form:age" and I provide as input
53+
| Input |
54+
| 10 |
55+
Then the command has finished successfully
56+
And the output should be
57+
"""
58+
Your age: Array
59+
(
60+
[age] => 10
61+
)
62+
"""
63+
5164
Scenario: Select a value
5265
When I run the command "form:color" and I provide as input
5366
| Input |

test/Form/AgeType.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Matthias\SymfonyConsoleForm\Tests\Form;
5+
6+
use Symfony\Component\Form\AbstractType;
7+
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
8+
use Symfony\Component\Form\FormBuilderInterface;
9+
10+
final class AgeType extends AbstractType
11+
{
12+
public function buildForm(FormBuilderInterface $builder, array $options)
13+
{
14+
$builder->add('age', IntegerType::class, ['label' => 'Your age']);
15+
}
16+
}

test/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ services:
6666
tags:
6767
- { name: console.command }
6868

69+
age_command:
70+
class: Matthias\SymfonyConsoleForm\Tests\Command\PrintFormDataCommand
71+
arguments:
72+
- Matthias\SymfonyConsoleForm\Tests\Form\AgeType
73+
- age
74+
tags:
75+
- { name: console.command }
76+
6977
empty_label_command:
7078
class: Matthias\SymfonyConsoleForm\Tests\Command\PrintFormDataCommand
7179
arguments:

0 commit comments

Comments
 (0)