Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
90.91% covered (success)
90.91%
10 / 11
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
ObjectTestCase
90.91% covered (success)
90.91%
10 / 11
66.67% covered (warning)
66.67%
2 / 3
4.01
0.00% covered (danger)
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% covered (warning)
75.00%
3 / 4
0.00% covered (danger)
0.00%
0 / 1
2.06
 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}