Skip to content

Commit c1ade1d

Browse files
authored
Merge pull request #182 from open-source-contributions/test_enhancement
Test enhancement
2 parents 87a5162 + f7f2076 commit c1ade1d

7 files changed

+27
-31
lines changed

phpunit.xml.dist

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414

1515
<filter>
1616
<whitelist>
17-
<directory>.</directory>
18-
<exclude>
19-
<directory>tests</directory>
20-
<directory>vendor</directory>
21-
</exclude>
17+
<directory>src</directory>
2218
</whitelist>
2319
</filter>
2420
</phpunit>

tests/AnnotationGenerator/ApiPlatformCoreAnnotationGeneratorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,23 @@ protected function setUp(): void
5959
);
6060
}
6161

62-
public function testGenerateClassAnnotations()
62+
public function testGenerateClassAnnotations(): void
6363
{
6464
$this->assertSame(['@ApiResource(iri="http://schema.org/Res")'], $this->generator->generateClassAnnotations('Res'));
6565
}
6666

67-
public function testGenerateClassAnnotationsWithOperations()
67+
public function testGenerateClassAnnotationsWithOperations(): void
6868
{
6969
$this->assertSame(['@ApiResource(iri="http://schema.org/WithOperations", itemOperations={"get"={"route_name"="api_about_get"}}, collectionOperations={})'], $this->generator->generateClassAnnotations('WithOperations'));
7070
}
7171

72-
public function testGenerateFieldAnnotations()
72+
public function testGenerateFieldAnnotations(): void
7373
{
7474
$this->assertSame(['@ApiProperty(iri="http://schema.org/prop")'], $this->generator->generateFieldAnnotations('Res', 'prop'));
7575
$this->assertSame([], $this->generator->generateFieldAnnotations('Res', 'customProp'));
7676
}
7777

78-
public function testGenerateUses()
78+
public function testGenerateUses(): void
7979
{
8080
$this->assertSame(['ApiPlatform\Core\Annotation\ApiResource', 'ApiPlatform\Core\Annotation\ApiProperty'], $this->generator->generateUses('Res'));
8181
$this->assertSame([], $this->generator->generateUses('MyEnum'));

tests/AnnotationGenerator/DoctrineOrmAnnotationGeneratorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class DoctrineOrmAnnotationGeneratorTest extends TestCase
2828
*/
2929
private $generator;
3030

31-
public function setUp()
31+
protected function setUp(): void
3232
{
3333
$graph = new \EasyRdf_Graph();
3434
$myEnum = new \EasyRdf_Resource('https://schema.org/MyEnum', $graph);
@@ -79,15 +79,15 @@ public function setUp()
7979
);
8080
}
8181

82-
public function testGenerateClassAnnotations()
82+
public function testGenerateClassAnnotations(): void
8383
{
8484
$this->assertSame([], $this->generator->generateClassAnnotations('MyEnum'));
8585
$this->assertSame(['', '@ORM\MappedSuperclass'], $this->generator->generateClassAnnotations('Product'));
8686
$this->assertSame(['', '@ORM\Entity'], $this->generator->generateClassAnnotations('Vehicle'));
8787
$this->assertSame(['', '@ORM\Embeddable'], $this->generator->generateClassAnnotations('QuantitativeValue'));
8888
}
8989

90-
public function testGenerateFieldAnnotations()
90+
public function testGenerateFieldAnnotations(): void
9191
{
9292
$this->assertSame(
9393
['@ORM\Embedded(class="QuantitativeValue", columnPrefix=false)'],

tests/Command/DumpConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class DumpConfigurationTest extends TestCase
2424
{
25-
public function testDumpConfiguration()
25+
public function testDumpConfiguration(): void
2626
{
2727
$commandTester = new CommandTester(new DumpConfigurationCommand());
2828
$this->assertEquals(0, $commandTester->execute([]));

tests/Command/ExtractCardinalitiesCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
class ExtractCardinalitiesCommandTest extends TestCase
2424
{
25-
public function testExtractCardinalities()
25+
public function testExtractCardinalities(): void
2626
{
2727
$commandTester = new CommandTester(new ExtractCardinalitiesCommand());
2828
$this->assertEquals(0, $commandTester->execute(

tests/Command/GenerateTypesCommandTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ protected function setUp(): void
3636
/**
3737
* @dataProvider getArguments
3838
*/
39-
public function testCommand($output, $config)
39+
public function testCommand($output, $config): void
4040
{
4141
$this->fs->mkdir($output);
4242

4343
$commandTester = new CommandTester(new GenerateTypesCommand());
4444
$this->assertEquals(0, $commandTester->execute(['output' => $output, 'config' => $config]));
4545
}
4646

47-
public function getArguments()
47+
public function getArguments(): array
4848
{
4949
return [
5050
[__DIR__.'/../../build/blog/', __DIR__.'/../config/blog.yaml'],
@@ -55,7 +55,7 @@ public function getArguments()
5555
];
5656
}
5757

58-
public function testDoctrineCollection()
58+
public function testDoctrineCollection(): void
5959
{
6060
$outputDir = __DIR__.'/../../build/address-book';
6161
$config = __DIR__.'/../config/address-book.yaml';
@@ -78,7 +78,7 @@ public function getFriends(): Collection
7878
, $person);
7979
}
8080

81-
public function testFluentMutators()
81+
public function testFluentMutators(): void
8282
{
8383
$outputDir = __DIR__.'/../../build/fluent-mutators';
8484
$config = __DIR__.'/../config/fluent-mutators.yaml';
@@ -115,7 +115,7 @@ public function removeFriend(Person $friend): self
115115
, $person);
116116
}
117117

118-
public function testDoNotGenerateAccessorMethods()
118+
public function testDoNotGenerateAccessorMethods(): void
119119
{
120120
$outputDir = __DIR__.'/../../build/public-properties';
121121
$config = __DIR__.'/../config/public-properties.yaml';
@@ -132,7 +132,7 @@ public function testDoNotGenerateAccessorMethods()
132132
$this->assertNotContains('function remove', $person);
133133
}
134134

135-
public function testImplicitAndExplicitPropertyInheritance()
135+
public function testImplicitAndExplicitPropertyInheritance(): void
136136
{
137137
$outputDir = __DIR__.'/../../build/inherited-properties';
138138
$config = __DIR__.'/../config/inherited-properties.yaml';
@@ -164,7 +164,7 @@ public function testImplicitAndExplicitPropertyInheritance()
164164
$this->assertNotContains('function setName(', $webPage);
165165
}
166166

167-
public function testReadableWritable()
167+
public function testReadableWritable(): void
168168
{
169169
$outputDir = __DIR__.'/../../build/readable-writable';
170170
$config = __DIR__.'/../config/readable-writable.yaml';
@@ -184,7 +184,7 @@ public function testReadableWritable()
184184
$this->assertNotContains('function removeFriend(', $person);
185185
}
186186

187-
public function testGeneratedId()
187+
public function testGeneratedId(): void
188188
{
189189
$outputDir = __DIR__.'/../../build/generated-id';
190190
$config = __DIR__.'/../config/generated-id.yaml';
@@ -219,7 +219,7 @@ public function getId(): ?int
219219
$this->assertNotContains('function setId(', $person);
220220
}
221221

222-
public function testNonGeneratedId()
222+
public function testNonGeneratedId(): void
223223
{
224224
$outputDir = __DIR__.'/../../build/non-generated-id';
225225
$config = __DIR__.'/../config/non-generated-id.yaml';
@@ -253,7 +253,7 @@ public function getId(): string
253253
$this->assertContains('public function setId(string $id): void', $person);
254254
}
255255

256-
public function testGeneratedUuid()
256+
public function testGeneratedUuid(): void
257257
{
258258
$outputDir = __DIR__.'/../../build/generated-uuid';
259259
$config = __DIR__.'/../config/generated-uuid.yaml';
@@ -289,7 +289,7 @@ public function getId(): ?string
289289
$this->assertNotContains('function setId(', $person);
290290
}
291291

292-
public function testNonGeneratedUuid()
292+
public function testNonGeneratedUuid(): void
293293
{
294294
$outputDir = __DIR__.'/../../build/non-generated-uuid';
295295
$config = __DIR__.'/../config/non-generated-uuid.yaml';
@@ -324,7 +324,7 @@ public function getId(): string
324324
$this->assertContains('public function setId(string $id): void', $person);
325325
}
326326

327-
public function testDoNotGenerateId()
327+
public function testDoNotGenerateId(): void
328328
{
329329
$outputDir = __DIR__.'/../../build/no-id';
330330
$config = __DIR__.'/../config/no-id.yaml';
@@ -341,7 +341,7 @@ public function testDoNotGenerateId()
341341
$this->assertNotContains('function setId', $person);
342342
}
343343

344-
public function testNamespacesPrefix()
344+
public function testNamespacesPrefix(): void
345345
{
346346
$outputDir = __DIR__.'/../../build/namespaces-prefix';
347347
$config = __DIR__.'/../config/namespaces-prefix.yaml';
@@ -356,7 +356,7 @@ public function testNamespacesPrefix()
356356
$this->assertContains('namespace App\Entity;', $person);
357357
}
358358

359-
public function testNamespacesPrefixAutodetect()
359+
public function testNamespacesPrefixAutodetect(): void
360360
{
361361
$outputDir = __DIR__.'/../../build/namespaces-prefix-autodetect/';
362362

@@ -378,7 +378,7 @@ public function testNamespacesPrefixAutodetect()
378378
}
379379
}
380380

381-
public function testGeneratedEnum()
381+
public function testGeneratedEnum(): void
382382
{
383383
$outputDir = __DIR__.'/../../build/enum';
384384
$config = __DIR__.'/../config/enum.yaml';
@@ -401,7 +401,7 @@ public function testGeneratedEnum()
401401
$this->assertNotContains('function setId(', $gender);
402402
}
403403

404-
public function testSupersededProperties()
404+
public function testSupersededProperties(): void
405405
{
406406
$outputDir = __DIR__.'/../../build/superseded-properties';
407407
$config = __DIR__.'/../config/superseded-properties.yaml';

tests/TypesGeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ private function getClasses(): array
390390
*
391391
* @return \Closure
392392
*/
393-
private function getContextMatcher(array $class)
393+
private function getContextMatcher(array $class): \Closure
394394
{
395395
$config = $this->getConfig();
396396

0 commit comments

Comments
 (0)