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