-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from lemberg/issue/205-remove-package-php-fatal
[WIP] Add functional test covering package installation & removal
- Loading branch information
Showing
10 changed files
with
280 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Lemberg\Tests\Functional\Draft\Environment; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Filesystem\Filesystem; | ||
|
||
/** | ||
* Base functional test. | ||
* | ||
* @coversNothing | ||
*/ | ||
abstract class AbstractFunctionalTest extends TestCase { | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $workingDir; | ||
|
||
/** | ||
* @var \Symfony\Component\Filesystem\Filesystem | ||
*/ | ||
protected $fs; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $basePath; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
final protected function setUp(): void { | ||
|
||
$this->workingDir = sys_get_temp_dir() . '/draft-environment'; | ||
|
||
$this->fs = new Filesystem(); | ||
$this->fs->remove($this->workingDir); | ||
$this->fs->mkdir($this->workingDir); | ||
|
||
// Build path to the test composer.json file based on the current class | ||
// name. | ||
$this->basePath = './tests/fixtures/Functional' . str_replace('\\', DIRECTORY_SEPARATOR, substr(static::class, strlen('Lemberg\Tests\Functional\Draft\Environment'))); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
final protected function tearDown(): void { | ||
$this->fs->remove($this->workingDir); | ||
|
||
parent::tearDown(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Lemberg\Tests\Functional\Draft\Environment; | ||
|
||
use Lemberg\Draft\Environment\App; | ||
use Symfony\Component\Process\Process; | ||
|
||
/** | ||
* Tests Draft Environment installation and removal. | ||
* | ||
* @coversNothing | ||
*/ | ||
final class AppTest extends AbstractFunctionalTest { | ||
|
||
/** | ||
* Tests that package installation and removal works as expected. | ||
* | ||
* @doesNotPerformAssertions | ||
*/ | ||
public function testComposerInstallAndRemove(): void { | ||
|
||
$this->fs->mirror($this->basePath, $this->workingDir, NULL, ['override' => TRUE]); | ||
|
||
// Link package working directory, so tests runs against the proper | ||
// source code. | ||
(new Process([ | ||
'vendor/bin/composer', 'config', | ||
'repositories.test', json_encode([ | ||
'type' => 'path', | ||
'url' => getcwd(), | ||
'options' => [ | ||
'symlink' => FALSE, | ||
], | ||
]), | ||
'--working-dir', $this->workingDir, | ||
])) | ||
->mustRun(); | ||
|
||
// Run composer install. | ||
(new Process([ | ||
'vendor/bin/composer', 'install', | ||
'--prefer-dist', | ||
'--no-interaction', | ||
'--no-suggest', | ||
'--working-dir', $this->workingDir, | ||
])) | ||
->mustRun(); | ||
|
||
// Run composer remove. | ||
(new Process([ | ||
'vendor/bin/composer', 'remove', | ||
'--dev', App::PACKAGE_NAME, | ||
'--working-dir', $this->workingDir, | ||
])) | ||
->mustRun(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.