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

FlashServiceBootstrapperTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 30
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 3 1
A setUp() 0 3 1
A testRegisterBindings() 0 15 1
1
<?php
2
3
namespace AbterPhp\Framework\Bootstrappers\Session;
4
5
use AbterPhp\Framework\Constant\Env;
6
use AbterPhp\Framework\Environments\Environment;
7
use AbterPhp\Framework\I18n\ITranslator;
8
use AbterPhp\Framework\Session\FlashService;
9
use Opulence\Ioc\Container;
10
use Opulence\Sessions\ISession;
11
use PHPUnit\Framework\TestCase;
12
13
class FlashServiceBootstrapperTest extends TestCase
14
{
15
    /** @var FlashServiceBootstrapper */
16
    protected FlashServiceBootstrapper $sut;
17
18
    public function setUp(): void
19
    {
20
        $this->sut = new FlashServiceBootstrapper();
21
    }
22
23
    protected function tearDown(): void
24
    {
25
        Environment::unsetVar(Env::ENV_NAME);
26
    }
27
28
    public function testRegisterBindings()
29
    {
30
        Environment::setVar(Env::ENV_NAME, 'foo');
31
32
        $sessionMock    = $this->getMockBuilder(ISession::class)->getMock();
33
        $translatorMock = $this->getMockBuilder(ITranslator::class)->getMock();
34
35
        $container = new Container();
36
        $container->bindInstance(ISession::class, $sessionMock);
37
        $container->bindInstance(ITranslator::class, $translatorMock);
38
39
        $this->sut->registerBindings($container);
40
41
        $action = $container->resolve(FlashService::class);
42
        $this->assertInstanceOf(FlashService::class, $action);
43
    }
44
}
45