Skip to content

Commit fbba76a

Browse files
committed
fix duplicate test class names
1 parent 7c4601e commit fbba76a

File tree

5 files changed

+42
-49
lines changed

5 files changed

+42
-49
lines changed

tests/Unit/Doctrine/AbstractListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ private function getMockPersister(Entity $object, $indexName, $typeName)
306306
return $mock;
307307
}
308308

309-
private function getMockIndexable($indexName, $typeName, Entity $object, $return = null)
309+
private function getMockIndexable($indexName, $typeName, Entity $object = null, $return = null)
310310
{
311311
$mock = $this->createMock(IndexableInterface::class);
312312

tests/Unit/Doctrine/ORM/ElasticaToModelTransformerTest.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
class ElasticaToModelTransformerTest extends TestCase
2424
{
25+
const OBJECT_CLASS = \stdClass::class;
26+
2527
/**
2628
* @var \Doctrine\Common\Persistence\ManagerRegistry|\PHPUnit_Framework_MockObject_MockObject
2729
*/
@@ -37,19 +39,14 @@ class ElasticaToModelTransformerTest extends TestCase
3739
*/
3840
protected $repository;
3941

40-
/**
41-
* @var string
42-
*/
43-
protected $objectClass = 'stdClass';
44-
4542
protected function setUp()
4643
{
4744
$this->registry = $this->createMock(ManagerRegistry::class);
4845
$this->manager = $this->createMock(ObjectManager::class);
4946

5047
$this->registry->expects($this->any())
5148
->method('getManagerForClass')
52-
->with($this->objectClass)
49+
->with(self::OBJECT_CLASS)
5350
->will($this->returnValue($this->manager));
5451

5552
$this->repository = $this
@@ -66,7 +63,7 @@ protected function setUp()
6663

6764
$this->manager->expects($this->any())
6865
->method('getRepository')
69-
->with($this->objectClass)
66+
->with(self::OBJECT_CLASS)
7067
->will($this->returnValue($this->repository));
7168
}
7269

@@ -85,7 +82,7 @@ public function testTransformUsesQueryBuilderMethodConfiguration()
8582
$this->repository->expects($this->never())
8683
->method('createQueryBuilder');
8784

88-
$transformer = new ElasticaToModelTransformer($this->registry, $this->objectClass, [
85+
$transformer = new ElasticaToModelTransformer($this->registry, self::OBJECT_CLASS, [
8986
'query_builder_method' => 'customQueryBuilderCreator',
9087
]);
9188

@@ -111,7 +108,7 @@ public function testTransformUsesDefaultQueryBuilderMethodConfiguration()
111108
->with($this->equalTo(ElasticaToModelTransformer::ENTITY_ALIAS))
112109
->will($this->returnValue($qb));
113110

114-
$transformer = new ElasticaToModelTransformer($this->registry, $this->objectClass);
111+
$transformer = new ElasticaToModelTransformer($this->registry, self::OBJECT_CLASS);
115112

116113
$class = new \ReflectionClass(ElasticaToModelTransformer::class);
117114
$method = $class->getMethod('getEntityQueryBuilder');
@@ -145,7 +142,7 @@ public function testUsesHintsConfigurationIfGiven()
145142
->with($this->equalTo(ElasticaToModelTransformer::ENTITY_ALIAS))
146143
->will($this->returnValue($qb));
147144

148-
$transformer = new ElasticaToModelTransformer($this->registry, $this->objectClass, [
145+
$transformer = new ElasticaToModelTransformer($this->registry, self::OBJECT_CLASS, [
149146
'hints' => [
150147
['name' => 'customHintName', 'value' => 'Custom\Hint\Class'],
151148
],

tests/Unit/Doctrine/RepositoryManagerTest.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class CustomRepository
2222
{
2323
}
2424

25-
class Entity
25+
class NamespacedEntity
2626
{
2727
}
2828

@@ -41,11 +41,9 @@ public function testThatGetRepositoryCallsMainRepositoryManager()
4141
->with($this->equalTo('index/type'))
4242
->willReturn(new Repository($finderMock));
4343

44-
$entityName = Entity::class;
45-
4644
$manager = new RepositoryManager($registryMock, $mainManager);
47-
$manager->addEntity($entityName, 'index/type');
48-
$repository = $manager->getRepository($entityName);
45+
$manager->addEntity(NamespacedEntity::class, 'index/type');
46+
$repository = $manager->getRepository(NamespacedEntity::class);
4947
$this->assertInstanceOf(Repository::class, $repository);
5048
}
5149

@@ -57,17 +55,15 @@ public function testGetRepositoryShouldResolveEntityShortName()
5755

5856
$registryMock->method('getAliasNamespace')
5957
->with($this->equalTo('FOSElasticaBundle'))
60-
->willReturn('FOS\ElasticaBundle\Tests\Doctrine');
58+
->willReturn((new \ReflectionClass(NamespacedEntity::class))->getNamespaceName());
6159

6260
$mainManager->method('getRepository')
6361
->with($this->equalTo('index/type'))
6462
->willReturn(new Repository($finderMock));
6563

66-
$entityName = Entity::class;
67-
6864
$manager = new RepositoryManager($registryMock, $mainManager);
69-
$manager->addEntity($entityName, 'index/type');
70-
$repository = $manager->getRepository('FOSElasticaBundle:Entity');
65+
$manager->addEntity(NamespacedEntity::class, 'index/type');
66+
$repository = $manager->getRepository('FOSElasticaBundle:NamespacedEntity');
7167
$this->assertInstanceOf(Repository::class, $repository);
7268
}
7369
}

tests/Unit/Transformer/ModelToElasticaAutoTransformerTest.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1919
use Symfony\Component\PropertyAccess\PropertyAccess;
2020

21-
class POPO
21+
class POPO3
2222
{
2323
public $id = 123;
2424
public $name = 'someName';
@@ -183,18 +183,18 @@ public function testTransformerDispatches()
183183
);
184184

185185
$transformer = $this->getTransformer($dispatcher);
186-
$transformer->transform(new POPO(), []);
186+
$transformer->transform(new POPO3(), []);
187187
}
188188

189189
public function testPropertyPath()
190190
{
191191
$transformer = $this->getTransformer();
192192

193-
$document = $transformer->transform(new POPO(), ['name' => ['property_path' => false]]);
193+
$document = $transformer->transform(new POPO3(), ['name' => ['property_path' => false]]);
194194
$this->assertInstanceOf(Document::class, $document);
195195
$this->assertFalse($document->has('name'));
196196

197-
$document = $transformer->transform(new POPO(), ['realName' => ['property_path' => 'name']]);
197+
$document = $transformer->transform(new POPO3(), ['realName' => ['property_path' => 'name']]);
198198
$this->assertInstanceOf(Document::class, $document);
199199
$this->assertTrue($document->has('realName'));
200200
$this->assertSame('someName', $document->get('realName'));
@@ -203,7 +203,7 @@ public function testPropertyPath()
203203
public function testThatCanTransformObject()
204204
{
205205
$transformer = $this->getTransformer();
206-
$document = $transformer->transform(new POPO(), ['name' => []]);
206+
$document = $transformer->transform(new POPO3(), ['name' => []]);
207207
$data = $document->getData();
208208

209209
$this->assertInstanceOf(Document::class, $document);
@@ -215,7 +215,7 @@ public function testThatCanTransformObjectWithCorrectTypes()
215215
{
216216
$transformer = $this->getTransformer();
217217
$document = $transformer->transform(
218-
new POPO(), [
218+
new POPO3(), [
219219
'name' => [],
220220
'float' => [],
221221
'bool' => [],
@@ -238,7 +238,7 @@ public function testThatCanTransformObjectWithCorrectTypes()
238238
public function testThatCanTransformObjectWithIteratorValue()
239239
{
240240
$transformer = $this->getTransformer();
241-
$document = $transformer->transform(new POPO(), ['iterator' => []]);
241+
$document = $transformer->transform(new POPO3(), ['iterator' => []]);
242242
$data = $document->getData();
243243

244244
$this->assertSame(['value1'], $data['iterator']);
@@ -247,7 +247,7 @@ public function testThatCanTransformObjectWithIteratorValue()
247247
public function testThatCanTransformObjectWithArrayValue()
248248
{
249249
$transformer = $this->getTransformer();
250-
$document = $transformer->transform(new POPO(), ['array' => []]);
250+
$document = $transformer->transform(new POPO3(), ['array' => []]);
251251
$data = $document->getData();
252252

253253
$this->assertSame(
@@ -261,7 +261,7 @@ public function testThatCanTransformObjectWithArrayValue()
261261
public function testThatCanTransformObjectWithMultiDimensionalArrayValue()
262262
{
263263
$transformer = $this->getTransformer();
264-
$document = $transformer->transform(new POPO(), ['multiArray' => []]);
264+
$document = $transformer->transform(new POPO3(), ['multiArray' => []]);
265265
$data = $document->getData();
266266

267267
$expectedDate = new \DateTime('1978-09-07');
@@ -277,7 +277,7 @@ public function testThatCanTransformObjectWithMultiDimensionalArrayValue()
277277
public function testThatNullValuesAreNotFilteredOut()
278278
{
279279
$transformer = $this->getTransformer();
280-
$document = $transformer->transform(new POPO(), ['nullValue' => []]);
280+
$document = $transformer->transform(new POPO3(), ['nullValue' => []]);
281281
$data = $document->getData();
282282

283283
$this->assertTrue(array_key_exists('nullValue', $data));
@@ -289,13 +289,13 @@ public function testThatNullValuesAreNotFilteredOut()
289289
public function testThatCannotTransformObjectWhenGetterDoesNotExistForPrivateMethod()
290290
{
291291
$transformer = $this->getTransformer();
292-
$transformer->transform(new POPO(), ['desc' => []]);
292+
$transformer->transform(new POPO3(), ['desc' => []]);
293293
}
294294

295295
public function testFileAddedForAttachmentMapping()
296296
{
297297
$transformer = $this->getTransformer();
298-
$document = $transformer->transform(new POPO(), ['file' => ['type' => 'attachment']]);
298+
$document = $transformer->transform(new POPO3(), ['file' => ['type' => 'attachment']]);
299299
$data = $document->getData();
300300

301301
$this->assertSame(base64_encode(file_get_contents(__DIR__.'/fixtures/attachment.odt')), $data['file']);
@@ -304,7 +304,7 @@ public function testFileAddedForAttachmentMapping()
304304
public function testFileContentsAddedForAttachmentMapping()
305305
{
306306
$transformer = $this->getTransformer();
307-
$document = $transformer->transform(new POPO(), ['fileContents' => ['type' => 'attachment']]);
307+
$document = $transformer->transform(new POPO3(), ['fileContents' => ['type' => 'attachment']]);
308308
$data = $document->getData();
309309

310310
$this->assertSame(
@@ -315,7 +315,7 @@ public function testFileContentsAddedForAttachmentMapping()
315315
public function testNestedMapping()
316316
{
317317
$transformer = $this->getTransformer();
318-
$document = $transformer->transform(new POPO(), [
318+
$document = $transformer->transform(new POPO3(), [
319319
'sub' => [
320320
'type' => 'nested',
321321
'properties' => ['foo' => []],
@@ -334,7 +334,7 @@ public function testNestedMapping()
334334
public function tesObjectMapping()
335335
{
336336
$transformer = $this->getTransformer();
337-
$document = $transformer->transform(new POPO(), [
337+
$document = $transformer->transform(new POPO3(), [
338338
'sub' => [
339339
'type' => 'object',
340340
'properties' => ['bar'],
@@ -353,7 +353,7 @@ public function tesObjectMapping()
353353
public function testObjectDoesNotRequireProperties()
354354
{
355355
$transformer = $this->getTransformer();
356-
$document = $transformer->transform(new POPO(), [
356+
$document = $transformer->transform(new POPO3(), [
357357
'obj' => [
358358
'type' => 'object',
359359
],
@@ -373,7 +373,7 @@ public function testObjectsMappingOfAtLeastOneAutoMappedObjectAndAtLeastOneManua
373373
{
374374
$transformer = $this->getTransformer();
375375
$document = $transformer->transform(
376-
new POPO(),
376+
new POPO3(),
377377
[
378378
'obj' => ['type' => 'object', 'properties' => []],
379379
'nestedObject' => [
@@ -417,7 +417,7 @@ public function testObjectsMappingOfAtLeastOneAutoMappedObjectAndAtLeastOneManua
417417
public function testParentMapping()
418418
{
419419
$transformer = $this->getTransformer();
420-
$document = $transformer->transform(new POPO(), [
420+
$document = $transformer->transform(new POPO3(), [
421421
'_parent' => ['type' => 'upper', 'property' => 'upper', 'identifier' => 'id'],
422422
]);
423423

@@ -427,7 +427,7 @@ public function testParentMapping()
427427
public function testParentMappingWithCustomIdentifier()
428428
{
429429
$transformer = $this->getTransformer();
430-
$document = $transformer->transform(new POPO(), [
430+
$document = $transformer->transform(new POPO3(), [
431431
'_parent' => ['type' => 'upper', 'property' => 'upper', 'identifier' => 'name'],
432432
]);
433433

@@ -437,7 +437,7 @@ public function testParentMappingWithCustomIdentifier()
437437
public function testParentMappingWithNullProperty()
438438
{
439439
$transformer = $this->getTransformer();
440-
$document = $transformer->transform(new POPO(), [
440+
$document = $transformer->transform(new POPO3(), [
441441
'_parent' => ['type' => 'upper', 'property' => null, 'identifier' => 'id'],
442442
]);
443443

@@ -447,7 +447,7 @@ public function testParentMappingWithNullProperty()
447447
public function testParentMappingWithCustomProperty()
448448
{
449449
$transformer = $this->getTransformer();
450-
$document = $transformer->transform(new POPO(), [
450+
$document = $transformer->transform(new POPO3(), [
451451
'_parent' => ['type' => 'upper', 'property' => 'upperAlias', 'identifier' => 'id'],
452452
]);
453453

@@ -457,7 +457,7 @@ public function testParentMappingWithCustomProperty()
457457
public function testThatMappedObjectsDontNeedAnIdentifierField()
458458
{
459459
$transformer = $this->getTransformer();
460-
$document = $transformer->transform(new POPO(), [
460+
$document = $transformer->transform(new POPO3(), [
461461
'objWithoutIdentifier' => [
462462
'type' => 'object',
463463
'properties' => [
@@ -479,7 +479,7 @@ public function testThatMappedObjectsDontNeedAnIdentifierField()
479479
public function testThatNestedObjectsDontNeedAnIdentifierField()
480480
{
481481
$transformer = $this->getTransformer();
482-
$document = $transformer->transform(new POPO(), [
482+
$document = $transformer->transform(new POPO3(), [
483483
'subWithoutIdentifier' => [
484484
'type' => 'nested',
485485
'properties' => [
@@ -501,7 +501,7 @@ public function testThatNestedObjectsDontNeedAnIdentifierField()
501501
public function testNestedTransformHandlesSingleObjects()
502502
{
503503
$transformer = $this->getTransformer();
504-
$document = $transformer->transform(new POPO(), [
504+
$document = $transformer->transform(new POPO3(), [
505505
'upper' => [
506506
'type' => 'nested',
507507
'properties' => ['name' => null],
@@ -515,7 +515,7 @@ public function testNestedTransformHandlesSingleObjects()
515515
public function testNestedTransformReturnsAnEmptyArrayForNullValues()
516516
{
517517
$transformer = $this->getTransformer();
518-
$document = $transformer->transform(new POPO(), [
518+
$document = $transformer->transform(new POPO3(), [
519519
'nullValue' => [
520520
'type' => 'nested',
521521
'properties' => [

tests/Unit/Transformer/ModelToElasticaIdentifierTransformerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use PHPUnit\Framework\TestCase;
1717
use Symfony\Component\PropertyAccess\PropertyAccess;
1818

19-
class POPO
19+
class POPO4
2020
{
2121
protected $id = 123;
2222
protected $name = 'Name';
@@ -37,7 +37,7 @@ class ModelToElasticaIdentifierTransformerTest extends TestCase
3737
public function testGetDocumentWithIdentifierOnly()
3838
{
3939
$transformer = $this->getTransformer();
40-
$document = $transformer->transform(new POPO(), []);
40+
$document = $transformer->transform(new POPO4(), []);
4141
$data = $document->getData();
4242

4343
$this->assertInstanceOf(Document::class, $document);
@@ -48,7 +48,7 @@ public function testGetDocumentWithIdentifierOnly()
4848
public function testGetDocumentWithIdentifierOnlyWithFields()
4949
{
5050
$transformer = $this->getTransformer();
51-
$document = $transformer->transform(new POPO(), ['name' => []]);
51+
$document = $transformer->transform(new POPO4(), ['name' => []]);
5252
$data = $document->getData();
5353

5454
$this->assertInstanceOf(Document::class, $document);

0 commit comments

Comments
 (0)