diff --git a/composer.json b/composer.json index 5b6d7c4..cfd8240 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "php": ">= 8.2", "algolia/algoliasearch-client-php": "^3.0", "doctrine/event-manager": "^1.1 || ^2.0", - "doctrine/persistence": "^2.1 || ^3.0", + "doctrine/persistence": "^2.1 || ^3.0 || ^4.0", "symfony/filesystem": "^7.0", "symfony/property-access": "^7.0", "symfony/serializer": "^7.0" @@ -34,7 +34,7 @@ "require-dev": { "ext-json": "*", "doctrine/doctrine-bundle": "^2.12", - "doctrine/orm": "^2.5", + "doctrine/orm": "^2.5 || ^3.0", "friendsofphp/php-cs-fixer": "^v3.54.0", "jms/serializer-bundle": "^5.4.0", "friendsofphp/proxy-manager-lts": "*", diff --git a/src/Command/SearchImportCommand.php b/src/Command/SearchImportCommand.php index 3b9bcb4..7930170 100644 --- a/src/Command/SearchImportCommand.php +++ b/src/Command/SearchImportCommand.php @@ -37,7 +37,7 @@ public function __construct( SearchService $searchService, SearchService $searchServiceForAtomicReindex, ManagerRegistry $managerRegistry, - SearchClient $searchClient + SearchClient $searchClient, ) { parent::__construct($searchService); diff --git a/tests/TestCase/CommandsTest.php b/tests/TestCase/CommandsTest.php index 44d27c2..8a2ee11 100644 --- a/tests/TestCase/CommandsTest.php +++ b/tests/TestCase/CommandsTest.php @@ -86,6 +86,17 @@ public function testSearchClear(): void $this->cleanUp(); } + private function polyfillExecuteStatement(string $statement, array $params = []): void + { + if (method_exists($this->connection, 'executeStatement')) { + // doctrine/orm ^3.0 + $this->connection->executeStatement($statement, $params); + } else { + // doctrine/orm ^2.5 + $this->connection->executeUpdate($statement, $params); + } + } + public function testSearchImportAggregator(): void { for ($i = 1; $i <= 2; $i++) { @@ -120,7 +131,7 @@ public function testSearchImportAggregator(): void $searchPost = $this->searchService->rawSearch(ContentAggregator::class); self::assertCount($expectedResult, $searchPost['hits']); // clearup table - $this->connection->executeUpdate($this->platform->getTruncateTableSQL($this->indexName, true)); + $this->polyfillExecuteStatement($this->platform->getTruncateTableSQL($this->indexName, true)); $this->cleanUp(); } @@ -169,7 +180,7 @@ public function testSearchImport($isAtomic): void self::assertCount($expectedResult, $searchPost['hits']); // clearup table - $this->connection->executeUpdate($this->platform->getTruncateTableSQL($this->indexName, true)); + $this->polyfillExecuteStatement($this->platform->getTruncateTableSQL($this->indexName, true)); $this->cleanUp(); }