1
0
Fork 0

Add `InitCommand.php` Interactive test case (#12068)

* Add single test case for interactive `init` command

* Fix spelling + use single quotes

* Fix test expectations

---------

Co-authored-by: Jordi Boggiano <j.boggiano@seld.be>
pull/11956/merge
Mohamed Hubail 2024-08-22 11:49:55 +03:00 committed by GitHub
parent f931887304
commit 1684f82a43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 39 additions and 0 deletions

View File

@ -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 <test@example.org>', // 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());
}
}