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
parent
f931887304
commit
1684f82a43
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue