Skip to content

Commit

Permalink
minor #648 using stable-dev in tests to get latest fixes from Symfony…
Browse files Browse the repository at this point in the history
… (weaverryan)

This PR was squashed before being merged into the 1.0-dev branch.

Discussion
----------

using stable-dev in tests to get latest fixes from Symfony

This avoids a behavior change in symfony/console@6f533d9...d2c9f77 from symfony/symfony#37286

I'll create a PR to revert this after merge, which we will merge once the issue is resolved.

Commits
-------

1309c01 updating test in one other spot
ccfd248 forcing stable ORM in tests
6b512b8 making migration test work in all versions
b5a5a11 phpcs
6af124a Guaranteeing that dev versions will get dev dependencies
fd89d5d Forcing "stable" for 7.1
73f9ecc updating test for new version of migrations
0334718 Using stable-dev as default version in tests
  • Loading branch information
weaverryan committed Jul 6, 2020
2 parents 9191aec + 1309c01 commit 51c48ca
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -18,7 +18,9 @@ matrix:
fast_finish: true
include:
- php: 7.1.33
env: MAKER_TEST_VERSION=stable
- php: 7.3
env: MAKER_TEST_VERSION=stable-dev
- php: 7.3
env: MAKER_TEST_VERSION=dev
allow_failures:
Expand Down
16 changes: 11 additions & 5 deletions src/Test/MakerTestEnvironment.php
Expand Up @@ -319,14 +319,20 @@ private function buildFlexSkeleton()
$this->cachePath
)->run();

$rootPath = str_replace('\\', '\\\\', realpath(__DIR__.'/../..'));

// dev deps already will allow dev deps, but we should prefer stable
if (false !== strpos($targetVersion, 'dev')) {
MakerTestProcess::create('composer config prefer-stable true', $this->flexPath)
// make sure that dev versions allow dev deps
// for the current stable minor of Symfony, by default,
// minimum-stability is NOT dev, even when getting the -dev version
// of symfony/skeleton
MakerTestProcess::create('composer config minimum-stability dev', $this->flexPath)
->run();

MakerTestProcess::create(['composer', 'update'], $this->flexPath)
->run();
}

$rootPath = str_replace('\\', '\\\\', realpath(__DIR__.'/../..'));

// processes any changes needed to the Flex project
$replacements = [
[
Expand Down Expand Up @@ -429,7 +435,7 @@ private function determineMissingDependencies(): array
private function getTargetFlexVersion(): string
{
if (null === $this->targetFlexVersion) {
$targetVersion = $_SERVER['MAKER_TEST_VERSION'] ?? 'stable';
$targetVersion = $_SERVER['MAKER_TEST_VERSION'] ?? 'stable-dev';

if ('stable' === $targetVersion) {
$this->targetFlexVersion = '';
Expand Down
2 changes: 1 addition & 1 deletion src/Test/MakerTestProcess.php
Expand Up @@ -24,7 +24,7 @@ final class MakerTestProcess

private function __construct($commandLine, $cwd, array $envVars, $timeout)
{
$this->process = method_exists(Process::class, 'fromShellCommandline')
$this->process = \is_string($commandLine)
? Process::fromShellCommandline($commandLine, $cwd, null, null, $timeout)
: new Process($commandLine, $cwd, null, null, $timeout);

Expand Down
11 changes: 7 additions & 4 deletions tests/Maker/MakeMigrationTest.php
Expand Up @@ -28,19 +28,22 @@ public function getTestDetails()
// doctrine-migrations-bundle only requires doctrine-bundle, which
// only requires doctrine/dbal. But we're testing with the ORM,
// so let's install it
->addExtraDependencies('doctrine/orm')
->addExtraDependencies('doctrine/orm:@stable')
->assert(function (string $output, string $directory) {
$this->assertStringContainsString('Success', $output);

// support for Migrations 3 (/migrations) and earlier
$migrationsDirectoryPath = file_exists($directory.'/migrations') ? 'migrations' : 'src/Migrations';

$finder = new Finder();
$finder->in($directory.'/src/Migrations')
$finder->in($directory.'/'.$migrationsDirectoryPath)
->name('*.php');
$this->assertCount(1, $finder);

// see that the exact filename is in the output
$iterator = $finder->getIterator();
$iterator->rewind();
$this->assertStringContainsString(sprintf('"src/Migrations/%s"', $iterator->current()->getFilename()), $output);
$this->assertStringContainsString(sprintf('"%s/%s"', $migrationsDirectoryPath, $iterator->current()->getFilename()), $output);
}),
];

Expand All @@ -50,7 +53,7 @@ public function getTestDetails()
->setFixtureFilesPath(__DIR__.'/../fixtures/MakeMigration')
->configureDatabase()
// sync the database, so no changes are needed
->addExtraDependencies('doctrine/orm')
->addExtraDependencies('doctrine/orm:@stable')
->assert(function (string $output, string $directory) {
$this->assertNotContains('Success', $output);

Expand Down

0 comments on commit 51c48ca

Please sign in to comment.