diff --git a/composer.json b/composer.json index 9ac6b40..198c784 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "require": { "php": ">=8.1", - "doctrine/orm": "~2.7", + "doctrine/orm": "~2.18 | ~3.0", "psr/log": "^1.0|^2.0|^3.0", "wmde/email-address": "~1.0", diff --git a/src/DataAccess/DoctrineSubscriptionRepository.php b/src/DataAccess/DoctrineSubscriptionRepository.php index a5960e4..44653d6 100644 --- a/src/DataAccess/DoctrineSubscriptionRepository.php +++ b/src/DataAccess/DoctrineSubscriptionRepository.php @@ -6,7 +6,7 @@ use Doctrine\DBAL\Types\Types; use Doctrine\ORM\EntityManager; -use Doctrine\ORM\ORMException; +use Doctrine\ORM\Exception\ORMException; use WMDE\Fundraising\SubscriptionContext\Domain\Model\Subscription; use WMDE\Fundraising\SubscriptionContext\Domain\Repositories\SubscriptionRepository; use WMDE\Fundraising\SubscriptionContext\Domain\Repositories\SubscriptionRepositoryException; diff --git a/src/Domain/Repositories/SubscriptionRepositoryException.php b/src/Domain/Repositories/SubscriptionRepositoryException.php index 7033498..e01c3d6 100644 --- a/src/Domain/Repositories/SubscriptionRepositoryException.php +++ b/src/Domain/Repositories/SubscriptionRepositoryException.php @@ -10,7 +10,7 @@ */ class SubscriptionRepositoryException extends \RuntimeException { - public function __construct( string $message, \Exception $previous = null ) { + public function __construct( string $message, \Throwable $previous = null ) { parent::__construct( $message, 0, $previous ); } diff --git a/tests/Integration/DataAccess/DoctrineSubscriptionRepositoryTest.php b/tests/Integration/DataAccess/DoctrineSubscriptionRepositoryTest.php index f69bfc5..29e7943 100644 --- a/tests/Integration/DataAccess/DoctrineSubscriptionRepositoryTest.php +++ b/tests/Integration/DataAccess/DoctrineSubscriptionRepositoryTest.php @@ -5,9 +5,10 @@ namespace WMDE\Fundraising\SubscriptionContext\Tests\Integration\DataAccess; use Doctrine\ORM\EntityManager; -use Doctrine\ORM\ORMException; +use Doctrine\ORM\Exception\ORMException; use Doctrine\Persistence\ObjectRepository; use PHPUnit\Framework\TestCase; +use RuntimeException; use WMDE\Fundraising\SubscriptionContext\DataAccess\DoctrineSubscriptionRepository; use WMDE\Fundraising\SubscriptionContext\Domain\Model\Subscription; use WMDE\Fundraising\SubscriptionContext\Domain\Repositories\SubscriptionRepositoryException; @@ -62,7 +63,10 @@ public function testMultipleSubscriptions_onlySimilarAreCounted(): void { public function testDatabaseLayerExceptionsAreConvertedToDomainExceptions(): void { $entityManager = $this->createMock( EntityManager::class ); - $entityManager->expects( $this->once() )->method( 'persist' )->willThrowException( new ORMException() ); + $entityManager->expects( $this->once() )->method( 'persist' )->willThrowException( + new class() extends RuntimeException implements ORMException { + } + ); $repository = new DoctrineSubscriptionRepository( $entityManager ); $subscription = new Subscription(); $subscription->setEmail( 'nyan@awesomecats.com' );