File tree 4 files changed +77
-0
lines changed
4 files changed +77
-0
lines changed Original file line number Diff line number Diff line change @@ -161,3 +161,21 @@ Feature: It is possible to interactively fill in a form from the CLI
161
161
"""
162
162
[name] => Jelmer
163
163
"""
164
+
165
+ Scenario : Remove an address from pre filled collection of blocked addresses
166
+ When I run the command "form:blocked_addresses" and I provide as input
167
+ """
168
+ [enter][enter][enter][enter][enter]n[enter][enter]
169
+ """
170
+ And the output should contain
171
+ """
172
+ [street] => first street
173
+ """
174
+ And the output should contain
175
+ """
176
+ [street] => second street
177
+ """
178
+ And the output should not contain
179
+ """
180
+ [street] => third street
181
+ """
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Matthias \SymfonyConsoleForm \Tests \Form ;
4
+
5
+ use Matthias \SymfonyConsoleForm \Tests \Form \Data \Address ;
6
+ use Symfony \Component \Form \AbstractType ;
7
+ use Symfony \Component \Form \Extension \Core \Type \CollectionType ;
8
+ use Symfony \Component \Form \FormBuilderInterface ;
9
+ use Symfony \Component \OptionsResolver \OptionsResolver ;
10
+
11
+ class BlockedAddressesType extends AbstractType
12
+ {
13
+ public function buildForm (FormBuilderInterface $ builder , array $ options )
14
+ {
15
+ $ builder
16
+ ->add (
17
+ 'addresses ' ,
18
+ CollectionType::class,
19
+ [
20
+ 'entry_type ' => AddressType::class,
21
+ 'allow_add ' => true ,
22
+ 'allow_delete ' => true ,
23
+ 'label ' => 'Blocked addresses ' ,
24
+ ]
25
+ )
26
+ ;
27
+ }
28
+
29
+ public function configureOptions (OptionsResolver $ resolver )
30
+ {
31
+ $ resolver ->setDefaults (
32
+ [
33
+ 'data ' => [
34
+ 'addresses ' => [
35
+ new Address ('first street ' ),
36
+ new Address ('second street ' ),
37
+ new Address ('third street ' ),
38
+ ],
39
+ ],
40
+ ]
41
+ );
42
+ }
43
+ }
Original file line number Diff line number Diff line change 5
5
class Address
6
6
{
7
7
public $ street ;
8
+
9
+ /**
10
+ * @param $street
11
+ */
12
+ public function __construct ($ street )
13
+ {
14
+ $ this ->street = $ street ;
15
+ }
8
16
}
Original file line number Diff line number Diff line change @@ -26,6 +26,14 @@ services:
26
26
tags :
27
27
- { name: console.command }
28
28
29
+ blocked_addresses_command :
30
+ class : Matthias\SymfonyConsoleForm\Tests\Command\PrintFormDataCommand
31
+ arguments :
32
+ - Matthias\SymfonyConsoleForm\Tests\Form\BlockedAddressesType
33
+ - blocked_addresses
34
+ tags :
35
+ - { name: console.command }
36
+
29
37
color_command :
30
38
class : Matthias\SymfonyConsoleForm\Tests\Command\PrintFormDataCommand
31
39
arguments :
You can’t perform that action at this time.
0 commit comments