Skip to content

Commit

Permalink
Added tests for creating a project with install.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed May 20, 2024
1 parent f3341a7 commit bf1061a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/phpunit/Fixtures/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
}
},
"minimum-stability": "dev",
"require": {
"php": ">=8.2",
"monolog/monolog": "^2.0"
},
"scripts": {
"customize": [
"YourOrg\\YourPackage\\CustomizeCommand"
Expand Down
40 changes: 40 additions & 0 deletions tests/phpunit/Functional/CreateProjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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');
}

}
1 change: 1 addition & 0 deletions tests/phpunit/Functional/CustomizerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down

0 comments on commit bf1061a

Please sign in to comment.