Skip to content

Commit

Permalink
Merge pull request #11676 from derrabus/chore/phpunit-deprecations
Browse files Browse the repository at this point in the history
Fix PHPUnit deprecations
  • Loading branch information
greg0ire authored Oct 14, 2024
2 parents ef4508e + 32682aa commit 013f850
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 77 deletions.
12 changes: 6 additions & 6 deletions tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function testBuildCachedEntityPersisterReadOnly(): void
$this->factory->expects(self::once())
->method('getRegion')
->with(self::equalTo($metadata->cache))
->will(self::returnValue($region));
->willReturn($region);

$cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata);

Expand All @@ -97,7 +97,7 @@ public function testBuildCachedEntityPersisterReadWrite(): void
$this->factory->expects(self::once())
->method('getRegion')
->with(self::equalTo($metadata->cache))
->will(self::returnValue($region));
->willReturn($region);

$cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata);

Expand All @@ -117,7 +117,7 @@ public function testBuildCachedEntityPersisterNonStrictReadWrite(): void
$this->factory->expects(self::once())
->method('getRegion')
->with(self::equalTo($metadata->cache))
->will(self::returnValue($region));
->willReturn($region);

$cachedPersister = $this->factory->buildCachedEntityPersister($em, $persister, $metadata);

Expand All @@ -138,7 +138,7 @@ public function testBuildCachedCollectionPersisterReadOnly(): void
$this->factory->expects(self::once())
->method('getRegion')
->with(self::equalTo($mapping['cache']))
->will(self::returnValue($region));
->willReturn($region);

$cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping);

Expand All @@ -159,7 +159,7 @@ public function testBuildCachedCollectionPersisterReadWrite(): void
$this->factory->expects(self::once())
->method('getRegion')
->with(self::equalTo($mapping['cache']))
->will(self::returnValue($region));
->willReturn($region);

$cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping);

Expand All @@ -180,7 +180,7 @@ public function testBuildCachedCollectionPersisterNonStrictReadWrite(): void
$this->factory->expects(self::once())
->method('getRegion')
->with(self::equalTo($mapping['cache']))
->will(self::returnValue($region));
->willReturn($region);

$cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function testDeleteLockFailureShouldIgnoreQueue(): void
$this->region->expects(self::once())
->method('lock')
->with(self::equalTo($key))
->will(self::returnValue(null));
->willReturn(null);

$this->collectionPersister->expects(self::once())
->method('delete')
Expand All @@ -278,7 +278,7 @@ public function testUpdateLockFailureShouldIgnoreQueue(): void
$this->region->expects(self::once())
->method('lock')
->with(self::equalTo($key))
->will(self::returnValue(null));
->willReturn(null);

$this->collectionPersister->expects(self::once())
->method('update')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testInsertTransactionCommitShouldPutCache(): void

$this->entityPersister->expects(self::once())
->method('getInserts')
->will(self::returnValue([$entity]));
->willReturn([$entity]);

$this->entityPersister->expects(self::once())
->method('executeInserts');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testDeleteShouldLockItem(): void
$this->region->expects(self::once())
->method('lock')
->with(self::equalTo($key))
->will(self::returnValue($lock));
->willReturn($lock);

$this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']);

Expand All @@ -56,7 +56,7 @@ public function testUpdateShouldLockItem(): void
$this->region->expects(self::once())
->method('lock')
->with(self::equalTo($key))
->will(self::returnValue($lock));
->willReturn($lock);

$this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']);

Expand All @@ -73,12 +73,12 @@ public function testUpdateTransactionRollBackShouldEvictItem(): void
$this->region->expects(self::once())
->method('lock')
->with(self::equalTo($key))
->will(self::returnValue($lock));
->willReturn($lock);

$this->region->expects(self::once())
->method('evict')
->with(self::equalTo($key))
->will(self::returnValue($lock));
->willReturn($lock);

$this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']);

Expand All @@ -96,7 +96,7 @@ public function testDeleteTransactionRollBackShouldEvictItem(): void
$this->region->expects(self::once())
->method('lock')
->with(self::equalTo($key))
->will(self::returnValue($lock));
->willReturn($lock);

$this->region->expects(self::once())
->method('evict')
Expand All @@ -121,7 +121,7 @@ public function testTransactionRollBackShouldClearQueue(): void
$this->region->expects(self::exactly(2))
->method('lock')
->with(self::equalTo($key))
->will(self::returnValue($lock));
->willReturn($lock);

$this->region->expects(self::exactly(2))
->method('evict')
Expand Down Expand Up @@ -152,7 +152,7 @@ public function testTransactionCommitShouldClearQueue(): void
$this->region->expects(self::exactly(2))
->method('lock')
->with(self::equalTo($key))
->will(self::returnValue($lock));
->willReturn($lock);

$this->region->expects(self::exactly(2))
->method('evict')
Expand Down Expand Up @@ -182,7 +182,7 @@ public function testDeleteLockFailureShouldIgnoreQueue(): void
$this->region->expects(self::once())
->method('lock')
->with(self::equalTo($key))
->will(self::returnValue(null));
->willReturn(null);

$this->entityPersister->expects(self::once())
->method('delete')
Expand All @@ -206,7 +206,7 @@ public function testUpdateLockFailureShouldIgnoreQueue(): void
$this->region->expects(self::once())
->method('lock')
->with(self::equalTo($key))
->will(self::returnValue(null));
->willReturn(null);

$this->entityPersister->expects(self::once())
->method('update')
Expand Down
27 changes: 9 additions & 18 deletions tests/Tests/ORM/Functional/PostLoadEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public function testLoadedEntityUsingFindShouldTriggerEvent(): void
// CmsUser and CmsAddres, because it's a ToOne inverse side on CmsUser
$mockListener
->expects(self::exactly(2))
->method('postLoad')
->will(self::returnValue(true));
->method('postLoad');

$eventManager = $this->_em->getEventManager();

Expand All @@ -52,8 +51,7 @@ public function testLoadedEntityUsingQueryShouldTriggerEvent(): void
// CmsUser and CmsAddres, because it's a ToOne inverse side on CmsUser
$mockListener
->expects(self::exactly(2))
->method('postLoad')
->will(self::returnValue(true));
->method('postLoad');

$eventManager = $this->_em->getEventManager();

Expand All @@ -72,8 +70,7 @@ public function testLoadedAssociationToOneShouldTriggerEvent(): void
// CmsUser (root), CmsAddress (ToOne inverse side), CmsEmail (joined association)
$mockListener
->expects(self::exactly(3))
->method('postLoad')
->will(self::returnValue(true));
->method('postLoad');

$eventManager = $this->_em->getEventManager();

Expand All @@ -92,8 +89,7 @@ public function testLoadedAssociationToManyShouldTriggerEvent(): void
// CmsUser (root), CmsAddress (ToOne inverse side), 2 CmsPhonenumber (joined association)
$mockListener
->expects(self::exactly(4))
->method('postLoad')
->will(self::returnValue(true));
->method('postLoad');

$eventManager = $this->_em->getEventManager();

Expand All @@ -114,8 +110,7 @@ public function testLoadedProxyEntityShouldTriggerEvent(): void

$mockListener
->expects(self::never())
->method('postLoad')
->will(self::returnValue(true));
->method('postLoad');

$eventManager->addEventListener([Events::postLoad], $mockListener);

Expand All @@ -128,8 +123,7 @@ public function testLoadedProxyEntityShouldTriggerEvent(): void

$mockListener2
->expects(self::exactly(2))
->method('postLoad')
->will(self::returnValue(true));
->method('postLoad');

$eventManager->addEventListener([Events::postLoad], $mockListener2);

Expand All @@ -146,8 +140,7 @@ public function testLoadedProxyPartialShouldTriggerEvent(): void
// CmsUser (partially loaded), CmsAddress (inverse ToOne), 2 CmsPhonenumber
$mockListener
->expects(self::exactly(4))
->method('postLoad')
->will(self::returnValue(true));
->method('postLoad');

$eventManager->addEventListener([Events::postLoad], $mockListener);

Expand All @@ -166,8 +159,7 @@ public function testLoadedProxyAssociationToOneShouldTriggerEvent(): void
// CmsEmail (proxy)
$mockListener
->expects(self::exactly(1))
->method('postLoad')
->will(self::returnValue(true));
->method('postLoad');

$eventManager = $this->_em->getEventManager();

Expand All @@ -187,8 +179,7 @@ public function testLoadedProxyAssociationToManyShouldTriggerEvent(): void
// 2 CmsPhonenumber (proxy)
$mockListener
->expects(self::exactly(2))
->method('postLoad')
->will(self::returnValue(true));
->method('postLoad');

$eventManager = $this->_em->getEventManager();

Expand Down
18 changes: 9 additions & 9 deletions tests/Tests/ORM/Functional/SQLFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ private function addMockFilterCollection(EntityManagerInterface $em): FilterColl

$em->expects(self::any())
->method('getFilters')
->will(self::returnValue($filterCollection));
->willReturn($filterCollection);

return $filterCollection;
}
Expand All @@ -267,12 +267,12 @@ public function testSQLFilterGetSetParameter(): void
$conn->expects(self::once())
->method('quote')
->with(self::equalTo('en'))
->will(self::returnValue("'en'"));
->willReturn("'en'");

$em = $this->getMockEntityManager();
$em->expects(self::once())
->method('getConnection')
->will(self::returnValue($conn));
->willReturn($conn);

$filterCollection = $this->addMockFilterCollection($em);
$filterCollection
Expand All @@ -298,7 +298,7 @@ public function testSQLFilterGetConnection(): void
$em = $this->getMockEntityManager();
$em->expects(self::once())
->method('getConnection')
->will(self::returnValue($conn));
->willReturn($conn);

$filter = new MyLocaleFilter($em);

Expand All @@ -315,12 +315,12 @@ public function testSQLFilterSetParameterInfersType(): void
$conn->expects(self::once())
->method('quote')
->with(self::equalTo('en'))
->will(self::returnValue("'en'"));
->willReturn("'en'");

$em = $this->getMockEntityManager();
$em->expects(self::once())
->method('getConnection')
->will(self::returnValue($conn));
->willReturn($conn);

$filterCollection = $this->addMockFilterCollection($em);
$filterCollection
Expand All @@ -339,13 +339,13 @@ public function testSQLFilterSetArrayParameterInfersType(): void
// Setup mock connection
$conn = $this->getMockConnection();
$conn->method('quote')
->will(self::returnCallback(static function ($value) {
->willReturnCallback(static function ($value) {
return "'" . $value . "'";
}));
});

$em = $this->getMockEntityManager();
$em->method('getConnection')
->will(self::returnValue($conn));
->willReturn($conn);

$filterCollection = $this->addMockFilterCollection($em);
$filterCollection
Expand Down
10 changes: 5 additions & 5 deletions tests/Tests/ORM/Functional/Ticket/DDC2359Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public function testIssue(): void

$configuration
->method('getMetadataDriverImpl')
->will(self::returnValue($mockDriver));
->willReturn($mockDriver);

$entityManager->expects(self::any())->method('getConfiguration')->will(self::returnValue($configuration));
$entityManager->expects(self::any())->method('getConnection')->will(self::returnValue($connection));
$entityManager->expects(self::any())->method('getConfiguration')->willReturn($configuration);
$entityManager->expects(self::any())->method('getConnection')->willReturn($connection);
$entityManager
->method('getEventManager')
->will(self::returnValue($this->createMock(EventManager::class)));
->willReturn($this->createMock(EventManager::class));

$metadataFactory->method('newClassMetadataInstance')->will(self::returnValue($mockMetadata));
$metadataFactory->method('newClassMetadataInstance')->willReturn($mockMetadata);
$metadataFactory->expects(self::once())->method('wakeupReflection');

$metadataFactory->setEntityManager($entityManager);
Expand Down
4 changes: 2 additions & 2 deletions tests/Tests/ORM/Hydration/ObjectHydratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ public function testCreatesProxyForLazyLoadingWithForeignKeys(): void
$proxyFactory->expects(self::once())
->method('getProxy')
->with(self::equalTo(ECommerceShipping::class), ['id' => 42])
->will(self::returnValue($proxyInstance));
->willReturn($proxyInstance);

$this->entityManager->setProxyFactory($proxyFactory);

Expand Down Expand Up @@ -1084,7 +1084,7 @@ public function testCreatesProxyForLazyLoadingWithForeignKeysWithAliasedProductE
$proxyFactory->expects(self::once())
->method('getProxy')
->with(self::equalTo(ECommerceShipping::class), ['id' => 42])
->will(self::returnValue($proxyInstance));
->willReturn($proxyInstance);

$this->entityManager->setProxyFactory($proxyFactory);

Expand Down
8 changes: 4 additions & 4 deletions tests/Tests/ORM/Internal/HydrationCompleteHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testDefersPostLoadOfEntity(int $listenersFlag): void
->expects(self::any())
->method('getSubscribedSystems')
->with($metadata)
->will(self::returnValue($listenersFlag));
->willReturn($listenersFlag);

$this->handler->deferPostLoadInvoking($metadata, $entity);

Expand Down Expand Up @@ -86,7 +86,7 @@ public function testDefersPostLoadOfEntityOnlyOnce(int $listenersFlag): void
->expects(self::any())
->method('getSubscribedSystems')
->with($metadata)
->will(self::returnValue($listenersFlag));
->willReturn($listenersFlag);

$this->handler->deferPostLoadInvoking($metadata, $entity);

Expand All @@ -110,7 +110,7 @@ public function testDefersMultiplePostLoadOfEntity(int $listenersFlag): void
->expects(self::any())
->method('getSubscribedSystems')
->with(self::logicalOr($metadata1, $metadata2))
->will(self::returnValue($listenersFlag));
->willReturn($listenersFlag);

$this->handler->deferPostLoadInvoking($metadata1, $entity1);
$this->handler->deferPostLoadInvoking($metadata2, $entity2);
Expand Down Expand Up @@ -144,7 +144,7 @@ public function testSkipsDeferredPostLoadOfMetadataWithNoInvokedListeners(): voi
->expects(self::any())
->method('getSubscribedSystems')
->with($metadata)
->will(self::returnValue(ListenersInvoker::INVOKE_NONE));
->willReturn(ListenersInvoker::INVOKE_NONE);

$this->handler->deferPostLoadInvoking($metadata, $entity);

Expand Down
Loading

0 comments on commit 013f850

Please sign in to comment.