Passed
Pull Request — master (#41)
by Chema
07:01
created

GlobalServicesTest.php$1 ➔ getConfigValues()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GacelaTest\Integration\Framework\GlobalServices;
6
7
use Gacela\Framework\AbstractConfig;
8
use Gacela\Framework\AbstractFacade;
9
use Gacela\Framework\AbstractFactory;
10
use Gacela\Framework\ClassResolver\AbstractClassResolver;
11
use PHPUnit\Framework\TestCase;
12
13
final class GlobalServicesTest extends TestCase
14
{
15
    private AbstractFacade $facade;
16
17
    public function setUp(): void
18
    {
19
        AbstractClassResolver::addGlobal(
20
            '\module-name@anonymous\Config',
21
            new class() extends AbstractConfig {
22
                public function getValues(): array
23
                {
24
                    return ['1', 2, [3]];
25
                }
26
            }
27
        );
28
29
        AbstractClassResolver::addGlobal(
30
            '\module-name@anonymous\Factory',
31
            new class() extends AbstractFactory {
32
                public function createDomainClass(): object
33
                {
34
                    return new class($this->getConfig()) {
35
                        private AbstractConfig $config;
36
37
                        public function __construct(AbstractConfig $config)
38
                        {
39
                            $this->config = $config;
40
                        }
41
42
                        public function getConfigValues(): array
43
                        {
44
                            return $this->config->getValues();
0 ignored issues
show
Bug introduced by
The method getValues() does not exist on Gacela\Framework\AbstractConfig. It seems like you code against a sub-type of Gacela\Framework\AbstractConfig such as anonymous//tests/Integra...lobalServicesTest.php$0 or anonymous//tests/Benchma...stractFacadeBench.php$0. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
                            return $this->config->/** @scrutinizer ignore-call */ getValues();
Loading history...
45
                        }
46
                    };
47
                }
48
            }
49
        );
50
51
        $this->facade = new class() extends AbstractFacade {
52
            public function getSomething(): array
53
            {
54
                return $this->getFactory()
55
                    ->createDomainClass()
0 ignored issues
show
Bug introduced by
The method createDomainClass() does not exist on Gacela\Framework\AbstractFactory. It seems like you code against a sub-type of Gacela\Framework\AbstractFactory such as anonymous//tests/Integra...lobalServicesTest.php$2 or anonymous//tests/Benchma...stractFacadeBench.php$2. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
                    ->/** @scrutinizer ignore-call */ createDomainClass()
Loading history...
56
                    ->getConfigValues();
57
            }
58
        };
59
    }
60
61
    public function test_factory(): void
62
    {
63
        self::assertSame(
64
            ['1', 2, [3]],
65
            $this->facade->getSomething()
0 ignored issues
show
Bug introduced by
The method getSomething() does not exist on Gacela\Framework\AbstractFacade. It seems like you code against a sub-type of Gacela\Framework\AbstractFacade such as anonymous//tests/Benchma...stractFacadeBench.php$3 or anonymous//tests/Integra...lobalServicesTest.php$3. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

65
            $this->facade->/** @scrutinizer ignore-call */ 
66
                           getSomething()
Loading history...
66
        );
67
    }
68
}
69