Passed
Pull Request — main (#333)
by Chema
08:07 queued 04:04
created

FeatureTest::test_unknown_facade_method()   A

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\Gacela;
9
use GacelaTest\Feature\Framework\StaticFacade\ModuleA\Facade as TestFacade;
10
use GacelaTest\Feature\Framework\StaticFacade\ModuleA\Factory as TestFactory;
11
use PHPUnit\Framework\TestCase;
12
13
final class FeatureTest extends TestCase
14
{
15
    protected function setUp(): void
16
    {
17
        Gacela::bootstrap(__DIR__);
18
    }
19
20
    public function test_unknown_facade_method(): void
21
    {
22
        $this->expectException(Error::class);
23
        $this->expectExceptionMessage('Call to undefined method ' . TestFacade::class . '::unknown()');
24
25
        (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

25
        (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...
26
    }
27
28
    public function test_facade_can_create_string(): void
29
    {
30
        $facade = new TestFacade();
31
        $actual = $facade->createString();
32
33
        self::assertSame(TestFactory::STR, $actual);
34
    }
35
36
    public function test_factory_access_is_explicit(): void
37
    {
38
        $facade = new TestFacade();
39
        $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

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