ModuleTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 6
c 2
b 0
f 1
lcom 0
cbo 4
dl 0
loc 43
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A provideServiceList() 0 13 4
A testGetConfigReturnsValidConfig() 0 10 1
A testService() 0 6 1
1
<?php
2
3
namespace MtZendeskApiTest;
4
5
use MtZendeskApi\Module;
6
use PHPUnit_Framework_TestCase;
7
8
class ModuleTest extends PHPUnit_Framework_TestCase
9
{
10
    /**
11
     * This test should verify if module configuration works out of the box
12
     */
13
    public function testGetConfigReturnsValidConfig()
14
    {
15
        $module = new Module();
16
        $config = $module->getConfig();
17
        $this->assertInternalType('array', $config);
18
        $this->assertArrayHasKey('zendesk', $config);
19
        $this->assertArrayHasKey('subdomain', $config['zendesk']);
20
        $this->assertArrayHasKey('username', $config['zendesk']);
21
        $this->assertArrayHasKey('token', $config['zendesk']);
22
    }
23
    /**
24
     * Scans service manager configuration, returning all services created by factories and invokables
25
     * @return array
26
     */
27
    public function provideServiceList()
28
    {
29
        $config = include __DIR__ . '/../../config/module.config.php';
30
        $serviceConfig = array_merge(
31
            isset($config['service_manager']['factories'])?$config['service_manager']['factories']:array(),
32
            isset($config['service_manager']['invokables'])?$config['service_manager']['invokables']:array()
33
        );
34
        $services = array();
35
        foreach ($serviceConfig as $key => $val) {
36
            $services[] = array($key);
37
        }
38
        return $services;
39
    }
40
41
    /**
42
     * @dataProvider provideServiceList
43
     */
44
    public function testService($service)
45
    {
46
        $sm = Bootstrap::getServiceManager();
47
        $this->assertTrue($sm->has($service));
48
        $this->assertInstanceOf($service, $sm->get($service));
49
    }
50
}
51