Skip to content

Commit f31c4e5

Browse files
committed
Merge branch '1.x' into 2.x
2 parents 42c836a + 397ad7a commit f31c4e5

File tree

9 files changed

+70
-54
lines changed

9 files changed

+70
-54
lines changed

tests/Cache/PropertyResolver/AssociationResolverTestCase.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ public function testResolveAssociations(
3333
bool $isGetAssociationMappedByTargetFieldCalled,
3434
bool $isAssociationInverseSide,
3535
): void {
36-
$extractor = self::createStub(PropertyReadInfoExtractorInterface::class);
37-
$extractor->method('getReadInfo')
36+
$extractor = $this->createMock(PropertyReadInfoExtractorInterface::class);
37+
$extractor->expects(self::once())
38+
->method('getReadInfo')
3839
->with('BarEntity', 'barProperty')
3940
->willReturn(
4041
new PropertyReadInfo(
@@ -126,8 +127,9 @@ public function testFieldNotAssociation(): void
126127
),
127128
);
128129

129-
$classMetadata = self::createStub(ClassMetadata::class);
130-
$classMetadata->method('hasAssociation')
130+
$classMetadata = $this->createMock(ClassMetadata::class);
131+
$classMetadata->expects(self::once())
132+
->method('hasAssociation')
131133
->with('fooProperty')
132134
->willReturn(false);
133135

tests/Cache/PropertyResolver/EmbeddableResolverDoctrine3Test.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ public function testResolveEmbeddable(): void
4848
->with('BarEntity')
4949
->willReturn($embeddableClassMetadata);
5050

51-
$managerRegistry = self::createStub(ManagerRegistry::class);
52-
$managerRegistry->method('getManagerForClass')
51+
$managerRegistry = $this->createMock(ManagerRegistry::class);
52+
$managerRegistry->expects(self::once())
53+
->method('getManagerForClass')
5354
->with('ParentClass')
5455
->willReturn($entityManager);
5556

tests/Cache/PropertyResolver/ExpressionLanguage/InverseRelationExpressionTransformerTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ final class InverseRelationExpressionTransformerTest extends TestCase
2020
#[TestWith(['false', PropertyReadInfo::TYPE_METHOD, 'isBar', 'obj.isBar() !== null ? (obj.isBar().firstName~"-"~obj.isBar().lastName) : false'])]
2121
public function testTransform(string $fallback, string $readInfoType, string $readInfoName, string $expectedExpression): void
2222
{
23-
$extractor = self::createStub(PropertyReadInfoExtractorInterface::class);
24-
$extractor->method('getReadInfo')
23+
$extractor = $this->createMock(PropertyReadInfoExtractorInterface::class);
24+
$extractor->expects(self::once())
25+
->method('getReadInfo')
2526
->with(\stdClass::class, 'prop')
2627
->willReturn(
2728
new PropertyReadInfo(
@@ -42,8 +43,9 @@ public function testTransform(string $fallback, string $readInfoType, string $re
4243

4344
public function testExceptionIsThrownWhenPropertyIsNotAccessible(): void
4445
{
45-
$extractor = self::createStub(PropertyReadInfoExtractorInterface::class);
46-
$extractor->method('getReadInfo')
46+
$extractor = $this->createMock(PropertyReadInfoExtractorInterface::class);
47+
$extractor->expects(self::once())
48+
->method('getReadInfo')
4749
->with(\stdClass::class, 'prop')
4850
->willReturn(null);
4951

tests/Cache/PropertyResolver/InverseValuesBuildersTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ final class InverseValuesBuildersTest extends TestCase
2929
{
3030
public function testBuild(): void
3131
{
32-
$extractor = self::createStub(PropertyReadInfoExtractorInterface::class);
33-
$extractor->method('getReadInfo')
32+
$extractor = $this->createMock(PropertyReadInfoExtractorInterface::class);
33+
$extractor->expects(self::once())
34+
->method('getReadInfo')
3435
->with(\stdClass::class, 'association')
3536
->willReturn(
3637
new PropertyReadInfo(

tests/Cache/PropertyResolver/MethodResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function testResolveMethod(string $target, int $invocationCount): void
4646

4747
$classMetadata = self::createStub(ClassMetadata::class);
4848
$classMetadata->method('hasField')
49-
->willReturnCallback(fn (string $property) => match ($property) {
49+
->willReturnCallback(static fn (string $property) => match ($property) {
5050
'bar' => true,
5151
'baz' => true,
5252
});

tests/Cache/PropertyResolver/PropertyResolverTest.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ public function testResolveField(): void
2828
managerRegistry: self::createStub(ManagerRegistry::class),
2929
);
3030

31-
$classMetadata = self::createStub(ClassMetadata::class);
31+
$classMetadata = $this->createMock(ClassMetadata::class);
3232
$classMetadata->subClasses = [];
33-
$classMetadata->method('hasField')
33+
$classMetadata->expects(self::once())
34+
->method('hasField')
3435
->with('fooProperty')
3536
->willReturn(true);
3637

@@ -67,9 +68,10 @@ public function testTargetNotField(): void
6768
managerRegistry: self::createStub(ManagerRegistry::class),
6869
);
6970

70-
$classMetadata = self::createStub(ClassMetadata::class);
71+
$classMetadata = $this->createMock(ClassMetadata::class);
7172
$classMetadata->subClasses = [];
72-
$classMetadata->method('hasField')
73+
$classMetadata->expects(self::once())
74+
->method('hasField')
7375
->with('fooProperty')
7476
->willReturn(false);
7577

@@ -101,18 +103,22 @@ public function testResolveAssociation(): void
101103
managerRegistry: self::createStub(ManagerRegistry::class),
102104
);
103105

104-
$classMetadata = self::createStub(ClassMetadata::class);
106+
$classMetadata = $this->createMock(ClassMetadata::class);
105107
$classMetadata->subClasses = [];
106-
$classMetadata->method('hasField')
108+
$classMetadata->expects(self::once())
109+
->method('hasField')
107110
->with('fooProperty')
108111
->willReturn(false);
109-
$classMetadata->method('hasAssociation')
112+
$classMetadata->expects(self::once())
113+
->method('hasAssociation')
110114
->with('fooProperty')
111115
->willReturn(true);
112-
$classMetadata->method('isSingleValuedAssociation')
116+
$classMetadata->expects(self::once())
117+
->method('isSingleValuedAssociation')
113118
->with('fooProperty')
114119
->willReturn(true);
115-
$classMetadata->method('isAssociationInverseSide')
120+
$classMetadata->expects(self::once())
121+
->method('isAssociationInverseSide')
116122
->with('fooProperty')
117123
->willReturn(false);
118124

tests/Cache/Subscription/PurgeSubscriptionProviderTest.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testWithoutTarget(RouteMetadata $routeMetadata, array $expectedS
3838
{
3939
$routeMetadataProvider = self::createStub(RouteMetadataProviderInterface::class);
4040
$routeMetadataProvider->method('provide')
41-
->willReturnCallback(function () use ($routeMetadata) {
41+
->willReturnCallback(static function () use ($routeMetadata) {
4242
yield $routeMetadata;
4343
});
4444

@@ -138,7 +138,7 @@ public function testWithTarget(RouteMetadata $routeMetadata, array $targetResolv
138138
{
139139
$subscriptionResolver = self::createStub(SubscriptionResolverInterface::class);
140140
$subscriptionResolver->method('resolveSubscription')
141-
->willReturnCallback(function () use ($expectedSubscriptions) {
141+
->willReturnCallback(static function () use ($expectedSubscriptions) {
142142
static $i = 0;
143143

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

149149
$routeMetadataProvider = self::createStub(RouteMetadataProviderInterface::class);
150150
$routeMetadataProvider->method('provide')
151-
->willReturnCallback(function () use ($routeMetadata) {
151+
->willReturnCallback(static function () use ($routeMetadata) {
152152
yield $routeMetadata;
153153
});
154154

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

157-
$entityManager = self::createStub(EntityManagerInterface::class);
158-
$entityManager->method('getClassMetadata')
157+
$entityManager = $this->createMock(EntityManagerInterface::class);
158+
$entityManager->expects(self::once())
159+
->method('getClassMetadata')
159160
->with('FooEntity')
160161
->willReturn($classMetadata);
161162

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

168-
$dummyTargetResolver = self::createStub(TargetResolverInterface::class);
169-
$dummyTargetResolver->method('resolve')
169+
$dummyTargetResolver = $this->createMock(TargetResolverInterface::class);
170+
$dummyTargetResolver->expects(self::once())
171+
->method('resolve')
170172
->with($routeMetadata->purgeOn->target, $routeMetadata)
171173
->willReturn($targetResolverReturn);
172174

173-
$targetResolverLocator = self::createStub(ContainerInterface::class);
174-
$targetResolverLocator->method('get')
175+
$targetResolverLocator = $this->createMock(ContainerInterface::class);
176+
$targetResolverLocator->expects(self::once())
177+
->method('get')
175178
->with(DummyTarget::class)
176179
->willReturn($dummyTargetResolver);
177180

@@ -300,7 +303,7 @@ public function testExceptionIsThrownWhenEntityMetadataIsNotFound(): void
300303
{
301304
$routeMetadataProvider = self::createStub(RouteMetadataProviderInterface::class);
302305
$routeMetadataProvider->method('provide')
303-
->willReturnCallback(function () {
306+
->willReturnCallback(static function () {
304307
yield new RouteMetadata(
305308
routeName: 'foo',
306309
route: new Route('/foo'),
@@ -338,7 +341,7 @@ public function testWithMissingRouteParams(
338341
): void {
339342
$routeMetadataProvider = self::createStub(RouteMetadataProviderInterface::class);
340343
$routeMetadataProvider->method('provide')
341-
->willReturnCallback(function () use ($routeMetadata) {
344+
->willReturnCallback(static function () use ($routeMetadata) {
342345
yield $routeMetadata;
343346
});
344347

@@ -491,7 +494,7 @@ public function testExceptionIsThrownOnInvalidRouteParamsExpression(string $expr
491494
{
492495
$routeMetadataProvider = self::createStub(RouteMetadataProviderInterface::class);
493496
$routeMetadataProvider->method('provide')
494-
->willReturnCallback(function () use ($expression): iterable {
497+
->willReturnCallback(static function () use ($expression): iterable {
495498
yield new RouteMetadata(
496499
routeName: 'foo',
497500
route: new Route('/{foo}'),
@@ -514,7 +517,7 @@ class: 'FooEntity',
514517
public function getFunctions(): array
515518
{
516519
return [
517-
new ExpressionFunction('valid_function', function () {}, function () {}),
520+
new ExpressionFunction('valid_function', static function () {}, static function () {}),
518521
];
519522
}
520523
},
@@ -533,7 +536,7 @@ public function testExceptionIsThrownOnInvalidIfExpression(string $if, string $e
533536
{
534537
$routeMetadataProvider = self::createStub(RouteMetadataProviderInterface::class);
535538
$routeMetadataProvider->method('provide')
536-
->willReturnCallback(function () use ($if): iterable {
539+
->willReturnCallback(static function () use ($if): iterable {
537540
yield new RouteMetadata(
538541
routeName: 'foo',
539542
route: new Route('/{foo}'),
@@ -556,7 +559,7 @@ class: 'FooEntity',
556559
public function getFunctions(): array
557560
{
558561
return [
559-
new ExpressionFunction('valid_function', function () {}, function () {}),
562+
new ExpressionFunction('valid_function', static function () {}, static function () {}),
560563
];
561564
}
562565
},

tests/Cache/TargetResolver/ForGroupsResolverTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ final class ForGroupsResolverTest extends TestCase
2020
{
2121
public function testResolve(): void
2222
{
23-
$propertyListExtractor = self::createStub(PropertyListExtractorInterface::class);
24-
$propertyListExtractor->method('getProperties')
23+
$propertyListExtractor = $this->createMock(PropertyListExtractorInterface::class);
24+
$propertyListExtractor->expects(self::once())
25+
->method('getProperties')
2526
->with('FooEntity', ['serializer_groups' => ['group1']])
2627
->willReturn(['property1', 'property2']);
2728

tests/RouteProvider/RemovedEntityRouteProviderTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,9 @@ public function testExceptionIsThrownWhenEntityMetadataIsNotFound(): void
152152
$configurationLoader->method('load')
153153
->willReturn(new Configuration([]));
154154

155-
$managerRegistry = self::createStub(ManagerRegistry::class);
156-
$managerRegistry->method('getManagerForClass')
155+
$managerRegistry = $this->createMock(ManagerRegistry::class);
156+
$managerRegistry->expects(self::once())
157+
->method('getManagerForClass')
157158
->with(\stdClass::class)
158159
->willReturn(null);
159160

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

243244
$classMetadata = self::createStub(ClassMetadata::class);
244-
245-
$entityManager = self::createStub(EntityManagerInterface::class);
246-
247-
$managerRegistry = self::createStub(ManagerRegistry::class);
248-
$managerRegistry->method('getManagerForClass')
249-
->with(\stdClass::class)
250-
->willReturn($entityManager);
251-
252-
$entityManager->method('getClassMetadata')
253-
->with(\stdClass::class)
254-
->willReturn($classMetadata);
255-
256245
$classMetadata->method('getFieldNames')
257246
->willReturn(['foo', 'bar', 'baz']);
258-
259247
$classMetadata->method('getAssociationNames')
260248
->willReturn([]);
261249

250+
$entityManager = $this->createMock(EntityManagerInterface::class);
251+
$entityManager->expects(self::once())
252+
->method('getClassMetadata')
253+
->with(\stdClass::class)
254+
->willReturn($classMetadata);
255+
256+
$managerRegistry = $this->createMock(ManagerRegistry::class);
257+
$managerRegistry->expects(self::once())
258+
->method('getManagerForClass')
259+
->with(\stdClass::class)
260+
->willReturn($entityManager);
261+
262262
$expressionLanguage = null;
263263
if ($withExpressionLang) {
264264
$expressionLanguage = self::createStub(ExpressionLanguage::class);

0 commit comments

Comments
 (0)