From 7c4f56d898550a6917b6eb3ae0914b5742dc400f Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Thu, 25 Jun 2020 22:41:06 +0200 Subject: [PATCH 1/6] Use new persistence namespace in docs (#324) From 89453309febadde1f4618d39e1f19e70ff2a7ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 29 May 2020 19:40:16 +0200 Subject: [PATCH 2/6] Allow php 8 --- .travis.yml | 5 +++++ composer.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 475f1073..3d720cf5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,11 @@ jobs: php: 7.3 env: DEPENDENCIES="dev" + - stage: test + php: nightly + before_install: + - composer config platform.php 7.4.99 + # Run phpcs - stage: Code Quality php: 7.2 diff --git a/composer.json b/composer.json index aebe1781..70514968 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ } ], "require": { - "php": "^7.1", + "php": "^7.1 || ^8.0", "doctrine/data-fixtures": "^1.3", "doctrine/doctrine-bundle": "^1.11|^2.0", "doctrine/orm": "^2.6.0", From 83665be93c1f709f3e65d22f348b524a377f6fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 4 Aug 2020 19:35:16 +0200 Subject: [PATCH 3/6] Allow using PHPunit 9.3 --- .travis.yml | 1 + Tests/IntegrationTest.php | 15 +++++++-------- composer.json | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3d720cf5..8db33bcd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,6 +33,7 @@ jobs: php: nightly before_install: - composer config platform.php 7.4.99 + - composer config minimum-stability dev # Run phpcs - stage: Code Quality diff --git a/Tests/IntegrationTest.php b/Tests/IntegrationTest.php index 069c5465..6e0cd4cf 100644 --- a/Tests/IntegrationTest.php +++ b/Tests/IntegrationTest.php @@ -10,6 +10,7 @@ use Doctrine\Bundle\FixturesBundle\Tests\Fixtures\FooBundle\DataFixtures\RequiredConstructorArgsFixtures; use Doctrine\Bundle\FixturesBundle\Tests\Fixtures\FooBundle\DataFixtures\WithDependenciesFixtures; use Doctrine\Common\DataFixtures\Loader; +use LogicException; use PHPUnit\Framework\TestCase; use RuntimeException; use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader; @@ -85,10 +86,6 @@ public function testFixturesLoaderWhenFixtureHasDepdencenyThatIsNotYetLoaded() : $this->assertInstanceOf(WithDependenciesFixtures::class, $actualFixtures[1]); } - /** - * @expectedException \LogicException - * @expectedExceptionMessage The getDependencies() method returned a class (Doctrine\Bundle\FixturesBundle\Tests\Fixtures\FooBundle\DataFixtures\RequiredConstructorArgsFixtures) that has required constructor arguments. Upgrade to "doctrine/data-fixtures" version 1.3 or higher to support this. - */ public function testExceptionWithDependenciesWithRequiredArguments() : void { // see https://github.com/doctrine/data-fixtures/pull/274 @@ -112,16 +109,15 @@ public function testExceptionWithDependenciesWithRequiredArguments() : void $kernel->boot(); $container = $kernel->getContainer(); + $this->expectException(LogicException::class); + $this->expectExceptionMessage('The getDependencies() method returned a class (Doctrine\Bundle\FixturesBundle\Tests\Fixtures\FooBundle\DataFixtures\RequiredConstructorArgsFixtures) that has required constructor arguments. Upgrade to "doctrine/data-fixtures" version 1.3 or higher to support this.'); + /** @var ContainerAwareLoader $loader */ $loader = $container->get('test.doctrine.fixtures.loader'); $loader->getFixtures(); } - /** - * @expectedException \LogicException - * @expectedExceptionMessage The "Doctrine\Bundle\FixturesBundle\Tests\Fixtures\FooBundle\DataFixtures\RequiredConstructorArgsFixtures" fixture class is trying to be loaded, but is not available. Make sure this class is defined as a service and tagged with "doctrine.fixture.orm". - */ public function testExceptionIfDependentFixtureNotWired() : void { // only runs on newer versions of doctrine/data-fixtures @@ -139,6 +135,9 @@ public function testExceptionIfDependentFixtureNotWired() : void $kernel->boot(); $container = $kernel->getContainer(); + $this->expectException(LogicException::class); + $this->expectExceptionMessage('The "Doctrine\Bundle\FixturesBundle\Tests\Fixtures\FooBundle\DataFixtures\RequiredConstructorArgsFixtures" fixture class is trying to be loaded, but is not available. Make sure this class is defined as a service and tagged with "doctrine.fixture.orm".'); + /** @var ContainerAwareLoader $loader */ $loader = $container->get('test.doctrine.fixtures.loader'); diff --git a/composer.json b/composer.json index 70514968..90114819 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ }, "require-dev": { "doctrine/coding-standard": "^6.0", - "phpunit/phpunit": "^7.4", + "phpunit/phpunit": "^7.4 || ^9.2", "symfony/phpunit-bridge": "^4.1|^5.0" }, "autoload": { From 9b646df4a417a7020073063cacad8c81d2903c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 4 Aug 2020 20:07:59 +0200 Subject: [PATCH 4/6] Adapt to new exception message --- Tests/Command/LoadDataFixturesDoctrineCommandTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Tests/Command/LoadDataFixturesDoctrineCommandTest.php b/Tests/Command/LoadDataFixturesDoctrineCommandTest.php index 12b38069..742f5fa9 100644 --- a/Tests/Command/LoadDataFixturesDoctrineCommandTest.php +++ b/Tests/Command/LoadDataFixturesDoctrineCommandTest.php @@ -10,6 +10,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\Container; use TypeError; +use const PHP_VERSION_ID; class LoadDataFixturesDoctrineCommandTest extends TestCase { @@ -24,6 +25,14 @@ public function testInstantiatingWithoutManagerRegistry() : void try { new LoadDataFixturesDoctrineCommand($loader); } catch (TypeError $e) { + if (PHP_VERSION_ID >= 80000) { + $this->expectExceptionMessage( + <<<'MESSAGE' +Doctrine\Bundle\DoctrineBundle\Command\DoctrineCommand::__construct(): Argument #1 ($doctrine) must be of type Doctrine\Persistence\ManagerRegistry, null given, called in /home/travis/build/doctrine/DoctrineFixturesBundle/Command/LoadDataFixturesDoctrineCommand.php on line 41 +MESSAGE + ); + throw $e; + } $this->expectExceptionMessage('Argument 1 passed to Doctrine\Bundle\DoctrineBundle\Command\DoctrineCommand::__construct() must be an instance of Doctrine\Persistence\ManagerRegistry, null given'); throw $e; From a0815ceba6ab5c5efe3d39f0c89aa46040ebf158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 29 Aug 2020 22:35:56 +0200 Subject: [PATCH 5/6] Allow persistence 2 The bundle is already compatible with it. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 90114819..25955786 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "doctrine/data-fixtures": "^1.3", "doctrine/doctrine-bundle": "^1.11|^2.0", "doctrine/orm": "^2.6.0", - "doctrine/persistence": "^1.3", + "doctrine/persistence": "^1.3|^2.0", "symfony/config": "^3.4|^4.3|^5.0", "symfony/console": "^3.4|^4.3|^5.0", "symfony/dependency-injection": "^3.4|^4.3|^5.0", From c64d8d3260b680bb58470a596f6260e76b18777e Mon Sep 17 00:00:00 2001 From: Zul3s Date: Wed, 2 Sep 2020 06:42:23 +0200 Subject: [PATCH 6/6] Allow option to exclude purged tables/views --- Command/LoadDataFixturesDoctrineCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Command/LoadDataFixturesDoctrineCommand.php b/Command/LoadDataFixturesDoctrineCommand.php index 1a2e9089..70456b60 100644 --- a/Command/LoadDataFixturesDoctrineCommand.php +++ b/Command/LoadDataFixturesDoctrineCommand.php @@ -54,6 +54,7 @@ protected function configure() ->addOption('em', null, InputOption::VALUE_REQUIRED, 'The entity manager to use for this command.') ->addOption('shard', null, InputOption::VALUE_REQUIRED, 'The shard connection to use for this command.') ->addOption('purge-with-truncate', null, InputOption::VALUE_NONE, 'Purge data by using a database-level TRUNCATE statement') + ->addOption('purge-excluded', null, InputOption::VALUE_IS_ARRAY|InputOption::VALUE_OPTIONAL, 'Array of table/view names to be excluded from purge') ->setHelp(<<%command.name% command loads data fixtures from your application: @@ -118,7 +119,8 @@ protected function execute(InputInterface $input, OutputInterface $output) return 1; } - $purger = new ORMPurger($em); + $excluded = $input->getOption('purge-excluded'); + $purger = new ORMPurger($em, $excluded); $purger->setPurgeMode($input->getOption('purge-with-truncate') ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE); $executor = new ORMExecutor($em, $purger); $executor->setLogger(static function ($message) use ($ui) : void {