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 @@ -33,8 +33,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 @@ -126,8 +127,9 @@ public function testFieldNotAssociation(): void
),
);

$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
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ final class InverseRelationExpressionTransformerTest extends TestCase
#[TestWith(['false', PropertyReadInfo::TYPE_METHOD, 'isBar', 'obj.isBar() !== null ? (obj.isBar().firstName~"-"~obj.isBar().lastName) : false'])]
public function testTransform(string $fallback, string $readInfoType, string $readInfoName, string $expectedExpression): void
{
$extractor = self::createStub(PropertyReadInfoExtractorInterface::class);
$extractor->method('getReadInfo')
$extractor = $this->createMock(PropertyReadInfoExtractorInterface::class);
$extractor->expects(self::once())
->method('getReadInfo')
->with(\stdClass::class, 'prop')
->willReturn(
new PropertyReadInfo(
Expand All @@ -42,8 +43,9 @@ public function testTransform(string $fallback, string $readInfoType, string $re

public function testExceptionIsThrownWhenPropertyIsNotAccessible(): void
{
$extractor = self::createStub(PropertyReadInfoExtractorInterface::class);
$extractor->method('getReadInfo')
$extractor = $this->createMock(PropertyReadInfoExtractorInterface::class);
$extractor->expects(self::once())
->method('getReadInfo')
->with(\stdClass::class, 'prop')
->willReturn(null);

Expand Down
5 changes: 3 additions & 2 deletions tests/Cache/PropertyResolver/InverseValuesBuildersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ final class InverseValuesBuildersTest extends TestCase
{
public function testBuild(): void
{
$extractor = self::createStub(PropertyReadInfoExtractorInterface::class);
$extractor->method('getReadInfo')
$extractor = $this->createMock(PropertyReadInfoExtractorInterface::class);
$extractor->expects(self::once())
->method('getReadInfo')
->with(\stdClass::class, 'association')
->willReturn(
new PropertyReadInfo(
Expand Down
2 changes: 1 addition & 1 deletion tests/Cache/PropertyResolver/MethodResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testResolveMethod(string $target, int $invocationCount): void

$classMetadata = self::createStub(ClassMetadata::class);
$classMetadata->method('hasField')
->willReturnCallback(fn (string $property) => match ($property) {
->willReturnCallback(static fn (string $property) => match ($property) {
'bar' => true,
'baz' => true,
});
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
33 changes: 18 additions & 15 deletions tests/Cache/Subscription/PurgeSubscriptionProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testWithoutTarget(RouteMetadata $routeMetadata, array $expectedS
{
$routeMetadataProvider = self::createStub(RouteMetadataProviderInterface::class);
$routeMetadataProvider->method('provide')
->willReturnCallback(function () use ($routeMetadata) {
->willReturnCallback(static function () use ($routeMetadata) {
yield $routeMetadata;
});

Expand Down Expand Up @@ -138,7 +138,7 @@ public function testWithTarget(RouteMetadata $routeMetadata, array $targetResolv
{
$subscriptionResolver = self::createStub(SubscriptionResolverInterface::class);
$subscriptionResolver->method('resolveSubscription')
->willReturnCallback(function () use ($expectedSubscriptions) {
->willReturnCallback(static function () use ($expectedSubscriptions) {
static $i = 0;

yield $expectedSubscriptions[$i++];
Expand All @@ -148,14 +148,15 @@ public function testWithTarget(RouteMetadata $routeMetadata, array $targetResolv

$routeMetadataProvider = self::createStub(RouteMetadataProviderInterface::class);
$routeMetadataProvider->method('provide')
->willReturnCallback(function () use ($routeMetadata) {
->willReturnCallback(static function () use ($routeMetadata) {
yield $routeMetadata;
});

$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 Expand Up @@ -300,7 +303,7 @@ public function testExceptionIsThrownWhenEntityMetadataIsNotFound(): void
{
$routeMetadataProvider = self::createStub(RouteMetadataProviderInterface::class);
$routeMetadataProvider->method('provide')
->willReturnCallback(function () {
->willReturnCallback(static function () {
yield new RouteMetadata(
routeName: 'foo',
route: new Route('/foo'),
Expand Down Expand Up @@ -338,7 +341,7 @@ public function testWithMissingRouteParams(
): void {
$routeMetadataProvider = self::createStub(RouteMetadataProviderInterface::class);
$routeMetadataProvider->method('provide')
->willReturnCallback(function () use ($routeMetadata) {
->willReturnCallback(static function () use ($routeMetadata) {
yield $routeMetadata;
});

Expand Down Expand Up @@ -491,7 +494,7 @@ public function testExceptionIsThrownOnInvalidRouteParamsExpression(string $expr
{
$routeMetadataProvider = self::createStub(RouteMetadataProviderInterface::class);
$routeMetadataProvider->method('provide')
->willReturnCallback(function () use ($expression): iterable {
->willReturnCallback(static function () use ($expression): iterable {
yield new RouteMetadata(
routeName: 'foo',
route: new Route('/{foo}'),
Expand All @@ -514,7 +517,7 @@ class: 'FooEntity',
public function getFunctions(): array
{
return [
new ExpressionFunction('valid_function', function () {}, function () {}),
new ExpressionFunction('valid_function', static function () {}, static function () {}),
];
}
},
Expand All @@ -533,7 +536,7 @@ public function testExceptionIsThrownOnInvalidIfExpression(string $if, string $e
{
$routeMetadataProvider = self::createStub(RouteMetadataProviderInterface::class);
$routeMetadataProvider->method('provide')
->willReturnCallback(function () use ($if): iterable {
->willReturnCallback(static function () use ($if): iterable {
yield new RouteMetadata(
routeName: 'foo',
route: new Route('/{foo}'),
Expand All @@ -556,7 +559,7 @@ class: 'FooEntity',
public function getFunctions(): array
{
return [
new ExpressionFunction('valid_function', function () {}, function () {}),
new ExpressionFunction('valid_function', static function () {}, static function () {}),
];
}
},
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
Loading