2
2
3
3
declare (strict_types=1 );
4
4
5
- namespace Tests \Feature \Console ;
6
-
7
5
use Laravel \Prompts \Key ;
8
6
use Laravel \Prompts \Prompt ;
9
- use Tests \TestCase ;
10
7
11
- class InstallCommandMultiselectTest extends TestCase
12
- {
13
- /**
14
- * Test that multiselect returns keys when given an associative array.
15
- */
16
- public function test_multiselect_returns_keys_for_associative_array (): void
17
- {
18
- // Mock the prompt to simulate user selecting options
19
- // Note: mcp_server is already selected by default, so we don't toggle it
20
- Prompt::fake ([
21
- Key::DOWN , // Move to second option (ai_guidelines)
22
- Key::SPACE , // Select second option
23
- Key::ENTER , // Submit
24
- ]);
8
+ test ('multiselect returns keys for associative array ' , function () {
9
+ // Mock the prompt to simulate user selecting options
10
+ // Note: mcp_server is already selected by default, so we don't toggle it
11
+ Prompt::fake ([
12
+ Key::DOWN , // Move to second option (ai_guidelines)
13
+ Key::SPACE , // Select second option
14
+ Key::ENTER , // Submit
15
+ ]);
25
16
26
- $ result = \Laravel \Prompts \multiselect (
27
- label: 'What shall we install? ' ,
28
- options: [
29
- 'mcp_server ' => 'Boost MCP Server ' ,
30
- 'ai_guidelines ' => 'Package AI Guidelines ' ,
31
- 'style_guidelines ' => 'Laravel Style AI Guidelines ' ,
32
- ],
33
- default: ['mcp_server ' ]
34
- );
17
+ $ result = \Laravel \Prompts \multiselect (
18
+ label: 'What shall we install? ' ,
19
+ options: [
20
+ 'mcp_server ' => 'Boost MCP Server ' ,
21
+ 'ai_guidelines ' => 'Package AI Guidelines ' ,
22
+ 'style_guidelines ' => 'Laravel Style AI Guidelines ' ,
23
+ ],
24
+ default: ['mcp_server ' ]
25
+ );
35
26
36
- // Assert that we get the keys, not the values
37
- $ this -> assertIsArray ( $ result );
38
- $ this -> assertCount ( 2 , $ result , 'Should have 2 items selected ' );
39
- $ this -> assertContains ('mcp_server ' , $ result );
40
- $ this -> assertContains ('ai_guidelines ' , $ result );
41
- $ this -> assertNotContains ('Boost MCP Server ' , $ result );
42
- $ this -> assertNotContains ('Package AI Guidelines ' , $ result );
43
- }
27
+ // Assert that we get the keys, not the values
28
+ expect ( $ result )-> toBeArray ( );
29
+ expect ( $ result )-> toHaveCount ( 2 , 'Should have 2 items selected ' );
30
+ expect ( $ result )-> toContain ('mcp_server ' );
31
+ expect ( $ result )-> toContain ('ai_guidelines ' );
32
+ expect ( $ result )-> not -> toContain ('Boost MCP Server ' );
33
+ expect ( $ result )-> not -> toContain ('Package AI Guidelines ' );
34
+ })-> skipOnWindows ();
44
35
45
- /**
46
- * Test multiselect with numeric indexed array returns values.
47
- */
48
- public function test_multiselect_returns_values_for_indexed_array (): void
49
- {
50
- Prompt::fake ([
51
- Key::SPACE , // Select first option
52
- Key::DOWN , // Move to second option
53
- Key::SPACE , // Select second option
54
- Key::ENTER , // Submit
55
- ]);
36
+ test ('multiselect returns values for indexed array ' , function () {
37
+ Prompt::fake ([
38
+ Key::SPACE , // Select first option
39
+ Key::DOWN , // Move to second option
40
+ Key::SPACE , // Select second option
41
+ Key::ENTER , // Submit
42
+ ]);
56
43
57
- $ result = \Laravel \Prompts \multiselect (
58
- label: 'Select options ' ,
59
- options: ['Option 1 ' , 'Option 2 ' , 'Option 3 ' ],
60
- default: []
61
- );
44
+ $ result = \Laravel \Prompts \multiselect (
45
+ label: 'Select options ' ,
46
+ options: ['Option 1 ' , 'Option 2 ' , 'Option 3 ' ],
47
+ default: []
48
+ );
62
49
63
- // For indexed arrays, it returns the actual values
64
- $ this -> assertIsArray ( $ result );
65
- $ this -> assertContains ('Option 1 ' , $ result );
66
- $ this -> assertContains ('Option 2 ' , $ result );
67
- }
50
+ // For indexed arrays, it returns the actual values
51
+ expect ( $ result )-> toBeArray ( );
52
+ expect ( $ result )-> toContain ('Option 1 ' );
53
+ expect ( $ result )-> toContain ('Option 2 ' );
54
+ })-> skipOnWindows ();
68
55
69
- /**
70
- * Test that demonstrates multiselect behavior is consistent with InstallCommand expectations.
71
- * This ensures Laravel 10/11 compatibility.
72
- */
73
- public function test_multiselect_behavior_matches_install_command_expectations (): void
74
- {
75
- // Test the exact same structure used in InstallCommand::selectBoostFeatures()
76
- // Note: mcp_server and ai_guidelines are already selected by default
77
- Prompt::fake ([
78
- Key::DOWN , // Move to ai_guidelines (already selected)
79
- Key::DOWN , // Move to style_guidelines
80
- Key::SPACE , // Select style_guidelines
81
- Key::ENTER , // Submit
82
- ]);
56
+ test ('multiselect behavior matches install command expectations ' , function () {
57
+ // Test the exact same structure used in InstallCommand::selectBoostFeatures()
58
+ // Note: mcp_server and ai_guidelines are already selected by default
59
+ Prompt::fake ([
60
+ Key::DOWN , // Move to ai_guidelines (already selected)
61
+ Key::DOWN , // Move to style_guidelines
62
+ Key::SPACE , // Select style_guidelines
63
+ Key::ENTER , // Submit
64
+ ]);
83
65
84
- $ toInstallOptions = [
85
- 'mcp_server ' => 'Boost MCP Server ' ,
86
- 'ai_guidelines ' => 'Package AI Guidelines (i.e. Framework, Inertia, Pest) ' ,
87
- 'style_guidelines ' => 'Laravel Style AI Guidelines ' ,
88
- ];
66
+ $ toInstallOptions = [
67
+ 'mcp_server ' => 'Boost MCP Server ' ,
68
+ 'ai_guidelines ' => 'Package AI Guidelines (i.e. Framework, Inertia, Pest) ' ,
69
+ 'style_guidelines ' => 'Laravel Style AI Guidelines ' ,
70
+ ];
89
71
90
- $ result = \Laravel \Prompts \multiselect (
91
- label: 'What shall we install? ' ,
92
- options: $ toInstallOptions ,
93
- default: ['mcp_server ' , 'ai_guidelines ' ],
94
- required: true ,
95
- hint: 'Style guidelines are best for new projects ' ,
96
- );
72
+ $ result = \Laravel \Prompts \multiselect (
73
+ label: 'What shall we install? ' ,
74
+ options: $ toInstallOptions ,
75
+ default: ['mcp_server ' , 'ai_guidelines ' ],
76
+ required: true ,
77
+ hint: 'Style guidelines are best for new projects ' ,
78
+ );
97
79
98
- // Verify we get keys that can be used with in_array checks
99
- $ this -> assertIsArray ( $ result );
100
- $ this -> assertCount ( 3 , $ result ); // All 3 selected (2 default + 1 added)
80
+ // Verify we get keys that can be used with in_array checks
81
+ expect ( $ result )-> toBeArray ( );
82
+ expect ( $ result )-> toHaveCount ( 3 ); // All 3 selected (2 default + 1 added)
101
83
102
- // These are the exact checks used in InstallCommand
103
- $ this -> assertTrue (in_array ('mcp_server ' , $ result , true ));
104
- $ this -> assertTrue (in_array ('ai_guidelines ' , $ result , true ));
105
- $ this -> assertTrue (in_array ('style_guidelines ' , $ result , true ));
84
+ // These are the exact checks used in InstallCommand
85
+ expect (in_array ('mcp_server ' , $ result , true ))-> toBeTrue ( );
86
+ expect (in_array ('ai_guidelines ' , $ result , true ))-> toBeTrue ( );
87
+ expect (in_array ('style_guidelines ' , $ result , true ))-> toBeTrue ( );
106
88
107
- // Verify it doesn't contain the display values
108
- $ this ->assertFalse (in_array ('Boost MCP Server ' , $ result , true ));
109
- $ this ->assertFalse (in_array ('Package AI Guidelines (i.e. Framework, Inertia, Pest) ' , $ result , true ));
110
- }
111
- }
89
+ // Verify it doesn't contain the display values
90
+ expect (in_array ('Boost MCP Server ' , $ result , true ))->toBeFalse ();
91
+ expect (in_array ('Package AI Guidelines (i.e. Framework, Inertia, Pest) ' , $ result , true ))->toBeFalse ();
92
+ })->skipOnWindows ();
0 commit comments