Passed
Push — master ( 562d32...d311da )
by Gabriel
01:39
created

test_getProvider_with_string()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 4
c 1
b 1
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Nip\Container\Tests\ServiceProviders;
4
5
use Nip\Container\Container;
6
use Nip\Container\ServiceProviders\ProviderRepository;
7
use Nip\Container\Tests\AbstractTest;
8
use Nip\Container\Tests\Fixtures\DemoServiceProvider;
9
10
/**
11
 * Class ProviderRepositoryTest
12
 * @package Nip\Container\Tests\ServiceProviders
13
 */
14
class ProviderRepositoryTest extends AbstractTest
15
{
16
    public function test_getProvider_not_exists()
17
    {
18
        $repository = new ProviderRepository();
19
        self::assertNull($repository->getProvider('NotFound'));
20
    }
21
22
    public function test_getProvider_with_string()
23
    {
24
        $repository = new ProviderRepository();
25
        $repository->setContainer(new Container());
26
        $repository->add(DemoServiceProvider::class);
27
        self::assertInstanceOf(DemoServiceProvider::class, $repository->getProvider(DemoServiceProvider::class));
28
    }
29
30
    public function test_getProvider_with_object()
31
    {
32
        $repository = new ProviderRepository();
33
        $repository->setContainer(new Container());
34
        $provider = new DemoServiceProvider();
35
        $repository->add($provider);
36
        $providerReturned = $repository->getProvider($provider);
37
        self::assertSame($providerReturned, $provider);
38
    }
39
}