Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions tests/Cache/PropertyResolver/AssociationResolverTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ public function testResolveAssociations(
bool $isGetAssociationMappedByTargetFieldCalled,
bool $isAssociationInverseSide,
): void {
$extractor = self::createStub(PropertyReadInfoExtractorInterface::class);
$extractor->method('getReadInfo')
$extractor = $this->createMock(PropertyReadInfoExtractorInterface::class);
$extractor->expects(self::once())
->method('getReadInfo')
->with('BarEntity', 'barProperty')
->willReturn(
new PropertyReadInfo(
Expand Down Expand Up @@ -115,8 +116,9 @@ public function testFieldNotAssociation(): void
self::createStub(PropertyReadInfoExtractorInterface::class),
);

$classMetadata = self::createStub(ClassMetadata::class);
$classMetadata->method('hasAssociation')
$classMetadata = $this->createMock(ClassMetadata::class);
$classMetadata->expects(self::once())
->method('hasAssociation')
->with('fooProperty')
->willReturn(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ public function testResolveEmbeddable(): void
->with('BarEntity')
->willReturn($embeddableClassMetadata);

$managerRegistry = self::createStub(ManagerRegistry::class);
$managerRegistry->method('getManagerForClass')
$managerRegistry = $this->createMock(ManagerRegistry::class);
$managerRegistry->expects(self::once())
->method('getManagerForClass')
->with('ParentClass')
->willReturn($entityManager);

Expand Down
24 changes: 15 additions & 9 deletions tests/Cache/PropertyResolver/PropertyResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ public function testResolveField(): void
managerRegistry: self::createStub(ManagerRegistry::class),
);

$classMetadata = self::createStub(ClassMetadata::class);
$classMetadata = $this->createMock(ClassMetadata::class);
$classMetadata->subClasses = [];
$classMetadata->method('hasField')
$classMetadata->expects(self::once())
->method('hasField')
->with('fooProperty')
->willReturn(true);

Expand Down Expand Up @@ -67,9 +68,10 @@ public function testTargetNotField(): void
managerRegistry: self::createStub(ManagerRegistry::class),
);

$classMetadata = self::createStub(ClassMetadata::class);
$classMetadata = $this->createMock(ClassMetadata::class);
$classMetadata->subClasses = [];
$classMetadata->method('hasField')
$classMetadata->expects(self::once())
->method('hasField')
->with('fooProperty')
->willReturn(false);

Expand Down Expand Up @@ -101,18 +103,22 @@ public function testResolveAssociation(): void
managerRegistry: self::createStub(ManagerRegistry::class),
);

$classMetadata = self::createStub(ClassMetadata::class);
$classMetadata = $this->createMock(ClassMetadata::class);
$classMetadata->subClasses = [];
$classMetadata->method('hasField')
$classMetadata->expects(self::once())
->method('hasField')
->with('fooProperty')
->willReturn(false);
$classMetadata->method('hasAssociation')
$classMetadata->expects(self::once())
->method('hasAssociation')
->with('fooProperty')
->willReturn(true);
$classMetadata->method('isSingleValuedAssociation')
$classMetadata->expects(self::once())
->method('isSingleValuedAssociation')
->with('fooProperty')
->willReturn(true);
$classMetadata->method('isAssociationInverseSide')
$classMetadata->expects(self::once())
->method('isAssociationInverseSide')
->with('fooProperty')
->willReturn(false);

Expand Down
15 changes: 9 additions & 6 deletions tests/Cache/Subscription/PurgeSubscriptionProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,9 @@ public function testWithTarget(RouteMetadata $routeMetadata, array $targetResolv

$classMetadata = self::createStub(ClassMetadata::class);

$entityManager = self::createStub(EntityManagerInterface::class);
$entityManager->method('getClassMetadata')
$entityManager = $this->createMock(EntityManagerInterface::class);
$entityManager->expects(self::once())
->method('getClassMetadata')
->with('FooEntity')
->willReturn($classMetadata);

Expand All @@ -165,13 +166,15 @@ public function testWithTarget(RouteMetadata $routeMetadata, array $targetResolv
->with('FooEntity')
->willReturn($entityManager);

$dummyTargetResolver = self::createStub(TargetResolverInterface::class);
$dummyTargetResolver->method('resolve')
$dummyTargetResolver = $this->createMock(TargetResolverInterface::class);
$dummyTargetResolver->expects(self::once())
->method('resolve')
->with($routeMetadata->purgeOn->target, $routeMetadata)
->willReturn($targetResolverReturn);

$targetResolverLocator = self::createStub(ContainerInterface::class);
$targetResolverLocator->method('get')
$targetResolverLocator = $this->createMock(ContainerInterface::class);
$targetResolverLocator->expects(self::once())
->method('get')
->with(DummyTarget::class)
->willReturn($dummyTargetResolver);

Expand Down
5 changes: 3 additions & 2 deletions tests/Cache/TargetResolver/ForGroupsResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ final class ForGroupsResolverTest extends TestCase
{
public function testResolve(): void
{
$propertyListExtractor = self::createStub(PropertyListExtractorInterface::class);
$propertyListExtractor->method('getProperties')
$propertyListExtractor = $this->createMock(PropertyListExtractorInterface::class);
$propertyListExtractor->expects(self::once())
->method('getProperties')
->with('FooEntity', ['serializer_groups' => ['group1']])
->willReturn(['property1', 'property2']);

Expand Down
30 changes: 15 additions & 15 deletions tests/RouteProvider/RemovedEntityRouteProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ public function testExceptionIsThrownWhenEntityMetadataIsNotFound(): void
$configurationLoader->method('load')
->willReturn(new Configuration([]));

$managerRegistry = self::createStub(ManagerRegistry::class);
$managerRegistry->method('getManagerForClass')
$managerRegistry = $this->createMock(ManagerRegistry::class);
$managerRegistry->expects(self::once())
->method('getManagerForClass')
->with(\stdClass::class)
->willReturn(null);

Expand Down Expand Up @@ -241,24 +242,23 @@ private function createRouteProvider(array $configuration, bool $withExpressionL
->willReturn(new Configuration($configuration));

$classMetadata = self::createStub(ClassMetadata::class);

$entityManager = self::createStub(EntityManagerInterface::class);

$managerRegistry = self::createStub(ManagerRegistry::class);
$managerRegistry->method('getManagerForClass')
->with(\stdClass::class)
->willReturn($entityManager);

$entityManager->method('getClassMetadata')
->with(\stdClass::class)
->willReturn($classMetadata);

$classMetadata->method('getFieldNames')
->willReturn(['foo', 'bar', 'baz']);

$classMetadata->method('getAssociationNames')
->willReturn([]);

$entityManager = $this->createMock(EntityManagerInterface::class);
$entityManager->expects(self::once())
->method('getClassMetadata')
->with(\stdClass::class)
->willReturn($classMetadata);

$managerRegistry = $this->createMock(ManagerRegistry::class);
$managerRegistry->expects(self::once())
->method('getManagerForClass')
->with(\stdClass::class)
->willReturn($entityManager);

$expressionLanguage = null;
if ($withExpressionLang) {
$expressionLanguage = self::createStub(ExpressionLanguage::class);
Expand Down