SectionsManagerTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 11
dl 0
loc 27
rs 10
c 2
b 1
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_visibleIn() 0 7 1
A test_loadFromConfig() 0 6 1
A prepareConfig() 0 5 1
1
<?php
2
3
namespace Nip\Mvc\Tests\Sections;
4
5
use Nip\Config\Config;
6
use Nip\Container\Container;
7
use Nip\Mvc\Sections\SectionsManager;
8
use Nip\Mvc\Tests\AbstractTest;
9
10
/**
11
 * Class SectionsManagerTest
12
 * @package Nip\Mvc\Tests\Sections
13
 */
14
class SectionsManagerTest extends AbstractTest
15
{
16
    public function test_loadFromConfig()
17
    {
18
        $this->prepareConfig();
19
        $manager = new SectionsManager();
20
21
        self::assertCount(3, $manager->getSections());
22
    }
23
24
    public function test_visibleIn()
25
    {
26
        $this->prepareConfig();
27
        $manager = new SectionsManager();
28
29
        $adminSections = $manager->visibleIn('admin');
30
        self::assertCount(2, $adminSections);
31
    }
32
33
    /**
34
     * @param string $file
35
     */
36
    protected function prepareConfig($file = 'basic')
37
    {
38
        $data = require TEST_FIXTURE_PATH . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . $file . '.php';
39
        $config = new Config(['mvc' => $data]);
40
        Container::getInstance()->set('config', $config);
41
    }
42
}
43