ModuleTest::provideServiceList()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.2
c 0
b 0
f 0
cc 4
eloc 9
nc 2
nop 0
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