File tree Expand file tree Collapse file tree 2 files changed +44
-4
lines changed
tests/Integration/Console Expand file tree Collapse file tree 2 files changed +44
-4
lines changed Original file line number Diff line number Diff line change @@ -236,11 +236,13 @@ protected function commandIsolationMutex()
236
236
*/
237
237
protected function resolveCommand ($ command )
238
238
{
239
- if (! class_exists ($ command )) {
240
- return $ this ->getApplication ()->find ($ command );
241
- }
239
+ if (is_string ($ command )) {
240
+ if (! class_exists ($ command )) {
241
+ return $ this ->getApplication ()->find ($ command );
242
+ }
242
243
243
- $ command = $ this ->laravel ->make ($ command );
244
+ $ command = $ this ->laravel ->make ($ command );
245
+ }
244
246
245
247
if ($ command instanceof SymfonyCommand) {
246
248
$ command ->setApplication ($ this ->getApplication ());
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Illuminate \Tests \Integration \Console ;
4
+
5
+ use Illuminate \Foundation \Console \ViewClearCommand ;
6
+ use Illuminate \Support \Facades \Artisan ;
7
+ use Orchestra \Testbench \TestCase ;
8
+ use PHPUnit \Framework \Attributes \TestWith ;
9
+
10
+ class CallCommandsTest extends TestCase
11
+ {
12
+ protected function setUp (): void
13
+ {
14
+ $ this ->afterApplicationCreated (function () {
15
+ Artisan::command ('test:a ' , function () {
16
+ $ this ->call ('view:clear ' );
17
+ });
18
+
19
+ Artisan::command ('test:b ' , function () {
20
+ $ this ->call (ViewClearCommand::class);
21
+ });
22
+
23
+ Artisan::command ('test:c ' , function () {
24
+ $ this ->call ($ this ->laravel ->make (ViewClearCommand::class));
25
+ });
26
+ });
27
+
28
+ parent ::setUp ();
29
+ }
30
+
31
+ #[TestWith(['test:a ' ])]
32
+ #[TestWith(['test:b ' ])]
33
+ #[TestWith(['test:c ' ])]
34
+ public function testItCanCallCommands (string $ command )
35
+ {
36
+ $ this ->artisan ($ command )->assertSuccessful ();
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments