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

ModulesManagerTest::test_hasModule()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 10
c 1
b 0
f 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