@@ -51,9 +51,10 @@ public function testWillInstantiate(): void
5151 {
5252 $ maker = new Maker ('' );
5353 $ this ->assertContainsOnlyInstancesOf (Maker::class, [$ maker ]);
54+ $ this ->assertTrue ($ maker ->isCli ());
5455 }
5556
56- public function testInvokeWillOutputErrorWhenNotInCliMode (): void
57+ public function testCallingInvokeWillOutputErrorWhenNotInCliMode (): void
5758 {
5859 $ maker = $ this ->getMockBuilder (Maker::class)
5960 ->onlyMethods (['isCli ' ])
@@ -69,7 +70,7 @@ public function testInvokeWillOutputErrorWhenNotInCliMode(): void
6970 );
7071 }
7172
72- public function testInvokeWillOutputErrorWhenInvalidComponent (): void
73+ public function testCallingInvokeWillOutputErrorWhenInvalidComponent (): void
7374 {
7475 $ root = vfsStream::setup ('root ' , 0644 , [
7576 'composer.json ' => '{
@@ -98,7 +99,7 @@ public function testInvokeWillOutputErrorWhenInvalidComponent(): void
9899 $ this ->assertEmpty (stream_get_contents ($ this ->outputStream ));
99100 }
100101
101- public function testInvokeWithoutArgsWillOutputHelpText (): void
102+ public function testCallingInvokeWithoutArgsWillOutputHelpText (): void
102103 {
103104 $ root = vfsStream::setup ('root ' , 0644 , [
104105 'composer.json ' => '{
@@ -161,4 +162,35 @@ public function testCallingInvokeWithArgsModuleWillOutputDebugInfo(): void
161162 );
162163 $ this ->assertEmpty (stream_get_contents ($ this ->errorStream ));
163164 }
165+
166+ public function testCallingInvokeWithValidComponentIdentifierWillSucceed (): void
167+ {
168+ $ root = vfsStream::setup ('root ' , 0644 , [
169+ 'composer.json ' => '{
170+ "autoload": {
171+ "psr-4": {
172+ "Api \\\\App \\\\": "src/App/src/"
173+ }
174+ }
175+ } ' ,
176+ 'src ' => [
177+ 'App ' => [],
178+ ],
179+ ]);
180+
181+ fwrite ($ this ->inputStream , 'App ' . PHP_EOL );
182+ fwrite ($ this ->inputStream , 'Test ' . PHP_EOL );
183+ fwrite ($ this ->inputStream , PHP_EOL );
184+ rewind ($ this ->inputStream );
185+
186+ $ maker = $ this ->getMockBuilder (Maker::class)
187+ ->onlyMethods (['isCli ' ])
188+ ->setConstructorArgs ([$ root ->url ()])
189+ ->getMock ();
190+ $ maker ->method ('isCli ' )->willReturn (true );
191+ $ maker (['' , 'command ' ]);
192+
193+ rewind ($ this ->errorStream );
194+ $ this ->assertEmpty (stream_get_contents ($ this ->errorStream ));
195+ }
164196}
0 commit comments