FeatureTest::test_factory_access_is_explicit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GacelaTest\Feature\Framework\StaticFacade;
6
7
use Error;
8
use Gacela\Framework\Bootstrap\GacelaConfig;
9
use Gacela\Framework\Gacela;
10
use GacelaTest\Feature\Framework\StaticFacade\ModuleA\Facade as TestFacade;
11
use GacelaTest\Feature\Framework\StaticFacade\ModuleA\Factory as TestFactory;
12
use PHPUnit\Framework\TestCase;
13
14
final class FeatureTest extends TestCase
15
{
16
    protected function setUp(): void
17
    {
18
        Gacela::bootstrap(__DIR__, static function (GacelaConfig $config): void {
19
            $config->resetInMemoryCache();
20
        });
21
    }
22
23
    public function test_unknown_facade_method(): void
24
    {
25
        $this->expectException(Error::class);
26
        $this->expectExceptionMessage('Call to undefined method ' . TestFacade::class . '::unknown()');
27
28
        (new TestFacade())->unknown();
0 ignored issues
show
Bug introduced by
The method unknown() does not exist on GacelaTest\Feature\Frame...icFacade\ModuleA\Facade. ( Ignorable by Annotation )

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

28
        (new TestFacade())->/** @scrutinizer ignore-call */ unknown();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
    }
30
31
    public function test_facade_can_create_string(): void
32
    {
33
        $facade = new TestFacade();
34
        $actual = $facade->createString();
35
36
        self::assertSame(TestFactory::STR, $actual);
37
    }
38
39
    public function test_factory_access_is_explicit(): void
40
    {
41
        $facade = new TestFacade();
42
        $actual = $facade->getFactory()->createString();
0 ignored issues
show
Bug introduced by
The method createString() does not exist on Gacela\Framework\AbstractFactory. It seems like you code against a sub-type of Gacela\Framework\AbstractFactory such as GacelaTest\Benchmark\FileCache\ModuleC\FactoryC or GacelaTest\Benchmark\FileCache\ModuleE\FactoryE or GacelaTest\Benchmark\Fil...\ModuleG\ModuleGFactory or GacelaTest\Benchmark\FileCache\ModuleA\FactoryA or GacelaTest\Feature\Frame...ileCache\Module\Factory or GacelaTest\Feature\Frame...Resolver\Module\Factory or GacelaTest\Benchmark\FileCache\ModuleB\FactoryB or GacelaTest\Benchmark\FileCache\ModuleD\FactoryD or GacelaTest\Benchmark\FileCache\ModuleF\Factory or GacelaTest\Feature\Frame...cFacade\ModuleA\Factory. ( Ignorable by Annotation )

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

42
        $actual = $facade->getFactory()->/** @scrutinizer ignore-call */ createString();
Loading history...
43
44
        self::assertSame(TestFactory::STR, $actual);
45
    }
46
}
47