2626
2727class WpCliCommandTest extends TestCase
2828{
29+ public function testPerformDoesNotAddNoColorOptionWhenColorOptionIsPresent (): void
30+ {
31+ $ this ->setupActiveTeam ();
32+ $ project = $ this ->setupValidProject (1 , 'project ' , ['production ' => []], 'wordpress ' , WordPressProjectType::class);
33+ $ environment = EnvironmentFactory::create (['name ' => 'production ' ]);
34+
35+ $ this ->apiClient ->shouldReceive ('getEnvironments ' )->with (\Mockery::type (Project::class))->andReturn (new ResourceCollection ([$ environment ]));
36+ $ this ->apiClient ->shouldReceive ('createInvocation ' )->with (\Mockery::type (Project::class), $ environment , ['php ' => 'bin/wp plugin list --color ' ])->andReturn (collect (['id ' => 123 ]));
37+ $ this ->apiClient ->shouldReceive ('getInvocation ' )->with (123 )->andReturn (collect ([
38+ 'status ' => 'completed ' ,
39+ 'result ' => [
40+ 'exitCode ' => 0 ,
41+ 'output ' => 'plugin list output ' ,
42+ ],
43+ ]));
44+
45+ $ this ->bootApplication ([new WpCliCommand ($ this ->apiClient , $ this ->createExecutionContextFactory ([
46+ Environment::class => function () { return new EnvironmentDefinition (); },
47+ ]))]);
48+
49+ $ tester = $ this ->executeCommand (WpCliCommand::NAME , ['wp-command ' => ['plugin ' , 'list ' , '--color ' ], '--environment ' => 'production ' ]);
50+
51+ $ this ->assertStringContainsString ('Running "wp plugin list --color" on "production" environment ' , $ tester ->getDisplay ());
52+ }
53+
2954 public function testPerformExecutesWpCliCommand (): void
3055 {
3156 $ this ->setupActiveTeam ();
3257 $ project = $ this ->setupValidProject (1 , 'project ' , ['production ' => []], 'wordpress ' , WordPressProjectType::class);
3358 $ environment = EnvironmentFactory::create (['name ' => 'production ' ]);
3459
3560 $ this ->apiClient ->shouldReceive ('getEnvironments ' )->with (\Mockery::type (Project::class))->andReturn (new ResourceCollection ([$ environment ]));
36- $ this ->apiClient ->shouldReceive ('createInvocation ' )->with (\Mockery::type (Project::class), $ environment , ['php ' => 'bin/wp plugin list ' ])->andReturn (collect (['id ' => 123 ]));
61+ $ this ->apiClient ->shouldReceive ('createInvocation ' )->with (\Mockery::type (Project::class), $ environment , ['php ' => 'bin/wp plugin list --no-color ' ])->andReturn (collect (['id ' => 123 ]));
3762 $ this ->apiClient ->shouldReceive ('getInvocation ' )->with (123 )->andReturn (collect ([
3863 'status ' => 'completed ' ,
3964 'result ' => [
@@ -59,7 +84,7 @@ public function testPerformExecutesWpCliCommandAsynchronously(): void
5984 $ environment = EnvironmentFactory::create (['name ' => 'production ' ]);
6085
6186 $ this ->apiClient ->shouldReceive ('getEnvironments ' )->with (\Mockery::type (Project::class))->andReturn (new ResourceCollection ([$ environment ]));
62- $ this ->apiClient ->shouldReceive ('createInvocation ' )->with (\Mockery::type (Project::class), $ environment , ['php ' => 'bin/wp cache flush ' ])->andReturn (collect (['id ' => 123 ]));
87+ $ this ->apiClient ->shouldReceive ('createInvocation ' )->with (\Mockery::type (Project::class), $ environment , ['php ' => 'bin/wp cache flush --no-color ' ])->andReturn (collect (['id ' => 123 ]));
6388
6489 $ this ->bootApplication ([new WpCliCommand ($ this ->apiClient , $ this ->createExecutionContextFactory ([
6590 Environment::class => function () { return new EnvironmentDefinition (); },
@@ -77,7 +102,7 @@ public function testPerformExecutesWpCliCommandInteractively(): void
77102 $ environment = EnvironmentFactory::create (['name ' => 'production ' ]);
78103
79104 $ this ->apiClient ->shouldReceive ('getEnvironments ' )->with (\Mockery::type (Project::class))->andReturn (new ResourceCollection ([$ environment ]));
80- $ this ->apiClient ->shouldReceive ('createInvocation ' )->with (\Mockery::type (Project::class), $ environment , ['php ' => 'bin/wp post list ' ])->andReturn (collect (['id ' => 123 ]));
105+ $ this ->apiClient ->shouldReceive ('createInvocation ' )->with (\Mockery::type (Project::class), $ environment , ['php ' => 'bin/wp post list --no-color ' ])->andReturn (collect (['id ' => 123 ]));
81106 $ this ->apiClient ->shouldReceive ('getInvocation ' )->with (123 )->andReturn (collect ([
82107 'status ' => 'completed ' ,
83108 'result ' => [
@@ -103,7 +128,7 @@ public function testPerformRemovesWpPrefixFromCommand(): void
103128 $ environment = EnvironmentFactory::create (['name ' => 'production ' ]);
104129
105130 $ this ->apiClient ->shouldReceive ('getEnvironments ' )->with (\Mockery::type (Project::class))->andReturn (new ResourceCollection ([$ environment ]));
106- $ this ->apiClient ->shouldReceive ('createInvocation ' )->with (\Mockery::type (Project::class), $ environment , ['php ' => 'bin/wp plugin list ' ])->andReturn (collect (['id ' => 123 ]));
131+ $ this ->apiClient ->shouldReceive ('createInvocation ' )->with (\Mockery::type (Project::class), $ environment , ['php ' => 'bin/wp plugin list --no-color ' ])->andReturn (collect (['id ' => 123 ]));
107132 $ this ->apiClient ->shouldReceive ('getInvocation ' )->with (123 )->andReturn (collect ([
108133 'status ' => 'completed ' ,
109134 'result ' => [
0 commit comments