Passed
Push — main ( 3b40c1...b711d3 )
by Peter
07:24
created

FileFinderBootstrapperTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
namespace AbterPhp\Framework\Bootstrappers\Filesystem;
4
5
use AbterPhp\Framework\Constant\Env;
6
use AbterPhp\Framework\Environments\Environment;
7
use AbterPhp\Framework\Filesystem\FileFinder;
8
use AbterPhp\Framework\Filesystem\IFileFinder;
9
use AbterPhp\Framework\Module\Manager;
10
use Opulence\Ioc\Container;
11
use PHPUnit\Framework\TestCase;
12
13
class FileFinderBootstrapperTest extends TestCase
14
{
15
    /** @var FileFinderBootstrapper */
16
    protected FileFinderBootstrapper $sut;
17
18
    protected Manager $moduleManagerMock;
19
20
    public function setUp(): void
21
    {
22
        global $abterModuleManager;
23
24
        $this->sut = new FileFinderBootstrapper();
25
26
        $this->moduleManagerMock = $this->getMockBuilder(Manager::class)->disableOriginalConstructor()->getMock();
27
28
        $abterModuleManager = $this->moduleManagerMock;
29
    }
30
31
    public function tearDown(): void
32
    {
33
        global $abterModuleManager;
34
35
        Environment::unsetVar(Env::DIR_PUBLIC);
36
37
        $abterModuleManager = null;
38
    }
39
40
    public function testRegisterBindings()
41
    {
42
        Environment::setVar(Env::DIR_PUBLIC, '/tmp/foo');
43
44
        $assetsPaths = ['foo' => ['bar']];
45
46
        $this->moduleManagerMock->expects($this->once())->method('getAssetsPaths')->willReturn($assetsPaths);
0 ignored issues
show
Bug introduced by
The method expects() does not exist on AbterPhp\Framework\Module\Manager. ( Ignorable by Annotation )

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

46
        $this->moduleManagerMock->/** @scrutinizer ignore-call */ 
47
                                  expects($this->once())->method('getAssetsPaths')->willReturn($assetsPaths);

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...
47
48
        $container = new Container();
49
50
        $this->sut->registerBindings($container);
51
52
        $actual = $container->resolve(FileFinder::class);
53
        $this->assertInstanceOf(FileFinder::class, $actual);
54
55
        $actual = $container->resolve(IFileFinder::class);
56
        $this->assertInstanceOf(IFileFinder::class, $actual);
57
    }
58
}
59