Skip to content

Commit

Permalink
Add compatibility with doctrine/orm 3
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed May 29, 2024
1 parent 9f3c43a commit 93f8eef
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"require-dev": {
"doctrine/doctrine-bundle": "^2.1.1",
"doctrine/mongodb-odm": "^2.2",
"doctrine/orm": "^2.8",
"doctrine/orm": "^2.8 || ^3.2",
"doctrine/phpcr-odm": "^1.5.3 || ^2.0",
"ergebnis/composer-normalize": "^2.28",
"jackalope/jackalope-doctrine-dbal": "^1.2 || ^2.0",
Expand Down
6 changes: 5 additions & 1 deletion src/Doctrine/RegisterListenersService.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ public function register(ObjectManager $manager, PagerInterface $pager, array $o
});
}

if (false === $options['debug_logging'] && $manager instanceof EntityManagerInterface) {
if (
false === $options['debug_logging']
&& interface_exists('Doctrine\DBAL\Logging\SQLLogger')
&& $manager instanceof EntityManagerInterface
) {
$configuration = $manager->getConnection()->getConfiguration();
$logger = $configuration->getSQLLogger();

Check failure on line 58 in src/Doctrine/RegisterListenersService.php

View workflow job for this annotation

GitHub Actions / PHPStan (PHP 8.3, Symfony 6.4.* + highest deps)

Call to an undefined method Doctrine\DBAL\Configuration::getSQLLogger().

Check failure on line 58 in src/Doctrine/RegisterListenersService.php

View workflow job for this annotation

GitHub Actions / PHPStan (PHP 8.1, Symfony 5.4.* + highest deps)

Call to an undefined method Doctrine\DBAL\Configuration::getSQLLogger().

Check failure on line 58 in src/Doctrine/RegisterListenersService.php

View workflow job for this annotation

GitHub Actions / PHPStan (PHP 8.3, Symfony 5.4.* + highest deps)

Call to an undefined method Doctrine\DBAL\Configuration::getSQLLogger().

Check failure on line 58 in src/Doctrine/RegisterListenersService.php

View workflow job for this annotation

GitHub Actions / PHPStan (PHP 8.1, Symfony 6.4.* + highest deps)

Call to an undefined method Doctrine\DBAL\Configuration::getSQLLogger().

Check failure on line 58 in src/Doctrine/RegisterListenersService.php

View workflow job for this annotation

GitHub Actions / PHPStan (PHP 8.2, Symfony 7.0.* + highest deps)

Call to an undefined method Doctrine\DBAL\Configuration::getSQLLogger().

Check failure on line 58 in src/Doctrine/RegisterListenersService.php

View workflow job for this annotation

GitHub Actions / PHPStan (PHP 8.2, Symfony 6.4.* + highest deps)

Call to an undefined method Doctrine\DBAL\Configuration::getSQLLogger().

Check failure on line 58 in src/Doctrine/RegisterListenersService.php

View workflow job for this annotation

GitHub Actions / PHPStan (PHP 8.2, Symfony 5.4.* + highest deps)

Call to an undefined method Doctrine\DBAL\Configuration::getSQLLogger().

Check failure on line 58 in src/Doctrine/RegisterListenersService.php

View workflow job for this annotation

GitHub Actions / PHPStan (PHP 8.3, Symfony 7.0.* + highest deps)

Call to an undefined method Doctrine\DBAL\Configuration::getSQLLogger().

Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Doctrine/ORM/ElasticaToModelTransformerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace FOS\ElasticaBundle\Tests\Unit\Doctrine\ORM;

use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\Query;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
Expand Down Expand Up @@ -132,7 +133,7 @@ public function testTransformUsesDefaultQueryBuilderMethodConfiguration()
*/
public function testUsesHintsConfigurationIfGiven()
{
$query = $this->getMockBuilder(AbstractQuery::class)
$query = $this->getMockBuilder(Query::class)
->setMethods(['setHint', 'execute', 'setHydrationMode'])
->disableOriginalConstructor()
->getMockForAbstractClass()
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Doctrine/ORM/ListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function getClassMetadataClass()

protected function getLifecycleEventArgsClass()
{
return \Doctrine\ORM\Event\LifecycleEventArgs::class;
return \Doctrine\Persistence\Event\LifecycleEventArgs::class;
}

protected function getListenerClass()
Expand Down
4 changes: 4 additions & 0 deletions tests/Unit/Doctrine/RegisterListenersServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ public function testShouldNotCallSleepListenerForAnotherPagers()

public function testShouldRegisterDisableDebugLoggingByDefaultForEntityManager()
{
if (!interface_exists('Doctrine\DBAL\Logging\SQLLogger')) {
$this->markTestSkipped('This is only possible on doctrine/orm 2.');
}

$dispatcher = $this->createDispatcherMock();
$dispatcher->expects($this->exactly(2))
->method('addListener')
Expand Down

0 comments on commit 93f8eef

Please sign in to comment.