diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 390bdb5afc2..e0e880ef39f 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -24,4 +24,4 @@ on: jobs: coding-standards: - uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.1.0" + uses: "doctrine/.github/.github/workflows/coding-standards.yml@5.2.0" diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index e9b2c71857d..bf2ba69d770 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -17,4 +17,4 @@ on: jobs: documentation: name: "Documentation" - uses: "doctrine/.github/.github/workflows/documentation.yml@5.1.0" + uses: "doctrine/.github/.github/workflows/documentation.yml@5.2.0" diff --git a/.github/workflows/release-on-milestone-closed.yml b/.github/workflows/release-on-milestone-closed.yml index d54a784ebe5..f8bd8bce82e 100644 --- a/.github/workflows/release-on-milestone-closed.yml +++ b/.github/workflows/release-on-milestone-closed.yml @@ -7,7 +7,7 @@ on: jobs: release: - uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@5.1.0" + uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@5.2.0" secrets: GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }} GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }} diff --git a/README.md b/README.md index 1df322cf7e8..daef3b0c0e7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -| [4.0.x][4.0] | [3.3.x][3.3] | [3.2.x][3.2] | [2.20.x][2.20] | [2.19.x][2.19] | +| [4.0.x][4.0] | [3.4.x][3.4] | [3.3.x][3.3] | [2.21.x][2.21] | [2.20.x][2.20] | |:------------------------------------------------------:|:------------------------------------------------------:|:------------------------------------------------------:|:--------------------------------------------------------:|:--------------------------------------------------------:| -| [![Build status][4.0 image]][4.0] | [![Build status][3.3 image]][3.3] | [![Build status][3.2 image]][3.2] | [![Build status][2.20 image]][2.20] | [![Build status][2.19 image]][2.19] | -| [![Coverage Status][4.0 coverage image]][4.0 coverage] | [![Coverage Status][3.3 coverage image]][3.3 coverage] | [![Coverage Status][3.2 coverage image]][3.2 coverage] | [![Coverage Status][2.20 coverage image]][2.20 coverage] | [![Coverage Status][2.19 coverage image]][2.19 coverage] | +| [![Build status][4.0 image]][4.0] | [![Build status][3.4 image]][3.4] | [![Build status][3.3 image]][3.3] | [![Build status][2.21 image]][2.21] | [![Build status][2.20 image]][2.20] | +| [![Coverage Status][4.0 coverage image]][4.0 coverage] | [![Coverage Status][3.4 coverage image]][3.4 coverage] | [![Coverage Status][3.3 coverage image]][3.3 coverage] | [![Coverage Status][2.21 coverage image]][2.21 coverage] | [![Coverage Status][2.20 coverage image]][2.20 coverage] | [

πŸ‡ΊπŸ‡¦ UKRAINE NEEDS YOUR HELP NOW!

](https://www.doctrine-project.org/stop-war.html) @@ -22,19 +22,19 @@ without requiring unnecessary code duplication. [4.0]: https://github.com/doctrine/orm/tree/4.0.x [4.0 coverage image]: https://codecov.io/gh/doctrine/orm/branch/4.0.x/graph/badge.svg [4.0 coverage]: https://codecov.io/gh/doctrine/orm/branch/4.0.x + [3.4 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=3.4.x + [3.4]: https://github.com/doctrine/orm/tree/3.4.x + [3.4 coverage image]: https://codecov.io/gh/doctrine/orm/branch/3.4.x/graph/badge.svg + [3.4 coverage]: https://codecov.io/gh/doctrine/orm/branch/3.4.x [3.3 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=3.3.x [3.3]: https://github.com/doctrine/orm/tree/3.3.x [3.3 coverage image]: https://codecov.io/gh/doctrine/orm/branch/3.3.x/graph/badge.svg [3.3 coverage]: https://codecov.io/gh/doctrine/orm/branch/3.3.x - [3.2 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=3.2.x - [3.2]: https://github.com/doctrine/orm/tree/3.2.x - [3.2 coverage image]: https://codecov.io/gh/doctrine/orm/branch/3.2.x/graph/badge.svg - [3.2 coverage]: https://codecov.io/gh/doctrine/orm/branch/3.2.x + [2.21 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.21.x + [2.21]: https://github.com/doctrine/orm/tree/2.21.x + [2.21 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.21.x/graph/badge.svg + [2.21 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.21.x [2.20 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.20.x [2.20]: https://github.com/doctrine/orm/tree/2.20.x [2.20 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.20.x/graph/badge.svg [2.20 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.20.x - [2.19 image]: https://github.com/doctrine/orm/actions/workflows/continuous-integration.yml/badge.svg?branch=2.19.x - [2.19]: https://github.com/doctrine/orm/tree/2.19.x - [2.19 coverage image]: https://codecov.io/gh/doctrine/orm/branch/2.19.x/graph/badge.svg - [2.19 coverage]: https://codecov.io/gh/doctrine/orm/branch/2.19.x diff --git a/composer.json b/composer.json index 1d7a00b818e..ec2ff1fd5a7 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "psr/log": "^1 || ^2 || ^3", "squizlabs/php_codesniffer": "3.7.2", "symfony/cache": "^5.4 || ^6.2 || ^7.0", - "vimeo/psalm": "5.24.0" + "vimeo/psalm": "5.26.1" }, "suggest": { "ext-dom": "Provides support for XSD validation for XML mapping files", diff --git a/docs/en/tutorials/working-with-indexed-associations.rst b/docs/en/tutorials/working-with-indexed-associations.rst index e31b9be8f99..1b120a2ae40 100644 --- a/docs/en/tutorials/working-with-indexed-associations.rst +++ b/docs/en/tutorials/working-with-indexed-associations.rst @@ -29,83 +29,18 @@ You can map indexed associations by adding: The code and mappings for the Market entity looks like this: .. configuration-block:: - .. code-block:: attribute - - */ - #[OneToMany(targetEntity: Stock::class, mappedBy: 'market', indexBy: 'symbol')] - private Collection $stocks; - - public function __construct(string $name) - { - $this->name = $name; - $this->stocks = new ArrayCollection(); - } - - public function getId(): int|null - { - return $this->id; - } - - public function getName(): string - { - return $this->name; - } - - public function addStock(Stock $stock): void - { - $this->stocks[$stock->getSymbol()] = $stock; - } - - public function getStock(string $symbol): Stock - { - if (!isset($this->stocks[$symbol])) { - throw new \InvalidArgumentException("Symbol is not traded on this market."); - } - - return $this->stocks[$symbol]; - } - - /** @return array */ - public function getStocks(): array - { - return $this->stocks->toArray(); - } - } - - .. code-block:: xml + .. literalinclude:: working-with-indexed-associations/Market.php + :language: attribute - - + .. literalinclude:: working-with-indexed-associations/Market-annotations.php + :language: annotation - - - - + .. literalinclude:: working-with-indexed-associations/market.xml + :language: xml - + .. literalinclude:: working-with-indexed-associations/market.xml + :language: yaml - - - Inside the ``addStock()`` method you can see how we directly set the key of the association to the symbol, so that we can work with the indexed association directly after invoking ``addStock()``. Inside ``getStock($symbol)`` diff --git a/docs/en/tutorials/working-with-indexed-associations/Market-annotations.php b/docs/en/tutorials/working-with-indexed-associations/Market-annotations.php new file mode 100644 index 00000000000..798b49d1d02 --- /dev/null +++ b/docs/en/tutorials/working-with-indexed-associations/Market-annotations.php @@ -0,0 +1,74 @@ + + */ + private Collection $stocks; + + public function __construct($name) + { + $this->name = $name; + $this->stocks = new ArrayCollection(); + } + + public function getId(): int|null + { + return $this->id; + } + + public function getName(): string + { + return $this->name; + } + + public function addStock(Stock $stock): void + { + $this->stocks[$stock->getSymbol()] = $stock; + } + + public function getStock($symbol): Stock + { + if (!isset($this->stocks[$symbol])) { + throw new InvalidArgumentException("Symbol is not traded on this market."); + } + + return $this->stocks[$symbol]; + } + + /** @return array */ + public function getStocks(): array + { + return $this->stocks->toArray(); + } +} diff --git a/docs/en/tutorials/working-with-indexed-associations/Market.php b/docs/en/tutorials/working-with-indexed-associations/Market.php new file mode 100644 index 00000000000..bb16d3902b3 --- /dev/null +++ b/docs/en/tutorials/working-with-indexed-associations/Market.php @@ -0,0 +1,68 @@ + */ + #[OneToMany(targetEntity: Stock::class, mappedBy: 'market', indexBy: 'symbol')] + private Collection $stocks; + + public function __construct(string $name) + { + $this->name = $name; + $this->stocks = new ArrayCollection(); + } + + public function getId(): int|null + { + return $this->id; + } + + public function getName(): string + { + return $this->name; + } + + public function addStock(Stock $stock): void + { + $this->stocks[$stock->getSymbol()] = $stock; + } + + public function getStock(string $symbol): Stock + { + if (! isset($this->stocks[$symbol])) { + throw new InvalidArgumentException('Symbol is not traded on this market.'); + } + + return $this->stocks[$symbol]; + } + + /** @return array */ + public function getStocks(): array + { + return $this->stocks->toArray(); + } +} diff --git a/docs/en/tutorials/working-with-indexed-associations/market.xml b/docs/en/tutorials/working-with-indexed-associations/market.xml new file mode 100644 index 00000000000..3fc9fa2a857 --- /dev/null +++ b/docs/en/tutorials/working-with-indexed-associations/market.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + diff --git a/docs/en/tutorials/working-with-indexed-associations/market.yaml b/docs/en/tutorials/working-with-indexed-associations/market.yaml new file mode 100644 index 00000000000..b7c8132e090 --- /dev/null +++ b/docs/en/tutorials/working-with-indexed-associations/market.yaml @@ -0,0 +1,15 @@ +Doctrine\Tests\Models\StockExchange\Market: + type: entity + id: + id: + type: integer + generator: + strategy: AUTO + fields: + name: + type:string + oneToMany: + stocks: + targetEntity: Stock + mappedBy: market + indexBy: symbol diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 807db27145e..c7897f4d614 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + isEmpty() ? $filteredParameters->first() : null]]> diff --git a/tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php b/tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php index a25b3782160..bdb3d2ae9f9 100644 --- a/tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php +++ b/tests/Tests/ORM/Cache/DefaultCacheFactoryTest.php @@ -71,7 +71,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); @@ -91,7 +91,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); @@ -111,7 +111,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); @@ -132,7 +132,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); @@ -153,7 +153,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); @@ -174,7 +174,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); diff --git a/tests/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php index 0c8f7c4387d..fe6c050bc71 100644 --- a/tests/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php +++ b/tests/Tests/ORM/Cache/Persister/Entity/NonStrictReadWriteCachedEntityPersisterTest.php @@ -60,7 +60,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'); diff --git a/tests/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php b/tests/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php index 40fbd20a7c4..dc958fc4860 100644 --- a/tests/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php +++ b/tests/Tests/ORM/Cache/Persister/Entity/ReadWriteCachedEntityPersisterTest.php @@ -80,7 +80,7 @@ public function testUpdateTransactionRollBackShouldEvictItem(): void $this->region->expects(self::once()) ->method('evict') ->with(self::equalTo($key)) - ->willReturn(true); + ->willReturn($lock); $this->em->getUnitOfWork()->registerManaged($entity, ['id' => 1], ['id' => 1, 'name' => 'Foo']); diff --git a/tests/Tests/ORM/Functional/PostLoadEventTest.php b/tests/Tests/ORM/Functional/PostLoadEventTest.php index b68a12a532d..01d634b0380 100644 --- a/tests/Tests/ORM/Functional/PostLoadEventTest.php +++ b/tests/Tests/ORM/Functional/PostLoadEventTest.php @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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); @@ -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); @@ -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); @@ -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(); @@ -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(); diff --git a/tests/Tests/ORM/Functional/SQLFilterTest.php b/tests/Tests/ORM/Functional/SQLFilterTest.php index 3f12f4db069..6183b9c56e2 100644 --- a/tests/Tests/ORM/Functional/SQLFilterTest.php +++ b/tests/Tests/ORM/Functional/SQLFilterTest.php @@ -226,7 +226,7 @@ private function addMockFilterCollection(EntityManagerInterface&MockObject $em): $em->expects(self::any()) ->method('getFilters') - ->will(self::returnValue($filterCollection)); + ->willReturn($filterCollection); return $filterCollection; } @@ -238,12 +238,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 @@ -267,7 +267,7 @@ public function testSQLFilterGetConnection(): void $em = $this->getMockEntityManager(); $em->expects(self::once()) ->method('getConnection') - ->will(self::returnValue($conn)); + ->willReturn($conn); $filter = new MyLocaleFilter($em); @@ -283,12 +283,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 @@ -307,11 +307,11 @@ public function testSQLFilterSetArrayParameterInfersType(): void // Setup mock connection $conn = $this->getMockConnection(); $conn->method('quote') - ->will(self::returnCallback(static fn ($value) => "'" . $value . "'")); + ->willReturnCallback(static fn ($value) => "'" . $value . "'"); $em = $this->getMockEntityManager(); $em->method('getConnection') - ->will(self::returnValue($conn)); + ->willReturn($conn); $filterCollection = $this->addMockFilterCollection($em); $filterCollection diff --git a/tests/Tests/ORM/Functional/Ticket/DDC2359Test.php b/tests/Tests/ORM/Functional/Ticket/DDC2359Test.php index b02a8dfe62f..7e8a753d53d 100644 --- a/tests/Tests/ORM/Functional/Ticket/DDC2359Test.php +++ b/tests/Tests/ORM/Functional/Ticket/DDC2359Test.php @@ -43,15 +43,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); diff --git a/tests/Tests/ORM/Internal/HydrationCompleteHandlerTest.php b/tests/Tests/ORM/Internal/HydrationCompleteHandlerTest.php index 5275d980a54..51cf37e0494 100644 --- a/tests/Tests/ORM/Internal/HydrationCompleteHandlerTest.php +++ b/tests/Tests/ORM/Internal/HydrationCompleteHandlerTest.php @@ -49,7 +49,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); @@ -80,7 +80,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); @@ -104,7 +104,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); @@ -136,7 +136,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); diff --git a/tests/Tests/ORM/LazyCriteriaCollectionTest.php b/tests/Tests/ORM/LazyCriteriaCollectionTest.php index 4a974972328..82733dd643c 100644 --- a/tests/Tests/ORM/LazyCriteriaCollectionTest.php +++ b/tests/Tests/ORM/LazyCriteriaCollectionTest.php @@ -29,7 +29,7 @@ protected function setUp(): void public function testCountIsCached(): void { - $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(10)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->willReturn(10); self::assertSame(10, $this->lazyCriteriaCollection->count()); self::assertSame(10, $this->lazyCriteriaCollection->count()); @@ -38,7 +38,7 @@ public function testCountIsCached(): void public function testCountIsCachedEvenWithZeroResult(): void { - $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(0)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->willReturn(0); self::assertSame(0, $this->lazyCriteriaCollection->count()); self::assertSame(0, $this->lazyCriteriaCollection->count()); @@ -52,7 +52,7 @@ public function testCountUsesWrappedCollectionWhenInitialized(): void ->expects(self::once()) ->method('loadCriteria') ->with($this->criteria) - ->will(self::returnValue(['foo', 'bar', 'baz'])); + ->willReturn(['foo', 'bar', 'baz']); // should never call the persister's count $this->persister->expects(self::never())->method('count'); @@ -77,7 +77,7 @@ public function testMatchingUsesThePersisterOnlyOnce(): void ->expects(self::once()) ->method('loadCriteria') ->with($this->criteria) - ->will(self::returnValue([$foo, $bar, $baz])); + ->willReturn([$foo, $bar, $baz]); $criteria = new Criteria(); @@ -93,14 +93,14 @@ public function testMatchingUsesThePersisterOnlyOnce(): void public function testIsEmptyUsesCountWhenNotInitialized(): void { - $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(0)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->willReturn(0); self::assertTrue($this->lazyCriteriaCollection->isEmpty()); } public function testIsEmptyIsFalseIfCountIsNotZero(): void { - $this->persister->expects(self::once())->method('count')->with($this->criteria)->will(self::returnValue(1)); + $this->persister->expects(self::once())->method('count')->with($this->criteria)->willReturn(1); self::assertFalse($this->lazyCriteriaCollection->isEmpty()); } @@ -112,7 +112,7 @@ public function testIsEmptyUsesWrappedCollectionWhenInitialized(): void ->expects(self::once()) ->method('loadCriteria') ->with($this->criteria) - ->will(self::returnValue(['foo', 'bar', 'baz'])); + ->willReturn(['foo', 'bar', 'baz']); // should never call the persister's count $this->persister->expects(self::never())->method('count'); diff --git a/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 1bef18a908b..540ab47dde8 100644 --- a/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -245,7 +245,7 @@ public function testGetAllMetadataWorksWithBadConnection(): void $conn->expects(self::any()) ->method('getDatabasePlatform') - ->will(self::throwException(new Exception('Exception thrown in test when calling getDatabasePlatform'))); + ->willThrowException(new Exception('Exception thrown in test when calling getDatabasePlatform')); $cmf = new ClassMetadataFactory(); $cmf->setEntityManager($em); diff --git a/tests/Tests/ORM/Proxy/ProxyFactoryTest.php b/tests/Tests/ORM/Proxy/ProxyFactoryTest.php index 31cb9cc001f..05b19a4abcf 100644 --- a/tests/Tests/ORM/Proxy/ProxyFactoryTest.php +++ b/tests/Tests/ORM/Proxy/ProxyFactoryTest.php @@ -75,7 +75,7 @@ public function testReferenceProxyDelegatesLoadingToThePersister(): void ->expects(self::atLeastOnce()) ->method('loadById') ->with(self::equalTo($identifier)) - ->will(self::returnValue($proxy)); + ->willReturn($proxy); $proxy->getDescription(); } @@ -132,7 +132,7 @@ public function testFailedProxyLoadingDoesNotMarkTheProxyAsInitialized(): void $persister ->expects(self::atLeastOnce()) ->method('load') - ->will(self::returnValue(null)); + ->willReturn(null); try { $proxy->getDescription(); @@ -158,7 +158,7 @@ public function testFailedProxyCloningDoesNotMarkTheProxyAsInitialized(): void $persister ->expects(self::atLeastOnce()) ->method('load') - ->will(self::returnValue(null)); + ->willReturn(null); try { $cloned = clone $proxy; diff --git a/tests/Tests/ORM/Query/SqlExpressionVisitorTest.php b/tests/Tests/ORM/Query/SqlExpressionVisitorTest.php index 3e2a3e30eda..79bb44f1910 100644 --- a/tests/Tests/ORM/Query/SqlExpressionVisitorTest.php +++ b/tests/Tests/ORM/Query/SqlExpressionVisitorTest.php @@ -31,7 +31,7 @@ public function testWalkNotCompositeExpression(): void $this->persister ->expects(self::once()) ->method('getSelectConditionStatementSQL') - ->will(self::returnValue('dummy expression')); + ->willReturn('dummy expression'); $expr = $this->visitor->walkCompositeExpression( $cb->not( diff --git a/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php b/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php index a9b71ef9571..83d39881f58 100644 --- a/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php +++ b/tests/Tests/ORM/Repository/DefaultRepositoryFactoryTest.php @@ -34,7 +34,7 @@ protected function setUp(): void $this->configuration ->expects(self::any()) ->method('getDefaultRepositoryClassName') - ->will(self::returnValue(DDC869PaymentRepository::class)); + ->willReturn(DDC869PaymentRepository::class); } public function testCreatesRepositoryFromDefaultRepositoryClass(): void @@ -42,7 +42,7 @@ public function testCreatesRepositoryFromDefaultRepositoryClass(): void $this->entityManager ->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback($this->buildClassMetadata(...))); + ->willReturnCallback($this->buildClassMetadata(...)); self::assertInstanceOf( DDC869PaymentRepository::class, @@ -55,7 +55,7 @@ public function testCreatedRepositoriesAreCached(): void $this->entityManager ->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback($this->buildClassMetadata(...))); + ->willReturnCallback($this->buildClassMetadata(...)); self::assertSame( $this->repositoryFactory->getRepository($this->entityManager, self::class), @@ -71,7 +71,7 @@ public function testCreatesRepositoryFromCustomClassMetadata(): void $this->entityManager ->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnValue($customMetadata)); + ->willReturn($customMetadata); self::assertInstanceOf( DDC753DefaultRepository::class, @@ -86,11 +86,11 @@ public function testCachesDistinctRepositoriesPerDistinctEntityManager(): void $em1->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback($this->buildClassMetadata(...))); + ->willReturnCallback($this->buildClassMetadata(...)); $em2->expects(self::any()) ->method('getClassMetadata') - ->will(self::returnCallback($this->buildClassMetadata(...))); + ->willReturnCallback($this->buildClassMetadata(...)); $repo1 = $this->repositoryFactory->getRepository($em1, self::class); $repo2 = $this->repositoryFactory->getRepository($em2, self::class);