diff --git a/tests/phpunit/Fixtures/composer.json b/tests/phpunit/Fixtures/composer.json index 4350996..4b8563e 100644 --- a/tests/phpunit/Fixtures/composer.json +++ b/tests/phpunit/Fixtures/composer.json @@ -8,6 +8,10 @@ } }, "minimum-stability": "dev", + "require": { + "php": ">=8.2", + "monolog/monolog": "^2.0" + }, "scripts": { "customize": [ "YourOrg\\YourPackage\\CustomizeCommand" diff --git a/tests/phpunit/Functional/CreateProjectTest.php b/tests/phpunit/Functional/CreateProjectTest.php index c81bac5..1f84a09 100644 --- a/tests/phpunit/Functional/CreateProjectTest.php +++ b/tests/phpunit/Functional/CreateProjectTest.php @@ -22,6 +22,10 @@ public function testCreateProjectNoInstall(): void { $this->assertComposerCommandSuccessOutputContains('Welcome to yourorg/yourpackage project customizer'); $this->assertComposerCommandSuccessOutputContains('Project was customized'); + + $this->assertFileExists('composer.json'); + $this->assertFileDoesNotExist('composer.lock'); + $this->assertDirectoryDoesNotExist('vendor'); } public function testCreateProjectNoInstallCancel(): void { @@ -33,6 +37,42 @@ public function testCreateProjectNoInstallCancel(): void { $this->assertComposerCommandSuccessOutputContains('Welcome to yourorg/yourpackage project customizer'); $this->assertComposerCommandSuccessOutputContains('No changes were made.'); + + $this->assertFileExists('composer.json'); + $this->assertFileDoesNotExist('composer.lock'); + $this->assertDirectoryDoesNotExist('vendor'); + } + + public function testCreateProjectInstall(): void { + $this->customizerSetAnswers([ + self::TUI_ANSWER_NOTHING, + ]); + + $this->composerCreateProject(); + + $this->assertComposerCommandSuccessOutputContains('Welcome to yourorg/yourpackage project customizer'); + $this->assertComposerCommandSuccessOutputContains('Project was customized'); + + $this->assertFileExists('composer.json'); + $this->assertFileExists('composer.lock'); + $this->assertDirectoryExists('vendor'); + $this->assertDirectoryExists('vendor/monolog/monolog'); + } + + public function testCreateProjectInstallCancel(): void { + $this->customizerSetAnswers([ + 'no', + ]); + + $this->composerCreateProject(); + + $this->assertComposerCommandSuccessOutputContains('Welcome to yourorg/yourpackage project customizer'); + $this->assertComposerCommandSuccessOutputContains('No changes were made.'); + + $this->assertFileExists('composer.json'); + $this->assertFileExists('composer.lock'); + $this->assertDirectoryExists('vendor'); + $this->assertDirectoryExists('vendor/monolog/monolog'); } } diff --git a/tests/phpunit/Functional/CustomizerTestCase.php b/tests/phpunit/Functional/CustomizerTestCase.php index 687f17e..bba9070 100644 --- a/tests/phpunit/Functional/CustomizerTestCase.php +++ b/tests/phpunit/Functional/CustomizerTestCase.php @@ -108,6 +108,7 @@ protected function composerCreateProject(array $options = []): void { $defaults = [ 'command' => 'create-project', 'package' => $this->packageName, + 'directory' => $this->dirs->sut, 'version' => '@dev', '--repository' => [ json_encode([