Skip to content

Commit

Permalink
Merge branch '1.8.x' into 2.0.x
Browse files Browse the repository at this point in the history
* 1.8.x:
  Adjust PHPStan settings for ORM 3 (#467)
  Add tests (#465)
  Backport tests for strict return types (#463)
  • Loading branch information
derrabus committed Mar 8, 2024
2 parents ecb0e82 + 0e5d455 commit e01cf5e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
8 changes: 6 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ parameters:
paths:
- src
- tests
excludePaths:
- tests/Mock/ForwardCompatibleEntityManager.php

ignoreErrors:
# ORM 3 forward compatibility
- '~^Parameter \$assoc of method Doctrine\\Common\\DataFixtures\\Purger\\ORMPurger\:\:getJoinTableName\(\) has invalid type Doctrine\\ORM\\Mapping\\ManyToManyOwningSideMapping\.$~'
# ORM 2 backwards compatibility
-
message: '#^Call to an undefined static method Doctrine\\ORM\\ORMSetup\:\:createAnnotationMetadataConfiguration\(\)\.$#'
path: tests/Common/DataFixtures/BaseTestCase.php

includes:
- phpstan-baseline.neon
6 changes: 2 additions & 4 deletions tests/Common/DataFixtures/Executor/ORMExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public function testExecuteWithPurge(): void
$em = $this->getMockSqliteEntityManager();
$purger = $this->getMockPurger();
$purger->expects($this->once())
->method('purge')
->willReturn(null);
->method('purge');
$executor = new ORMExecutor($em, $purger);
$fixture = $this->getMockFixture();
$fixture->expects($this->once())
Expand Down Expand Up @@ -103,8 +102,7 @@ public function testExecuteMultipleTransactionsWithPurge(): void
$em = $this->getMockSqliteEntityManager();
$purger = $this->getMockPurger();
$purger->expects($this->once())
->method('purge')
->willReturn(null);
->method('purge');
$executor = new MultipleTransactionORMExecutor($em, $purger);
$fixture = $this->getMockFixture();
$fixture->expects($this->once())
Expand Down
13 changes: 12 additions & 1 deletion tests/Common/DataFixtures/ReferenceRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testReferenceIdentityPopulation(): void

$referenceRepository->expects($this->once())
->method('getReferenceNames')
->will($this->returnValue(['admin-role']));
->willReturn(['admin-role']);

$referenceRepository->expects($this->once())
->method('setReferenceIdentity')
Expand Down Expand Up @@ -131,6 +131,17 @@ public function testUndefinedReference(): void
$referenceRepository->getReference('foo', Role::class);
}

/** @group legacy */
public function testLegacyUndefinedReference(): void
{
$referenceRepository = new ReferenceRepository($this->getMockSqliteEntityManager());

$this->expectException(OutOfBoundsException::class);
$this->expectExceptionMessage(sprintf('Reference to "foo" for class "%s" does not exist', Role::class));

$referenceRepository->getReference('foo', Role::class);
}

public function testThrowsExceptionAddingDuplicatedReference(): void
{
$em = $this->getMockSqliteEntityManager();
Expand Down

0 comments on commit e01cf5e

Please sign in to comment.