Skip to content

Commit f4add50

Browse files
chore: replace assertEquals by assertSame when it's possible
1 parent 1e1b121 commit f4add50

File tree

126 files changed

+524
-524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+524
-524
lines changed

tests/Action/ExceptionActionTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public function testActionWithCatchableException(): void
5858
$request->setFormat('jsonproblem', 'application/problem+json');
5959

6060
$response = $exceptionAction($flattenException, $request);
61-
$this->assertEquals('', $response->getContent());
62-
$this->assertEquals(Response::HTTP_BAD_REQUEST, $response->getStatusCode());
61+
$this->assertSame('', $response->getContent());
62+
$this->assertSame(Response::HTTP_BAD_REQUEST, $response->getStatusCode());
6363
$this->assertTrue($response->headers->contains('Content-Type', 'application/problem+json; charset=utf-8'));
6464
$this->assertTrue($response->headers->contains('X-Content-Type-Options', 'nosniff'));
6565
$this->assertTrue($response->headers->contains('X-Frame-Options', 'deny'));
@@ -118,8 +118,8 @@ public function testActionWithOperationExceptionToStatus(
118118

119119
$response = $exceptionAction($flattenException, $request);
120120

121-
$this->assertEquals('', $response->getContent());
122-
$this->assertEquals($expectedStatusCode, $response->getStatusCode());
121+
$this->assertSame('', $response->getContent());
122+
$this->assertSame($expectedStatusCode, $response->getStatusCode());
123123
$this->assertTrue($response->headers->contains('Content-Type', 'application/problem+json; charset=utf-8'));
124124
$this->assertTrue($response->headers->contains('X-Content-Type-Options', 'nosniff'));
125125
$this->assertTrue($response->headers->contains('X-Frame-Options', 'deny'));

tests/Action/PlaceholderActionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ public function testAction(): void
2626
$action = new PlaceholderAction();
2727

2828
$expected = new \stdClass();
29-
$this->assertEquals($expected, $action($expected));
29+
$this->assertSame($expected, $action($expected));
3030
}
3131
}

tests/Api/CompositeIdentifierParserTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CompositeIdentifierParserTest extends TestCase
2424
public function testNormalizeCompositeCorrectly(array $identifiers): void
2525
{
2626
foreach ($identifiers as $string => $expected) {
27-
$this->assertEquals(CompositeIdentifierParser::parse($string), $expected);
27+
$this->assertSame(CompositeIdentifierParser::parse($string), $expected);
2828
}
2929
}
3030

@@ -48,7 +48,7 @@ public function variousIdentifiers(): array
4848
public function testStringify(array $identifiers): void
4949
{
5050
foreach ($identifiers as $string => $arr) {
51-
$this->assertEquals(CompositeIdentifierParser::stringify($arr), $string);
51+
$this->assertSame(CompositeIdentifierParser::stringify($arr), $string);
5252
}
5353
}
5454

tests/Api/UriVariableTransformer/IntegerUriVariableTransformerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class IntegerUriVariableTransformerTest extends TestCase
2020
{
2121
public function testTransform(): void
2222
{
23-
$this->assertEquals(2, (new IntegerUriVariableTransformer())->transform('2', ['int']));
23+
$this->assertSame(2, (new IntegerUriVariableTransformer())->transform('2', ['int']));
2424
}
2525

2626
public function testSupportsTransformation(): void

tests/Doctrine/Common/State/PersistProcessorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testPersist(): void
4949
$managerRegistryProphecy->getManagerForClass(Dummy::class)->willReturn($objectManagerProphecy->reveal())->shouldBeCalled();
5050

5151
$result = (new PersistProcessor($managerRegistryProphecy->reveal()))->process($dummy, new Get());
52-
$this->assertEquals($dummy, $result);
52+
$this->assertSame($dummy, $result);
5353
}
5454

5555
public function testPersistIfEntityAlreadyManaged(): void
@@ -67,7 +67,7 @@ public function testPersistIfEntityAlreadyManaged(): void
6767
$managerRegistryProphecy->getManagerForClass(Dummy::class)->willReturn($objectManagerProphecy->reveal())->shouldBeCalled();
6868

6969
$result = (new PersistProcessor($managerRegistryProphecy->reveal()))->process($dummy, new Get());
70-
$this->assertEquals($dummy, $result);
70+
$this->assertSame($dummy, $result);
7171
}
7272

7373
public function testPersistWithNullManager(): void
@@ -78,7 +78,7 @@ public function testPersistWithNullManager(): void
7878
$managerRegistryProphecy->getManagerForClass(Dummy::class)->willReturn(null)->shouldBeCalled();
7979

8080
$result = (new PersistProcessor($managerRegistryProphecy->reveal()))->process($dummy, new Get());
81-
$this->assertEquals($dummy, $result);
81+
$this->assertSame($dummy, $result);
8282
}
8383

8484
public function getTrackingPolicyParameters()
@@ -120,6 +120,6 @@ public function testTrackingPolicy($metadataClass, $deferredExplicit, $persisted
120120
$managerRegistryProphecy->getManagerForClass(Dummy::class)->willReturn($objectManagerProphecy)->shouldBeCalled();
121121

122122
$result = (new PersistProcessor($managerRegistryProphecy->reveal()))->process($dummy, new Get());
123-
$this->assertEquals($dummy, $result);
123+
$this->assertSame($dummy, $result);
124124
}
125125
}

tests/Doctrine/Odm/Metadata/Property/DoctrineMongoDbOdmPropertyMetadataFactoryTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testCreateNoManager(): void
4343

4444
$doctrineMongoDbOdmPropertyMetadataFactory = new DoctrineMongoDbOdmPropertyMetadataFactory($managerRegistry->reveal(), $propertyMetadataFactory->reveal());
4545

46-
$this->assertEquals($doctrineMongoDbOdmPropertyMetadataFactory->create(Dummy::class, 'id'), $propertyMetadata);
46+
$this->assertSame($doctrineMongoDbOdmPropertyMetadataFactory->create(Dummy::class, 'id'), $propertyMetadata);
4747
}
4848

4949
public function testCreateIsIdentifier(): void
@@ -64,7 +64,7 @@ public function testCreateIsIdentifier(): void
6464

6565
$doctrineMongoDbOdmPropertyMetadataFactory = new DoctrineMongoDbOdmPropertyMetadataFactory($managerRegistry->reveal(), $propertyMetadataFactory->reveal());
6666

67-
$this->assertEquals($doctrineMongoDbOdmPropertyMetadataFactory->create(Dummy::class, 'id'), $propertyMetadata);
67+
$this->assertSame($doctrineMongoDbOdmPropertyMetadataFactory->create(Dummy::class, 'id'), $propertyMetadata);
6868
}
6969

7070
public function testCreateIsWritable(): void
@@ -88,8 +88,8 @@ public function testCreateIsWritable(): void
8888

8989
$doctrinePropertyMetadata = $doctrineMongoDbOdmPropertyMetadataFactory->create(Dummy::class, 'id');
9090

91-
$this->assertEquals($doctrinePropertyMetadata->isIdentifier(), true);
92-
$this->assertEquals($doctrinePropertyMetadata->isWritable(), false);
91+
$this->assertSame($doctrinePropertyMetadata->isIdentifier(), true);
92+
$this->assertSame($doctrinePropertyMetadata->isWritable(), false);
9393
}
9494

9595
public function testCreateClassMetadata(): void
@@ -112,7 +112,7 @@ public function testCreateClassMetadata(): void
112112

113113
$doctrinePropertyMetadata = $doctrineMongoDbOdmPropertyMetadataFactory->create(Dummy::class, 'id');
114114

115-
$this->assertEquals($doctrinePropertyMetadata->isIdentifier(), true);
116-
$this->assertEquals($doctrinePropertyMetadata->isWritable(), false);
115+
$this->assertSame($doctrinePropertyMetadata->isIdentifier(), true);
116+
$this->assertSame($doctrinePropertyMetadata->isWritable(), false);
117117
}
118118
}

tests/Doctrine/Odm/Metadata/Resource/DoctrineMongoDbOdmResourceCollectionMetadataFactoryTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ public function testWithProvider(Operation $operation, string $expectedProvider
8686
$managerRegistry->getManagerForClass($operation->getClass())->willReturn($objectManager->reveal());
8787
$resourceMetadataCollectionFactory = new DoctrineMongoDbOdmResourceCollectionMetadataFactory($managerRegistry->reveal(), $this->getResourceMetadataCollectionFactory($operation));
8888
$resourceMetadataCollection = $resourceMetadataCollectionFactory->create($operation->getClass());
89-
$this->assertEquals($expectedProvider, $resourceMetadataCollection->getOperation($operation->getName())->getProvider());
90-
$this->assertEquals($expectedProvider, $resourceMetadataCollection->getOperation('graphql_'.$operation->getName())->getProvider());
91-
$this->assertEquals($expectedProcessor, $resourceMetadataCollection->getOperation($operation->getName())->getProcessor());
92-
$this->assertEquals($expectedProcessor, $resourceMetadataCollection->getOperation('graphql_'.$operation->getName())->getProcessor());
89+
$this->assertSame($expectedProvider, $resourceMetadataCollection->getOperation($operation->getName())->getProvider());
90+
$this->assertSame($expectedProvider, $resourceMetadataCollection->getOperation('graphql_'.$operation->getName())->getProvider());
91+
$this->assertSame($expectedProcessor, $resourceMetadataCollection->getOperation($operation->getName())->getProcessor());
92+
$this->assertSame($expectedProcessor, $resourceMetadataCollection->getOperation('graphql_'.$operation->getName())->getProcessor());
9393
}
9494

9595
public function operationProvider(): iterable

tests/Doctrine/Odm/PaginatorTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public function testInitialize(int $firstResult, int $maxResults, int $totalItem
3636
{
3737
$paginator = $this->getPaginator($firstResult, $maxResults, $totalItems);
3838

39-
$this->assertEquals((float) $currentPage, $paginator->getCurrentPage());
40-
$this->assertEquals((float) $lastPage, $paginator->getLastPage());
41-
$this->assertEquals((float) $maxResults, $paginator->getItemsPerPage());
39+
$this->assertSame((float) $currentPage, $paginator->getCurrentPage());
40+
$this->assertSame((float) $lastPage, $paginator->getLastPage());
41+
$this->assertSame((float) $maxResults, $paginator->getItemsPerPage());
4242
}
4343

4444
public function testInitializeWithFacetStageNotApplied(): void
@@ -85,25 +85,25 @@ public function testInitializeWithLimitZeroStageApplied(): void
8585
{
8686
$paginator = $this->getPaginator(0, 5, 0, true);
8787

88-
$this->assertEquals(1., $paginator->getCurrentPage());
89-
$this->assertEquals(1., $paginator->getLastPage());
90-
$this->assertEquals(0., $paginator->getItemsPerPage());
88+
$this->assertSame(1., $paginator->getCurrentPage());
89+
$this->assertSame(1., $paginator->getLastPage());
90+
$this->assertSame(0., $paginator->getItemsPerPage());
9191
}
9292

9393
public function testInitializeWithNoCount(): void
9494
{
9595
$paginator = $this->getPaginatorWithNoCount();
9696

97-
$this->assertEquals(1., $paginator->getCurrentPage());
98-
$this->assertEquals(1., $paginator->getLastPage());
99-
$this->assertEquals(15., $paginator->getItemsPerPage());
97+
$this->assertSame(1., $paginator->getCurrentPage());
98+
$this->assertSame(1., $paginator->getLastPage());
99+
$this->assertSame(15., $paginator->getItemsPerPage());
100100
}
101101

102102
public function testGetIterator(): void
103103
{
104104
$paginator = $this->getPaginator();
105105

106-
$this->assertEquals($paginator->getIterator(), $paginator->getIterator(), 'Iterator should be cached');
106+
$this->assertSame($paginator->getIterator(), $paginator->getIterator(), 'Iterator should be cached');
107107
}
108108

109109
private function getPaginator(int $firstResult = 1, int $maxResults = 15, int $totalItems = 42, bool $limitZero = false): Paginator

tests/Doctrine/Odm/State/CollectionProviderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function testGetCollection(): void
7272
$extensionProphecy->applyToCollection($aggregationBuilder, ProviderEntity::class, $operation, [])->shouldBeCalled();
7373

7474
$dataProvider = new CollectionProvider($this->resourceMetadataFactoryProphecy->reveal(), $this->managerRegistryProphecy->reveal(), [$extensionProphecy->reveal()]);
75-
$this->assertEquals($iterator, $dataProvider->provide($operation, []));
75+
$this->assertSame($iterator, $dataProvider->provide($operation, []));
7676
}
7777

7878
public function testGetCollectionWithExecuteOptions(): void
@@ -98,7 +98,7 @@ public function testGetCollectionWithExecuteOptions(): void
9898
$extensionProphecy->applyToCollection($aggregationBuilder, ProviderEntity::class, $operation, [])->shouldBeCalled();
9999

100100
$dataProvider = new CollectionProvider($this->resourceMetadataFactoryProphecy->reveal(), $this->managerRegistryProphecy->reveal(), [$extensionProphecy->reveal()]);
101-
$this->assertEquals($iterator, $dataProvider->provide($operation, []));
101+
$this->assertSame($iterator, $dataProvider->provide($operation, []));
102102
}
103103

104104
public function testAggregationResultExtension(): void
@@ -165,6 +165,6 @@ public function testOperationNotFound(): void
165165
$extensionProphecy->applyToCollection($aggregationBuilder, ProviderEntity::class, $operation, [])->shouldBeCalled();
166166

167167
$dataProvider = new CollectionProvider($this->resourceMetadataFactoryProphecy->reveal(), $this->managerRegistryProphecy->reveal(), [$extensionProphecy->reveal()]);
168-
$this->assertEquals($iterator, $dataProvider->provide($operation, []));
168+
$this->assertSame($iterator, $dataProvider->provide($operation, []));
169169
}
170170
}

tests/Doctrine/Odm/State/ItemProviderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function testGetItemSingleIdentifier(): void
7070

7171
$dataProvider = new ItemProvider($this->prophesize(ResourceMetadataCollectionFactoryInterface::class)->reveal(), $managerRegistry, [$extensionProphecy->reveal()]);
7272

73-
$this->assertEquals($result, $dataProvider->provide($operation, ['id' => 1], $context));
73+
$this->assertSame($result, $dataProvider->provide($operation, ['id' => 1], $context));
7474
}
7575

7676
public function testGetItemWithExecuteOptions(): void
@@ -104,7 +104,7 @@ public function testGetItemWithExecuteOptions(): void
104104

105105
$dataProvider = new ItemProvider($this->prophesize(ResourceMetadataCollectionFactoryInterface::class)->reveal(), $managerRegistry, [$extensionProphecy->reveal()]);
106106

107-
$this->assertEquals($result, $dataProvider->provide($operation, ['id' => 1], $context));
107+
$this->assertSame($result, $dataProvider->provide($operation, ['id' => 1], $context));
108108
}
109109

110110
public function testGetItemDoubleIdentifier(): void
@@ -138,7 +138,7 @@ public function testGetItemDoubleIdentifier(): void
138138

139139
$dataProvider = new ItemProvider($this->prophesize(ResourceMetadataCollectionFactoryInterface::class)->reveal(), $managerRegistry, [$extensionProphecy->reveal()]);
140140

141-
$this->assertEquals($result, $dataProvider->provide($operation, ['ida' => 1, 'idb' => 2], $context));
141+
$this->assertSame($result, $dataProvider->provide($operation, ['ida' => 1, 'idb' => 2], $context));
142142
}
143143

144144
public function testAggregationResultExtension(): void

tests/Doctrine/Orm/Extension/FilterEagerLoadingExtensionTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function testApplyCollection(): void
123123
$filterEagerLoadingExtension = new FilterEagerLoadingExtension(true);
124124
$filterEagerLoadingExtension->applyToCollection($qb, $queryNameGenerator->reveal(), DummyCar::class, new Get(name: 'get'));
125125

126-
$this->assertEquals('SELECT o FROM ApiPlatform\Tests\Fixtures\TestBundle\Entity\DummyCar o LEFT JOIN o.colors colors WHERE o IN(SELECT o_2 FROM ApiPlatform\Tests\Fixtures\TestBundle\Entity\DummyCar o_2 LEFT JOIN o_2.colors colors_2 WHERE o_2.colors = :foo)', $qb->getDQL());
126+
$this->assertSame('SELECT o FROM ApiPlatform\Tests\Fixtures\TestBundle\Entity\DummyCar o LEFT JOIN o.colors colors WHERE o IN(SELECT o_2 FROM ApiPlatform\Tests\Fixtures\TestBundle\Entity\DummyCar o_2 LEFT JOIN o_2.colors colors_2 WHERE o_2.colors = :foo)', $qb->getDQL());
127127
}
128128

129129
public function testApplyCollectionWithManualJoin(): void
@@ -168,7 +168,7 @@ public function testApplyCollectionWithManualJoin(): void
168168
)
169169
SQL;
170170

171-
$this->assertEquals($this->toDQLString($expected), $qb->getDQL());
171+
$this->assertSame($this->toDQLString($expected), $qb->getDQL());
172172
}
173173

174174
public function testApplyCollectionCorrectlyReplacesJoinCondition(): void
@@ -208,7 +208,7 @@ public function testApplyCollectionCorrectlyReplacesJoinCondition(): void
208208
)
209209
SQL;
210210

211-
$this->assertEquals($this->toDQLString($expected), $qb->getDQL());
211+
$this->assertSame($this->toDQLString($expected), $qb->getDQL());
212212
}
213213

214214
/**
@@ -246,7 +246,7 @@ public function testHiddenOrderBy(): void
246246
) ORDER BY _o_dateCreated_null_rank DESC ASC
247247
SQL;
248248

249-
$this->assertEquals($this->toDQLString($expected), $qb->getDQL());
249+
$this->assertSame($this->toDQLString($expected), $qb->getDQL());
250250
}
251251

252252
public function testGroupBy(): void
@@ -285,7 +285,7 @@ public function testGroupBy(): void
285285
ORDER BY o.colors ASC
286286
SQL;
287287

288-
$this->assertEquals($this->toDQLString($expected), $qb->getDQL());
288+
$this->assertSame($this->toDQLString($expected), $qb->getDQL());
289289
}
290290

291291
public function testCompositeIdentifiers(): void
@@ -338,7 +338,7 @@ public function testCompositeIdentifiers(): void
338338
)
339339
SQL;
340340

341-
$this->assertEquals($this->toDQLString($expected), $qb->getDQL());
341+
$this->assertSame($this->toDQLString($expected), $qb->getDQL());
342342
}
343343

344344
public function testFetchEagerWithNoForceEager(): void
@@ -408,7 +408,7 @@ public function testFetchEagerWithNoForceEager(): void
408408
)
409409
DQL;
410410

411-
$this->assertEquals($this->toDQLString($expected), $qb->getDQL());
411+
$this->assertSame($this->toDQLString($expected), $qb->getDQL());
412412
}
413413

414414
public function testCompositeIdentifiersWithAssociation(): void
@@ -463,7 +463,7 @@ public function testCompositeIdentifiersWithAssociation(): void
463463
))
464464
SQL;
465465

466-
$this->assertEquals($this->toDQLString($expected), $qb->getDQL());
466+
$this->assertSame($this->toDQLString($expected), $qb->getDQL());
467467
}
468468

469469
public function testCompositeIdentifiersWithoutAssociation(): void
@@ -502,7 +502,7 @@ public function testCompositeIdentifiersWithoutAssociation(): void
502502
WHERE item.field1 = :foo AND o.bar = :bar
503503
SQL;
504504

505-
$this->assertEquals($this->toDQLString($expected), $qb->getDQL());
505+
$this->assertSame($this->toDQLString($expected), $qb->getDQL());
506506
}
507507

508508
public function testCompositeIdentifiersWithForeignIdentifiers(): void
@@ -541,7 +541,7 @@ public function testCompositeIdentifiersWithForeignIdentifiers(): void
541541
)
542542
SQL;
543543

544-
$this->assertEquals($this->toDQLString($expected), $qb->getDQL());
544+
$this->assertSame($this->toDQLString($expected), $qb->getDQL());
545545
}
546546

547547
private function toDQLString(string $dql): string

tests/Doctrine/Orm/Extension/PaginationExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ public function testGetResultWithFetchJoinCollection(bool $paginationFetchJoinCo
392392
$doctrinePaginatorReflectionProperty->setAccessible(true);
393393

394394
$doctrinePaginator = $doctrinePaginatorReflectionProperty->getValue($result);
395-
$this->assertEquals($expected, $doctrinePaginator->getFetchJoinCollection());
395+
$this->assertSame($expected, $doctrinePaginator->getFetchJoinCollection());
396396
}
397397

398398
public function fetchJoinCollectionProvider(): array
@@ -442,7 +442,7 @@ public function testGetResultWithUseOutputWalkers(bool $paginationUseOutputWalke
442442
$doctrinePaginatorReflectionProperty->setAccessible(true);
443443

444444
$doctrinePaginator = $doctrinePaginatorReflectionProperty->getValue($result);
445-
$this->assertEquals($expected, $doctrinePaginator->getUseOutputWalkers());
445+
$this->assertSame($expected, $doctrinePaginator->getUseOutputWalkers());
446446
}
447447

448448
public function fetchUseOutputWalkersProvider(): array

0 commit comments

Comments
 (0)