ModuleTest   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 58
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetConfigReturnsValidConfig() 0 7 1
A provideServiceList() 0 13 4
A testService() 0 6 1
A provideControllerPluginList() 0 13 4
A testControllerPlugin() 0 6 1
1
<?php
2
/**
3
 * MtMail - e-mail module for Zend Framework
4
 *
5
 * @link      http://github.com/mtymek/MtMail
6
 * @copyright Copyright (c) 2013-2017 Mateusz Tymek
7
 * @license   BSD 2-Clause
8
 */
9
10
namespace MtMailTest;
11
12
use MtMail\Module;
13
use PHPUnit\Framework\TestCase;
14
15
class ModuleTest extends TestCase
16
{
17
    public function testGetConfigReturnsValidConfig()
18
    {
19
        $module = new Module();
20
        $config = $module->getConfig();
21
        $this->assertInternalType('array', $config);
22
        $this->assertArrayHasKey('mt_mail', $config);
23
    }
24
25
    public function provideServiceList()
26
    {
27
        $config = include __DIR__ . '/../../config/module.config.php';
28
        $serviceConfig = array_merge(
29
            isset($config['service_manager']['factories'])?$config['service_manager']['factories']:[],
30
            isset($config['service_manager']['invokables'])?$config['service_manager']['invokables']:[]
31
        );
32
        $services = [];
33
        foreach ($serviceConfig as $key => $val) {
34
            $services[] = [$key];
35
        }
36
        return $services;
37
    }
38
39
    /**
40
     * @dataProvider provideServiceList
41
     */
42
    public function testService($service)
43
    {
44
        $sm = Bootstrap::getServiceManager();
45
        $this->assertTrue($sm->has($service));
46
        $this->assertInstanceOf($service, $sm->get($service));
47
    }
48
49
    public function provideControllerPluginList()
50
    {
51
        $config = include __DIR__ . '/../../config/module.config.php';
52
        $serviceConfig = array_merge(
53
            isset($config['controller_plugins']['factories'])?$config['controller_plugins']['factories']:[],
54
            isset($config['controller_plugins']['invokables'])?$config['controller_plugins']['invokables']:[]
55
        );
56
        $services = [];
57
        foreach ($serviceConfig as $key => $val) {
58
            $services[] = [$key];
59
        }
60
        return $services;
61
    }
62
63
    /**
64
     * @dataProvider provideControllerPluginList
65
     */
66
    public function testControllerPlugin($plugin)
67
    {
68
        $sm = Bootstrap::getServiceManager()->get('ControllerPluginManager');
69
        $this->assertTrue($sm->has($plugin));
70
        $this->assertInstanceOf('MtMail\Controller\Plugin\\' . $plugin, $sm->get($plugin));
71
    }
72
}
73