|
2 | 2 |
|
3 | 3 | namespace Grifart\ClassScaffolder\Test\Capabilities\Deprecated;
|
4 | 4 |
|
5 |
| -use Grifart\ClassScaffolder\Test\Capabilities\CapabilityTestCase; |
| 5 | +use Grifart\ClassScaffolder\ClassGenerator; |
| 6 | +use Grifart\ClassScaffolder\Definition\ClassDefinition; |
| 7 | +use Tester\Assert; |
| 8 | +use Tester\TestCase; |
6 | 9 | use function Grifart\ClassScaffolder\Capabilities\deprecated;
|
| 10 | +use function Grifart\ClassScaffolder\Definition\definitionOf; |
7 | 11 |
|
8 | 12 |
|
9 | 13 | require __DIR__ . '/../../bootstrap.php';
|
10 | 14 |
|
11 |
| -final class DeprecatedTest extends CapabilityTestCase |
| 15 | +final class DeprecatedTest extends TestCase |
12 | 16 | {
|
13 |
| - protected function getCapabilities(): array |
| 17 | + private function doAssert( |
| 18 | + ClassDefinition $definition, |
| 19 | + string $expectedFilePath, |
| 20 | + ): void |
14 | 21 | {
|
15 |
| - return [ |
16 |
| - deprecated(Replacement::class), |
17 |
| - ]; |
| 22 | + $generator = new ClassGenerator(); |
| 23 | + $phpFile = $generator->generateClass($definition); |
| 24 | + $code = (string) $phpFile; |
| 25 | + |
| 26 | + Assert::matchFile($expectedFilePath, $code); |
| 27 | + } |
| 28 | + |
| 29 | + public function testWithoutParams(): void |
| 30 | + { |
| 31 | + $this->doAssert( |
| 32 | + definition: definitionOf('ClassName') |
| 33 | + ->with(deprecated()), |
| 34 | + expectedFilePath: __DIR__ . '/DeprecatedTest.expected.onlyAnnotation.phps', |
| 35 | + ); |
| 36 | + } |
| 37 | + |
| 38 | + public function testWithDescription(): void |
| 39 | + { |
| 40 | + $this->doAssert( |
| 41 | + definition: definitionOf('ClassName') |
| 42 | + ->with(deprecated(description: 'will be removed in v4.0.0')), |
| 43 | + expectedFilePath: __DIR__ . '/DeprecatedTest.expected.withDescription.phps', |
| 44 | + ); |
| 45 | + } |
| 46 | + |
| 47 | + public function testWithReplacement(): void |
| 48 | + { |
| 49 | + $this->doAssert( |
| 50 | + definition: definitionOf('ClassName') |
| 51 | + ->with(deprecated(replacement: Replacement::class)), |
| 52 | + expectedFilePath: __DIR__ . '/DeprecatedTest.expected.withReplacement.phps', |
| 53 | + ); |
| 54 | + } |
| 55 | + |
| 56 | + public function testWithAll(): void |
| 57 | + { |
| 58 | + $this->doAssert( |
| 59 | + definition: definitionOf('ClassName') |
| 60 | + ->with(deprecated( |
| 61 | + description: 'will be removed in v4.0.0', |
| 62 | + replacement: Replacement::class, |
| 63 | + )), |
| 64 | + expectedFilePath: __DIR__ . '/DeprecatedTest.expected.withAll.phps', |
| 65 | + ); |
18 | 66 | }
|
19 | 67 | }
|
20 | 68 |
|
|
0 commit comments