Skip to content

Commit 622ea96

Browse files
Add fix for symfony 4.2 console version output changes
1 parent a5bc15c commit 622ea96

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"php": "^7.1",
1717
"ext-mongodb": "*",
1818
"mongodb/mongodb": "^1.4",
19-
"symfony/console": "^3.4|^4",
20-
"symfony/yaml": "^3.4|^4"
19+
"symfony/console": "^2.7|^3.4|^4",
20+
"symfony/yaml": "^2.7|^3.4|^4"
2121
},
2222
"require-dev": {
2323
"phpunit/phpunit": "^7.0",

tests/AntiMattr/Tests/MongoDB/Migrations/Tools/Console/Command/StatusCommandTest.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,19 @@ public function testExecuteWithShowingVersions()
438438
->with("\n <info>==</info> Available Migration Versions\n")
439439
;
440440

441-
$this->output->expects($this->at(40))
441+
// Symfony 4.2 has different output
442+
$consoleVersion = $this->getSymfonyConsoleVersion();
443+
$index = 39;
444+
if(version_compare($consoleVersion, '4.2.0', 'ge')) {
445+
$index = 40;
446+
}
447+
448+
$this->output->expects($this->at($index))
442449
->method('writeln')
443450
->with("\n <info>==</info> Previously Executed Unavailable Migration Versions\n")
444451
;
445452

446-
$this->output->expects($this->at(41))
453+
$this->output->expects($this->at(++$index))
447454
->method('writeln')
448455
->with(
449456
sprintf(
@@ -460,6 +467,19 @@ public function testExecuteWithShowingVersions()
460467
$this->output
461468
);
462469
}
470+
471+
/**
472+
* @return mixed
473+
*/
474+
private function getSymfonyConsoleVersion()
475+
{
476+
$versionData = [];
477+
exec('composer show | grep symfony/console', $versionData);
478+
$versionPart = explode('v', $versionData[0]);
479+
$versionPart2 = explode(' ', $versionPart[1]);
480+
$consoleVersion = $versionPart2[0];
481+
return $consoleVersion;
482+
}
463483
}
464484

465485
class StatusCommandStub extends StatusCommand

0 commit comments

Comments
 (0)