Passed
Push — master ( 6e4265...822c3c )
by Gabriel
01:38
created

ModulesManagerTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 4
Bugs 1 Features 2
Metric Value
eloc 14
dl 0
loc 35
rs 10
c 4
b 1
f 2
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A test_getNames() 0 6 1
A test_loadFromConfig() 0 6 1
A prepareConfig() 0 5 1
A test_hasModule() 0 7 1
1
<?php
2
3
namespace Nip\Mvc\Tests\Modules;
4
5
use Nip\Config\Config;
6
use Nip\Container\Container;
7
use Nip\Mvc\Modules\ModulesManager;
8
use Nip\Mvc\Sections\SectionsManager;
9
use Nip\Mvc\Tests\AbstractTest;
10
11
/**
12
 * Class ModulesManagerTest
13
 * @package Nip\Mvc\Tests\Modules
14
 */
15
class ModulesManagerTest extends AbstractTest
16
{
17
    public function test_getNames()
18
    {
19
        $this->prepareConfig();
20
        $manager = new ModulesManager();
21
22
        self::assertSame(['admin', 'frontend', 'api'], $manager->getNames());
23
    }
24
25
    public function test_hasModule()
26
    {
27
        $this->prepareConfig();
28
        $manager = new ModulesManager();
29
30
        self::assertTrue($manager->hasModule('admin'));
31
        self::assertFalse($manager->hasModule('dnf'));
32
    }
33
34
    public function test_loadFromConfig()
35
    {
36
        $this->prepareConfig();
37
        $manager = new ModulesManager();
38
39
        self::assertCount(3, $manager->getModules());
40
    }
41
42
    /**
43
     * @param string $file
44
     */
45
    protected function prepareConfig($file = 'basic')
46
    {
47
        $data = require TEST_FIXTURE_PATH . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . $file . '.php';
48
        $config = new Config(['mvc' => $data]);
49
        Container::getInstance()->set('config', $config);
50
    }
51
}
52