Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
90.00% |
9 / 10 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| ObjectTestCase | |
90.00% |
9 / 10 |
|
66.67% |
2 / 3 |
4.02 | |
0.00% |
0 / 1 |
| className | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| getOpenApiSchemaForCreation | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| testCount | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
| it_works_with_schema_generator | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| it_works_with_apie_faker | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\Fixtures\TestHelpers; |
| 3 | |
| 4 | use Apie\Core\Attributes\FakeCount; |
| 5 | use PHPUnit\Framework\Attributes\Test; |
| 6 | use PHPUnit\Framework\TestCase; |
| 7 | |
| 8 | abstract class ObjectTestCase extends TestCase |
| 9 | { |
| 10 | use TestWithOpenapiSchema; |
| 11 | use TestWithFaker; |
| 12 | use TestWithDoctrineEntityDatalayer; |
| 13 | |
| 14 | /** |
| 15 | * @return class-string<object> |
| 16 | */ |
| 17 | abstract public static function className(): string; |
| 18 | |
| 19 | abstract public static function getOpenApiSchemaForCreation(): array; |
| 20 | |
| 21 | protected static function testCount(): int |
| 22 | { |
| 23 | $refl = new \ReflectionClass(static::className()); |
| 24 | foreach ($refl->getAttributes(FakeCount::class) as $attribute) { |
| 25 | return $attribute->newInstance()->count; |
| 26 | } |
| 27 | |
| 28 | return 500; |
| 29 | } |
| 30 | |
| 31 | #[Test] |
| 32 | public function it_works_with_schema_generator() |
| 33 | { |
| 34 | $this->runOpenapiSchemaTestForCreation( |
| 35 | static::className(), |
| 36 | (new \ReflectionClass(static::className()))->getShortName() . '-post', |
| 37 | static::getOpenApiSchemaForCreation() |
| 38 | ); |
| 39 | } |
| 40 | |
| 41 | #[Test] |
| 42 | public function it_works_with_apie_faker() |
| 43 | { |
| 44 | $this->runFakerTest(static::className(), interval: static::testCount()); |
| 45 | } |
| 46 | } |