Skip to content

Commit

Permalink
Rely on ocramius/package-versions to render the version
Browse files Browse the repository at this point in the history
Since `Doctrine\ORM\Version` is now deprecated it shall not be updated
on future releases.

This ensures that our CLI tool will present the correct version number.
  • Loading branch information
lcobucci committed Dec 17, 2019
1 parent d629c4e commit d67e3e8
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 12 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"doctrine/event-manager": "^1.1",
"doctrine/instantiator": "^1.3",
"doctrine/persistence": "^1.2",
"ocramius/package-versions": "^1.4",
"symfony/console": "^3.0|^4.0|^5.0"
},
"require-dev": {
Expand Down
56 changes: 53 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
use Doctrine\DBAL\Tools\Console as DBALConsole;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Doctrine\ORM\Version;
use OutOfBoundsException;
use PackageVersions\Versions;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\HelperSet;

Expand Down Expand Up @@ -70,10 +71,11 @@ public static function run(HelperSet $helperSet, array $commands = []) : void
* @param array $commands
*
* @return \Symfony\Component\Console\Application
* @throws OutOfBoundsException
*/
public static function createApplication(HelperSet $helperSet, array $commands = []) : Application
{
$cli = new Application('Doctrine Command Line Interface', Version::VERSION);
$cli = new Application('Doctrine Command Line Interface', Versions::getVersion('doctrine/orm'));
$cli->setCatchExceptions(true);
$cli->setHelperSet($helperSet);
self::addCommands($cli);
Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Doctrine\Tests\ORM\Tools\Console;

use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Version;
use Doctrine\Tests\DoctrineTestCase;
use PackageVersions\Versions;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\HelperSet;

Expand All @@ -21,7 +21,7 @@ public function testCreateApplicationShouldReturnAnApplicationWithTheCorrectComm
$app = ConsoleRunner::createApplication($helperSet);

self::assertSame($helperSet, $app->getHelperSet());
self::assertEquals(Version::VERSION, $app->getVersion());
self::assertSame(Versions::getVersion('doctrine/orm'), $app->getVersion());

self::assertTrue($app->has('dbal:import'));
self::assertTrue($app->has('dbal:reserved-words'));
Expand Down
5 changes: 0 additions & 5 deletions tests/Doctrine/Tests/ORM/Tools/SetupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Doctrine\ORM\Mapping\Driver\XmlDriver;
use Doctrine\ORM\Mapping\Driver\YamlDriver;
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\Version;
use Doctrine\Tests\OrmTestCase;
use Doctrine\Tests\VerifyDeprecations;

Expand All @@ -22,10 +21,6 @@ class SetupTest extends OrmTestCase

public function setUp()
{
if (strpos(Version::VERSION, "DEV") === false) {
$this->markTestSkipped("Test only runs in a dev-installation from Github");
}

$this->originalAutoloaderCount = count(spl_autoload_functions());
$this->originalIncludePath = get_include_path();
}
Expand Down

0 comments on commit d67e3e8

Please sign in to comment.