|
7 | 7 | use Arkitect\Expression\ForClasses\HaveNameMatching; |
8 | 8 | use Arkitect\Expression\ForClasses\Implement; |
9 | 9 | use Arkitect\Rules\Rule; |
| 10 | +use Arkitect\Tests\Integration\Fixtures\Implements\AnInterface; |
10 | 11 | use Arkitect\Tests\Utils\TestRunner; |
11 | | -use org\bovigo\vfs\vfsStream; |
12 | 12 | use PHPUnit\Framework\TestCase; |
13 | 13 |
|
14 | 14 | class ImplementsTest extends TestCase |
15 | 15 | { |
16 | 16 | public function test_naming_is_enforced(): void |
17 | 17 | { |
18 | | - $dir = vfsStream::setup('root', null, $this->createDirStructure())->url(); |
| 18 | + $dir = __DIR__.'/Fixtures/Implements'; |
19 | 19 |
|
20 | 20 | $runner = TestRunner::create('8.2'); |
21 | 21 |
|
22 | 22 | $rule = Rule::allClasses() |
23 | | - ->that(new Implement('App\AnInterface')) |
| 23 | + ->that(new Implement(AnInterface::class)) |
24 | 24 | ->should(new HaveNameMatching('An*')) |
25 | 25 | ->because('reasons'); |
26 | 26 |
|
27 | 27 | $runner->run($dir, $rule); |
28 | 28 |
|
29 | 29 | self::assertCount(0, $runner->getParsingErrors()); |
30 | | - self::assertCount(2, $runner->getViolations()); |
31 | | - |
32 | | - self::assertEquals('App\AClass', $runner->getViolations()->get(0)->getFqcn()); |
33 | | - self::assertStringContainsString('should have a name that matches An* because reasons', $runner->getViolations()->get(0)->getError()); |
34 | | - |
35 | | - self::assertEquals('App\AEnum', $runner->getViolations()->get(1)->getFqcn()); |
36 | | - self::assertStringContainsString('should have a name that matches An* because reasons', $runner->getViolations()->get(1)->getError()); |
37 | | - } |
38 | | - |
39 | | - public function createDirStructure(): array |
40 | | - { |
41 | | - return [ |
42 | | - 'App' => [ |
43 | | - 'AEnum.php' => '<?php |
44 | | -
|
45 | | - namespace App; |
46 | | -
|
47 | | - enum AEnum implements AnInterface { |
48 | | - case PENDING; |
49 | | - case PAID; |
50 | | -
|
51 | | - public function amethod() {} |
52 | | - } |
53 | | - ', |
54 | | - 'OneTrait.php' => '<?php |
55 | | -
|
56 | | - namespace App; |
57 | | -
|
58 | | - trait OneTrait { |
59 | | - public function one() {} |
60 | | - } |
61 | | - ', |
62 | | - 'AClass.php' => '<?php |
63 | | -
|
64 | | - namespace App; |
65 | | -
|
66 | | - class AClass implements AnInterface { |
67 | | - public function amethod() {} |
68 | | - } |
69 | | - ', |
70 | | - 'AnInterface.php' => '<?php |
71 | | -
|
72 | | - namespace App; |
73 | | -
|
74 | | - interface AnInterface { |
75 | | - public function amethod(); |
76 | | - } |
77 | | - ', |
78 | | - ], |
79 | | - ]; |
| 30 | + self::assertCount(1, $runner->getViolations()); |
| 31 | + |
| 32 | + self::assertEquals( |
| 33 | + 'Arkitect\Tests\Integration\Fixtures\Implements\AClass', |
| 34 | + $runner->getViolations()->get(0)->getFqcn() |
| 35 | + ); |
| 36 | + self::assertStringContainsString( |
| 37 | + 'should have a name that matches An* because reasons', |
| 38 | + $runner->getViolations()->get(0)->getError() |
| 39 | + ); |
80 | 40 | } |
81 | 41 | } |
0 commit comments