diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index aeed3951..a5cb2931 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -23,7 +23,7 @@ jobs: fail-fast: false matrix: php-version: - - '8.2' + - '8.3' dependencies: [ highest, lowest ] make-test: - test_core @@ -38,8 +38,7 @@ jobs: - test_symfony_eloquent_bridge_proxy_manager variant: - 'no-change' - - '"symfony/symfony:^5.4"' - - '"symfony/symfony:^6.4"' + - '"symfony/symfony:^6.4.14"' # To keep in sync with docker-compose.yml services: mysql: @@ -97,12 +96,14 @@ jobs: # in the wiki merge plugin - name: Install doctrine Composer bin dependencies uses: ramsey/composer-install@v3 + if: "matrix.make-test == 'test_doctrine_bridge'" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "${{ matrix.composer-flags }}" working-directory: vendor-bin/doctrine - name: Repeat "Install doctrine Composer bin dependencies" uses: ramsey/composer-install@v3 + if: "matrix.make-test == 'test_doctrine_bridge'" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "${{ matrix.composer-flags }}" @@ -110,12 +111,14 @@ jobs: - name: Install MongoDB Composer bin dependencies uses: ramsey/composer-install@v3 + if: "matrix.make-test == 'test_doctrine_odm_bridge'" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "${{ matrix.composer-flags }}" working-directory: vendor-bin/doctrine_mongodb - name: Repeat "Install MongoDB Composer bin dependencies" uses: ramsey/composer-install@v3 + if: "matrix.make-test == 'test_doctrine_odm_bridge'" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "${{ matrix.composer-flags }}" @@ -123,12 +126,14 @@ jobs: - name: Install Doctrine PHPCR Composer bin dependencies uses: ramsey/composer-install@v3 + if: "matrix.make-test == 'test_doctrine_phpcr_bridge' || matrix.make-test == 'test_symfony_bridge' || matrix.make-test == 'test_symfony_doctrine_bridge'" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "${{ matrix.composer-flags }}" working-directory: vendor-bin/doctrine_phpcr - name: Repeat "Install Doctrine PHPCR Composer bin dependencies" uses: ramsey/composer-install@v3 + if: "matrix.make-test == 'test_doctrine_phpcr_bridge' || matrix.make-test == 'test_symfony_bridge' || matrix.make-test == 'test_symfony_doctrine_bridge'" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "${{ matrix.composer-flags }}" @@ -136,45 +141,37 @@ jobs: - name: Install Eloquent Composer bin dependencies uses: ramsey/composer-install@v3 + if: "matrix.make-test == 'test_eloquent_bridge'" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "${{ matrix.composer-flags }}" working-directory: vendor-bin/eloquent - name: Repeat "Install Eloquent Composer bin dependencies" uses: ramsey/composer-install@v3 + if: "matrix.make-test == 'test_eloquent_bridge'" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "${{ matrix.composer-flags }}" working-directory: vendor-bin/eloquent - # There is a known issue here with Composer - # see https://github.com/composer/composer/issues/10200 - # Meanwhile we break down the installation as a workaround. - # Once this is fixed the whole bin dependencies can probably be installed - # in one step with a timeout adjustment - - name: Remove Symfony from ProxyManager Composer bin dependencies - if: matrix.variant != 'no-change' - run: composer bin proxy-manager remove --dev --no-update symfony/symfony - - name: Install ProxyManager Composer bin dependencies uses: ramsey/composer-install@v3 + if: "matrix.make-test == 'test_symfony_doctrine_bridge_proxy_manager' || matrix.make-test == 'test_symfony_eloquent_bridge_proxy_manager'" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "${{ matrix.composer-flags }}" working-directory: vendor-bin/proxy-manager - name: Repeat "Install ProxyManager Composer bin dependencies" uses: ramsey/composer-install@v3 + if: "matrix.make-test == 'test_symfony_doctrine_bridge_proxy_manager' || matrix.make-test == 'test_symfony_eloquent_bridge_proxy_manager'" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "${{ matrix.composer-flags }}" working-directory: vendor-bin/proxy-manager - - name: Add back Symfony (variant) for ProxyManager Composer bin dependencies - if: matrix.variant != 'no-change' - run: composer bin proxy-manager require --dev --no-update ${{ matrix.variant }} - - name: Install Symfony for ProxyManager Composer bin dependencies uses: ramsey/composer-install@v3 + if: "matrix.make-test == 'test_symfony_doctrine_bridge_proxy_manager' || matrix.make-test == 'test_symfony_eloquent_bridge_proxy_manager'" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "${{ matrix.composer-flags }}" @@ -186,12 +183,14 @@ jobs: - name: Install Symfony Composer bin dependencies uses: ramsey/composer-install@v3 + if: "matrix.make-test == 'test_symfony_bridge' || matrix.make-test == 'test_symfony_doctrine_bridge' || matrix.make-test == 'test_symfony_eloquent_bridge' || matrix.make-test == 'test_symfony_eloquent_bridge_proxy_manager' || matrix.make-test == 'test_symfony_doctrine_bridge_proxy_manager'" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "${{ matrix.composer-flags }}" working-directory: vendor-bin/symfony - name: Repeat "Install Symfony Composer bin dependencies" uses: ramsey/composer-install@v3 + if: "matrix.make-test == 'test_symfony_bridge' || matrix.make-test == 'test_symfony_doctrine_bridge' || matrix.make-test == 'test_symfony_eloquent_bridge' || matrix.make-test == 'test_symfony_eloquent_bridge_proxy_manager' || matrix.make-test == 'test_symfony_doctrine_bridge_proxy_manager'" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "${{ matrix.composer-flags }}" diff --git a/Makefile b/Makefile index f069c563..701b6f30 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ PHP_CS_FIXER=php -d zend.enable_gc=0 vendor-bin/php-cs-fixer/bin/php-cs-fixer -DOCKER_COMPOSE=docker-compose +DOCKER_COMPOSE=docker compose DOCKER_COMPOSE_EXEC=$(DOCKER_COMPOSE) exec --no-TTY ifeq ("$(CI)", "true") MYSQL_BIN=mysql --user=root --password=password --port=3307 MONGO_BIN=mongosh --username=root --password=password --port=27018 else -MYSQL_BIN=$(DOCKER_COMPOSE_EXEC) mysql mysql --user=root --password=password --port=3307 -MONGO_BIN=$(DOCKER_COMPOSE_EXEC) mongo mongosh --username=root --password=password --port=27017 +MYSQL_BIN=$(DOCKER_COMPOSE_EXEC) mysql mysql --user=root --password=password --host=host.docker.internal --port=3307 +MONGO_BIN=$(DOCKER_COMPOSE_EXEC) mongo mongosh --username=root --password=password --host=host.docker.internal --port=27018 endif .DEFAULT_GOAL := help @@ -114,7 +114,7 @@ test_doctrine_odm_bridge: vendor/bamarni \ .PHONY: test_doctrine_phpcr_bridge test_doctrine_phpcr_bridge: ## Run the tests for the Doctrine Mongodb PHPCR bridge test_doctrine_phpcr_bridge: vendor/bamarni \ - vendor-bin/doctrine_mongodb/vendor/phpunit + vendor-bin/doctrine_phpcr/vendor/phpunit $(MAKE) remove_sf_cache $(MAKE) refresh_phpcr diff --git a/README.md b/README.md index 700d1dee..76af589b 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ AliceDataFixtures Supports: -* Symfony 5.4+, 6.4+ -* Doctrine ORM 2.5+ +* Symfony 6.4+ +* Doctrine ORM 2.20+ * Doctrine ODM 2.0+ -* Doctrine PHPCR 1.4+ -* Eloquent 8.12+ +* Doctrine PHPCR 2.0+ +* Eloquent 11.0+ ## Documentation diff --git a/composer.json b/composer.json index df926001..997ef9bc 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } ], "require": { - "php": "^8.2", + "php": "^8.3", "nelmio/alice": "^3.10", "psr/log": "^1 || ^2 || ^3", "webmozart/assert": "^1.10" @@ -33,12 +33,18 @@ "symfony/phpunit-bridge": "^5.3.8 || ^6.4" }, "conflict": { - "doctrine/orm": "<2.6.3", + "doctrine/data-fixtures": "<1.7.0", + "doctrine/orm": "<2.20", + "doctrine/doctrine-bundle": "<2.11.0", + "doctrine/mongodb-odm-bundle": "<5.1.0", + "doctrine/mongodb-odm": "<2.6.0", + "doctrine/phpcr-bundle": "<3.0", + "doctrine/phpcr-odm": "<2.0.0", "doctrine/dbal": "<3.0", "doctrine/persistence": "<2.0", - "illuminate/database": "<8.12", + "illuminate/database": "<10.0", "ocramius/proxy-manager": "<2.1", - "symfony/framework-bundle": "<5.4 || >=6.0 <6.4", + "symfony/framework-bundle": ">=6.0 <6.4", "zendframework/zend-code": "<3.3.1" }, "suggest": { diff --git a/docker-compose.yml b/docker-compose.yml index d10dffed..440c6a89 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.1' - # To keep in sync with .gitHub/workflows/tests.yaml services: mysql: diff --git a/doctrine-phpcr-db-settings.php b/doctrine-phpcr-db-settings.php index 96103106..1e32f4fd 100644 --- a/doctrine-phpcr-db-settings.php +++ b/doctrine-phpcr-db-settings.php @@ -10,4 +10,5 @@ 'dbname' => get_param('DOCTRINE_PHPCR_DB_NAME', 'fidry_alice_data_fixtures'), 'host' => get_param('DOCTRINE_PHPCR_DB_HOST', '127.0.0.1'), 'port' => get_param('DOCTRINE_PHPCR_DB_PORT', 3307), + 'charset' => get_param('DOCTRINE_PHPCR_DB_CHARSET', 'UTF8'), ]; diff --git a/fixtures/Bridge/Doctrine/PhpCrDocument/Dummy.php b/fixtures/Bridge/Doctrine/PhpCrDocument/Dummy.php index b6a7c065..60171192 100644 --- a/fixtures/Bridge/Doctrine/PhpCrDocument/Dummy.php +++ b/fixtures/Bridge/Doctrine/PhpCrDocument/Dummy.php @@ -13,16 +13,12 @@ namespace Fidry\AliceDataFixtures\Bridge\Doctrine\PhpCrDocument; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Document; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Id; +use Doctrine\ODM\PHPCR\Mapping\Attributes\Document; +use Doctrine\ODM\PHPCR\Mapping\Attributes\Id; -/** - * @Document() - */ +#[Document] class Dummy { - /** - * @Id() - */ + #[Id] public $id; } diff --git a/fixtures/Bridge/Doctrine/PhpCrDocument/DummySubClass.php b/fixtures/Bridge/Doctrine/PhpCrDocument/DummySubClass.php index ca10ef0b..8768748b 100644 --- a/fixtures/Bridge/Doctrine/PhpCrDocument/DummySubClass.php +++ b/fixtures/Bridge/Doctrine/PhpCrDocument/DummySubClass.php @@ -13,11 +13,9 @@ namespace Fidry\AliceDataFixtures\Bridge\Doctrine\PhpCrDocument; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Document; +use Doctrine\ODM\PHPCR\Mapping\Attributes\Document; -/** - * @Document() - */ +#[Document] class DummySubClass extends MappedSuperclassDummy { } diff --git a/fixtures/Bridge/Doctrine/PhpCrDocument/MappedSuperclassDummy.php b/fixtures/Bridge/Doctrine/PhpCrDocument/MappedSuperclassDummy.php index 5e69e59a..9d193a6b 100644 --- a/fixtures/Bridge/Doctrine/PhpCrDocument/MappedSuperclassDummy.php +++ b/fixtures/Bridge/Doctrine/PhpCrDocument/MappedSuperclassDummy.php @@ -13,22 +13,16 @@ namespace Fidry\AliceDataFixtures\Bridge\Doctrine\PhpCrDocument; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Field; -use Doctrine\ODM\PHPCR\Mapping\Annotations\Id; -use Doctrine\ODM\PHPCR\Mapping\Annotations\MappedSuperclass; +use Doctrine\ODM\PHPCR\Mapping\Attributes\Field; +use Doctrine\ODM\PHPCR\Mapping\Attributes\Id; +use Doctrine\ODM\PHPCR\Mapping\Attributes\MappedSuperclass; -/** - * @MappedSuperclass() - */ +#[MappedSuperclass] class MappedSuperclassDummy { - /** - * @Id() - */ + #[Id] public $id; - /** - * @Field(type="string") - */ + #[Field(type: 'string')] public string $status; } diff --git a/fixtures/Bridge/Symfony/SymfonyApp/config/config.yml b/fixtures/Bridge/Symfony/SymfonyApp/config/config.yml index dd2f4544..a4b6c557 100644 --- a/fixtures/Bridge/Symfony/SymfonyApp/config/config.yml +++ b/fixtures/Bridge/Symfony/SymfonyApp/config/config.yml @@ -8,6 +8,10 @@ # framework: + http_method_override: false + handle_all_throwables: false + php_errors: + log: true secret: test router: resource: ~ @@ -16,6 +20,7 @@ framework: enabled: false validation: enabled: true + email_validation_mode: html5 session: enabled: false test: ~ diff --git a/fixtures/Bridge/Symfony/SymfonyApp/config/config_doctrine.yml b/fixtures/Bridge/Symfony/SymfonyApp/config/config_doctrine.yml index 920101b6..70aeeba9 100644 --- a/fixtures/Bridge/Symfony/SymfonyApp/config/config_doctrine.yml +++ b/fixtures/Bridge/Symfony/SymfonyApp/config/config_doctrine.yml @@ -24,6 +24,9 @@ doctrine: 1002: "SET NAMES 'UTF8' COLLATE 'utf8_unicode_ci'" orm: auto_mapping: true + controller_resolver: + auto_mapping: false + enable_lazy_ghost_objects: true mappings: fixture_entities: type: xml diff --git a/fixtures/Bridge/Symfony/SymfonyApp/config/config_symfony_3.yml b/fixtures/Bridge/Symfony/SymfonyApp/config/config_symfony_3.yml index 7b483c16..7ca0318c 100644 --- a/fixtures/Bridge/Symfony/SymfonyApp/config/config_symfony_3.yml +++ b/fixtures/Bridge/Symfony/SymfonyApp/config/config_symfony_3.yml @@ -8,6 +8,10 @@ # framework: + http_method_override: false + handle_all_throwables: false + php_errors: + log: true secret: test router: resource: ~ @@ -15,5 +19,6 @@ framework: enabled: false validation: enabled: true + email_validation_mode: html5 session: ~ test: ~ diff --git a/tests/Bridge/Doctrine/Purger/PurgerTest.php b/tests/Bridge/Doctrine/Purger/PurgerTest.php index 4a63a1be..482e6fc5 100644 --- a/tests/Bridge/Doctrine/Purger/PurgerTest.php +++ b/tests/Bridge/Doctrine/Purger/PurgerTest.php @@ -14,9 +14,13 @@ namespace Fidry\AliceDataFixtures\Bridge\Doctrine\Purger; use Doctrine\Common\DataFixtures\Purger\ORMPurger as DoctrineOrmPurger; +use Doctrine\Common\EventManager; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Platforms\MySqlPlatform; +use Doctrine\ORM\Configuration; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\Mapping\ClassMetadataFactory; +use Doctrine\Persistence\Mapping\Driver\MappingDriver; use Fidry\AliceDataFixtures\Bridge\Doctrine\ORM\FakeEntityManager; use Fidry\AliceDataFixtures\Persistence\PurgeMode; use Fidry\AliceDataFixtures\Persistence\PurgerFactoryInterface; @@ -66,24 +70,38 @@ public function testCreatesADoctrineOrmPurgerWithTheAppropriateManagerAndPurgeMo public function testDisableFKChecksOnDeleteIsPerformed(): void { + $mappingDriverProphecy = $this->prophesize(MappingDriver::class); + $mappingDriverProphecy->getAllClassNames()->willReturn([]); + + $configuration = new Configuration(); + $configuration->setMetadataDriverImpl($mappingDriverProphecy->reveal()); + $connection = $this->prophesize(Connection::class); + $connection->getConfiguration()->willReturn($configuration); $connection->getDatabasePlatform()->willReturn($this->prophesize(MySqlPlatform::class)->reveal()); - $connection->exec('SET FOREIGN_KEY_CHECKS = 0;')->shouldBeCalled(); - $connection->exec('SET FOREIGN_KEY_CHECKS = 1;')->shouldBeCalled(); + $connection->executeStatement('SET FOREIGN_KEY_CHECKS = 0;')->shouldBeCalled(); + $connection->executeStatement('SET FOREIGN_KEY_CHECKS = 1;')->shouldBeCalled(); + + $classMetadataFactory = new ClassMetadataFactory(); $manager = $this->prophesize(EntityManager::class); + $manager->getConfiguration()->willReturn($configuration); $manager->getConnection()->willReturn($connection->reveal()); + $manager->getEventManager()->willReturn(new EventManager()); + $manager->getMetadataFactory()->willReturn($classMetadataFactory); + + $classMetadataFactory->setEntityManager($manager->reveal()); - $purgerORM = $this->prophesize(DoctrineOrmPurger::class); - $purgerORM->getObjectManager()->willReturn($manager->reveal()); - $purgerORM->purge()->shouldBeCalled(); + $purgerORM = new DoctrineOrmPurger( + $manager->reveal(), + ); $purgeMode = PurgeMode::createDeleteMode(); $purger = new Purger($manager->reveal(), $purgeMode); $decoratedPurgerReflection = (new ReflectionObject($purger))->getProperty('purger'); $decoratedPurgerReflection->setAccessible(true); - $decoratedPurgerReflection->setValue($purger, $purgerORM->reveal()); + $decoratedPurgerReflection->setValue($purger, $purgerORM); $purger->purge(); } diff --git a/tests/Bridge/DoctrinePhpCr/autoload.php b/tests/Bridge/DoctrinePhpCr/autoload.php index 97bfa542..dd29e9d8 100644 --- a/tests/Bridge/DoctrinePhpCr/autoload.php +++ b/tests/Bridge/DoctrinePhpCr/autoload.php @@ -15,11 +15,10 @@ $autoload = ROOT.'/vendor-bin/doctrine_phpcr/vendor/autoload.php'; -use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\DBAL\DriverManager; use Doctrine\ODM\PHPCR\Configuration; use Doctrine\ODM\PHPCR\DocumentManager; -use Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver; +use Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver; use Jackalope\RepositoryFactoryDoctrineDBAL; use PHPCR\SessionInterface; use PHPCR\SimpleCredentials; @@ -42,8 +41,7 @@ })(); $config = (static function (): Configuration { - $driver = new AnnotationDriver( - new AnnotationReader(), + $driver = new AttributeDriver( [ ROOT.'/vendor-bin/doctrine_phpcr/vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Document', ROOT.'/fixtures/Bridge/Doctrine/PhpCrDocument', diff --git a/tests/Bridge/Symfony/Doctrine/PhpcrLoaderIntegrationTest.php b/tests/Bridge/Symfony/Doctrine/PhpcrLoaderIntegrationTest.php index f7d4b900..7fabf320 100644 --- a/tests/Bridge/Symfony/Doctrine/PhpcrLoaderIntegrationTest.php +++ b/tests/Bridge/Symfony/Doctrine/PhpcrLoaderIntegrationTest.php @@ -46,14 +46,6 @@ public static function setUpBeforeClass(): void public function setUp(): void { - if (PHP_VERSION_ID < 80000) { - $this->markTestSkipped('The annotation reader is not available: the "enable_annotations" on the validator cannot be set as the PHP version is lower than 8'); - } - - if (PHP_VERSION_ID >= 80000) { - $this->markTestSkipped('Not compatible yet with PHP 8.0'); - } - $this->kernel = new DoctrinePhpcrKernel(static::$seed, true); $this->kernel->boot(); diff --git a/vendor-bin/eloquent/composer.json b/vendor-bin/eloquent/composer.json index 6022ef67..8281e88f 100644 --- a/vendor-bin/eloquent/composer.json +++ b/vendor-bin/eloquent/composer.json @@ -7,6 +7,7 @@ "require-dev": { "illuminate/database": ">=8.80", "illuminate/filesystem": ">=8.80", + "laravel/serializable-closure": "^1.3", "theofidry/composer-inheritance-plugin": "^1.2" }, "config": { diff --git a/vendor-bin/proxy-manager/composer.json b/vendor-bin/proxy-manager/composer.json index e74bf6fd..a4e16882 100644 --- a/vendor-bin/proxy-manager/composer.json +++ b/vendor-bin/proxy-manager/composer.json @@ -16,8 +16,8 @@ "doctrine/phpcr-odm": "*", "jackalope/jackalope-doctrine-dbal": "*", "friendsofphp/proxy-manager-lts": "*", - "monolog/monolog": "*", - "symfony/symfony": "^5.4 || ^6.4", + "monolog/monolog": ">=2.0", + "symfony/symfony": "^6.4.14", "theofidry/composer-inheritance-plugin": "^1.2", "wouterj/eloquent-bundle": "*" }, diff --git a/vendor-bin/symfony/composer.json b/vendor-bin/symfony/composer.json index 5757001b..e212dcfe 100644 --- a/vendor-bin/symfony/composer.json +++ b/vendor-bin/symfony/composer.json @@ -5,21 +5,20 @@ ] }, "require": { - "symfony/doctrine-messenger": "^4.4 || ^5.4 || ^6.0" + "symfony/doctrine-messenger": "^4.4 || ^5.4 || ^6.4" }, "require-dev": { "alcaeus/mongo-php-adapter": "*", "doctrine/annotations": "*", "doctrine/data-fixtures": "*", "doctrine/doctrine-bundle": "*", - "doctrine/mongodb-odm": "*", "doctrine/mongodb-odm-bundle": "*", "doctrine/orm": "*", "doctrine/phpcr-bundle": "*", "doctrine/phpcr-odm": "*", "jackalope/jackalope-doctrine-dbal": "*", - "monolog/monolog": "*", - "symfony/symfony": "^5.4 || ^6.4", + "monolog/monolog": ">=2.0", + "symfony/symfony": "^6.4.14", "theofidry/composer-inheritance-plugin": "^1.2", "wouterj/eloquent-bundle": "*" },