diff --git a/tests/Composer/Test/Command/InitCommandTest.php b/tests/Composer/Test/Command/InitCommandTest.php index 18847c1e4..41860f628 100644 --- a/tests/Composer/Test/Command/InitCommandTest.php +++ b/tests/Composer/Test/Command/InitCommandTest.php @@ -696,4 +696,43 @@ class InitCommandTest extends TestCase $file = new JsonFile($dir . '/composer.json'); self::assertEquals($expected, $file->read()); } + + public function testInteractiveRun(): void + { + $dir = $this->initTempComposer(); + unlink($dir . '/composer.json'); + unlink($dir . '/auth.json'); + + $appTester = $this->getApplicationTester(); + + $appTester->setInputs([ + 'vendor/pkg', // Pkg name + 'my desciption', // Description + 'Mr. Test ', // Author + 'stable', // Minimum stability + 'library', // Type + 'Custom License', // License + 'no', // Define dependencies + 'no', // Define dev dependencies + 'n', // Add PSR-4 autoload mapping + '', // Confirm generation + ]); + + $appTester->run(['command' => 'init']); + + self::assertSame(0, $appTester->getStatusCode()); + + $expected = [ + 'name' => 'vendor/pkg', + 'description' => 'my desciption', + 'type' => 'library', + 'license' => 'Custom License', + 'authors' => [['name' => 'Mr. Test', 'email' => 'test@example.org']], + 'minimum-stability' => 'stable', + 'require' => [], + ]; + + $file = new JsonFile($dir . '/composer.json'); + self::assertEquals($expected, $file->read()); + } }