|
23 | 23 | __DIR__.'/../stubs/StatusStringWithoutDocBlock.stub', |
24 | 24 | $this->withoutDocBlockEnumsFolder.'/StatusStringWithoutDocBlock.php' |
25 | 25 | ); |
| 26 | + copy( |
| 27 | + __DIR__.'/../stubs/DoesntUseEnumHelperTrait.stub', |
| 28 | + $this->withoutDocBlockEnumsFolder.'/DoesntUseEnumHelperTrait.php' |
| 29 | + ); |
| 30 | + copy( |
| 31 | + __DIR__.'/../stubs/StatusWithoutMethodTagDocBlock.stub', |
| 32 | + $this->withoutDocBlockEnumsFolder.'/StatusWithoutMethodTagDocBlock.php' |
| 33 | + ); |
26 | 34 | }); |
27 | 35 |
|
| 36 | +/** |
| 37 | + * @param \Datomatic\LaravelEnumHelper\Tests\TestCase|\PHPUnit\Framework\TestCase $this |
| 38 | + * @return void |
| 39 | + */ |
| 40 | +function unlinkAllPhpFiles(string $folder): void |
| 41 | +{ |
| 42 | + try{ |
| 43 | + unlink($folder.'/DoesntUseEnumHelperTrait.php'); |
| 44 | + unlink($folder.'/StatusWithoutDocBlock.php'); |
| 45 | + unlink($folder.'/StatusIntWithoutDocBlock.php'); |
| 46 | + unlink($folder.'/StatusStringWithoutDocBlock.php'); |
| 47 | + unlink($folder.'/StatusWithoutMethodTagDocBlock.php'); |
| 48 | + }catch (\Exception){}; |
| 49 | +} |
| 50 | + |
28 | 51 | afterEach(function () { |
29 | | - if (file_exists($this->withoutDocBlockEnumsFolder.'/StatusWithoutDocBlock.php')) { |
30 | | - unlink($this->withoutDocBlockEnumsFolder.'/StatusWithoutDocBlock.php'); |
31 | | - unlink($this->withoutDocBlockEnumsFolder.'/StatusIntWithoutDocBlock.php'); |
32 | | - unlink($this->withoutDocBlockEnumsFolder.'/StatusStringWithoutDocBlock.php'); |
33 | | - } |
| 52 | + unlinkAllPhpFiles($this->withoutDocBlockEnumsFolder); |
| 53 | + |
34 | 54 | rmdir($this->withoutDocBlockEnumsFolder); |
35 | 55 | rmdir(app_path('Enums')); |
36 | 56 | }); |
|
97 | 117 | $this->assertEquals(1, substr_count($contents, '@method static string noResponse()')); |
98 | 118 | }); |
99 | 119 |
|
100 | | -it('doesnt annotate enums that dont use LaravelEnumTrait', function () { |
| 120 | +it('doesnt annotate enums that don\'t use LaravelEnumTrait', function () { |
101 | 121 | $this->artisan('enum:annotate Datomatic\\\\LaravelEnumHelper\\\\Tests\\\\Support\\\\Enums\\\\DoesntUseEnumHelperTrait') |
102 | 122 | ->assertSuccessful(); |
103 | 123 | $e = new ReflectionEnum(DoesntUseEnumHelperTrait::class); |
|
115 | 135 | }); |
116 | 136 |
|
117 | 137 | it('can be failed with empty folder', function () { |
118 | | - unlink($this->withoutDocBlockEnumsFolder.'/StatusWithoutDocBlock.php'); |
119 | | - unlink($this->withoutDocBlockEnumsFolder.'/StatusIntWithoutDocBlock.php'); |
120 | | - unlink($this->withoutDocBlockEnumsFolder.'/StatusStringWithoutDocBlock.php'); |
121 | | - $this->artisan("enum:annotate --folder={$this->withoutDocBlockEnumsFolder}") |
122 | | - ->assertFailed(); |
| 138 | + unlinkAllPhpFiles($this->withoutDocBlockEnumsFolder); |
| 139 | + $this->artisan("enum:annotate --folder={$this->withoutDocBlockEnumsFolder}")->assertFailed(); |
123 | 140 | }); |
0 commit comments