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
|
|
|
|