13
13
use PHPUnit_Framework_TestCase as TestCase ;
14
14
use Zend \ServiceManager \AbstractFactory \ConfigAbstractFactory ;
15
15
use Zend \ServiceManager \Exception \InvalidArgumentException ;
16
- use Zend \ServiceManager \Tool \CliTool ;
16
+ use Zend \ServiceManager \Tool \ConfigDumper ;
17
17
use ZendTest \ServiceManager \TestAsset \FailingFactory ;
18
18
use ZendTest \ServiceManager \TestAsset \InvokableObject ;
19
19
use ZendTest \ServiceManager \TestAsset \ObjectWithScalarDependency ;
20
20
use ZendTest \ServiceManager \TestAsset \SecondComplexDependencyObject ;
21
21
use ZendTest \ServiceManager \TestAsset \SimpleDependencyObject ;
22
22
23
- class CliToolTest extends TestCase
23
+ class ConfigDumperTest extends TestCase
24
24
{
25
25
public function testCreateDependencyConfigExceptsIfClassNameIsNotString ()
26
26
{
27
27
self ::expectException (InvalidArgumentException::class);
28
28
self ::expectExceptionMessage ('Class name must be a string, integer given ' );
29
- CliTool ::createDependencyConfig ([], 42 );
29
+ ConfigDumper ::createDependencyConfig ([], 42 );
30
30
}
31
31
32
32
public function testCreateDependencyConfigExceptsIfClassDoesNotExist ()
33
33
{
34
34
$ className = 'Dirk\Gentley\Holistic\Detective\Agency ' ;
35
35
self ::expectException (InvalidArgumentException::class);
36
36
self ::expectExceptionMessage ('Cannot find class with name ' . $ className );
37
- CliTool ::createDependencyConfig ([], $ className );
37
+ ConfigDumper ::createDependencyConfig ([], $ className );
38
38
}
39
39
40
40
public function testCreateDependencyConfigInvokableObjectReturnsEmptyArray ()
41
41
{
42
- $ config = CliTool ::createDependencyConfig ([], InvokableObject::class);
42
+ $ config = ConfigDumper ::createDependencyConfig ([], InvokableObject::class);
43
43
self ::assertEquals (
44
44
[
45
45
ConfigAbstractFactory::class => [
@@ -52,7 +52,7 @@ public function testCreateDependencyConfigInvokableObjectReturnsEmptyArray()
52
52
53
53
public function testCreateDependencyConfigSimpleDependencyReturnsCorrectly ()
54
54
{
55
- $ config = CliTool ::createDependencyConfig ([], SimpleDependencyObject::class);
55
+ $ config = ConfigDumper ::createDependencyConfig ([], SimpleDependencyObject::class);
56
56
self ::assertEquals (
57
57
[
58
58
ConfigAbstractFactory::class => [
@@ -69,7 +69,7 @@ public function testCreateDependencyConfigSimpleDependencyReturnsCorrectly()
69
69
70
70
public function testCreateDependencyConfigClassWithoutConstructorChangesNothing ()
71
71
{
72
- $ config = CliTool ::createDependencyConfig ([ConfigAbstractFactory::class => []], FailingFactory::class);
72
+ $ config = ConfigDumper ::createDependencyConfig ([ConfigAbstractFactory::class => []], FailingFactory::class);
73
73
self ::assertEquals ([ConfigAbstractFactory::class => []], $ config );
74
74
}
75
75
@@ -79,7 +79,7 @@ public function testCreateDependencyConfigWithoutTypeHintedParameterExcepts()
79
79
self ::expectExceptionMessage (
80
80
'Cannot create config for ' . ObjectWithScalarDependency::class . ', it has no type hints in constructor '
81
81
);
82
- $ config = CliTool ::createDependencyConfig (
82
+ $ config = ConfigDumper ::createDependencyConfig (
83
83
[ConfigAbstractFactory::class => []],
84
84
ObjectWithScalarDependency::class
85
85
);
@@ -89,15 +89,15 @@ public function testCreateFactoryMappingsExceptsIfClassNameIsNotString()
89
89
{
90
90
self ::expectException (InvalidArgumentException::class);
91
91
self ::expectExceptionMessage ('Class name must be a string, integer given ' );
92
- CliTool ::createFactoryMappings ([], 42 );
92
+ ConfigDumper ::createFactoryMappings ([], 42 );
93
93
}
94
94
95
95
public function testCreateFactoryMappingsExceptsIfClassDoesNotExist ()
96
96
{
97
97
$ className = 'Dirk\Gentley\Holistic\Detective\Agency ' ;
98
98
self ::expectException (InvalidArgumentException::class);
99
99
self ::expectExceptionMessage ('Cannot find class with name ' . $ className );
100
- CliTool ::createFactoryMappings ([], $ className );
100
+ ConfigDumper ::createFactoryMappings ([], $ className );
101
101
}
102
102
103
103
public function testCreateFactoryMappingsReturnsUnmodifiedArrayIfMappingExists ()
@@ -109,7 +109,7 @@ public function testCreateFactoryMappingsReturnsUnmodifiedArrayIfMappingExists()
109
109
],
110
110
],
111
111
];
112
- self ::assertEquals ($ config , CliTool ::createFactoryMappings ($ config , InvokableObject::class));
112
+ self ::assertEquals ($ config , ConfigDumper ::createFactoryMappings ($ config , InvokableObject::class));
113
113
}
114
114
115
115
public function testCreateFactoryMappingsAddsClassIfNotExists ()
@@ -121,7 +121,7 @@ public function testCreateFactoryMappingsAddsClassIfNotExists()
121
121
],
122
122
],
123
123
];
124
- self ::assertEquals ($ expectedConfig , CliTool ::createFactoryMappings ([], InvokableObject::class));
124
+ self ::assertEquals ($ expectedConfig , ConfigDumper ::createFactoryMappings ([], InvokableObject::class));
125
125
}
126
126
127
127
public function testCreateFactoryMappingsIgnoresExistingsMappings ()
@@ -133,12 +133,12 @@ public function testCreateFactoryMappingsIgnoresExistingsMappings()
133
133
],
134
134
],
135
135
];
136
- self ::assertEquals ($ config , CliTool ::createFactoryMappings ($ config , InvokableObject::class));
136
+ self ::assertEquals ($ config , ConfigDumper ::createFactoryMappings ($ config , InvokableObject::class));
137
137
}
138
138
139
139
public function testCreateFactoryMappingsFromConfigReturnsIfNoConfigKey ()
140
140
{
141
- self ::assertEquals ([], CliTool ::createFactoryMappingsFromConfig ([]));
141
+ self ::assertEquals ([], ConfigDumper ::createFactoryMappingsFromConfig ([]));
142
142
}
143
143
144
144
public function testCreateFactoryMappingsFromConfigExceptsWhenConfigNotArray ()
@@ -148,7 +148,7 @@ public function testCreateFactoryMappingsFromConfigExceptsWhenConfigNotArray()
148
148
'Config key for ' . ConfigAbstractFactory::class . ' should be an array, boolean given '
149
149
);
150
150
151
- CliTool ::createFactoryMappingsFromConfig (
151
+ ConfigDumper ::createFactoryMappingsFromConfig (
152
152
[
153
153
ConfigAbstractFactory::class => true ,
154
154
]
@@ -188,17 +188,17 @@ public function testCreateFactoryMappingsFromConfigWithWorkingConfig()
188
188
],
189
189
];
190
190
191
- self ::assertEquals ($ expectedConfig , CliTool ::createFactoryMappingsFromConfig ($ config ));
191
+ self ::assertEquals ($ expectedConfig , ConfigDumper ::createFactoryMappingsFromConfig ($ config ));
192
192
}
193
193
194
194
/**
195
195
* @depends testCreateDependencyConfigSimpleDependencyReturnsCorrectly
196
196
*/
197
197
public function testDumpConfigFileReturnsContentsForConfigFileUsingUsingClassNotationAndShortArrays (array $ config )
198
198
{
199
- $ formatted = CliTool ::dumpConfigFile ($ config );
199
+ $ formatted = ConfigDumper ::dumpConfigFile ($ config );
200
200
$ this ->assertContains (
201
- '< ' . "?php \n/** \n * This file generated by Zend\ServiceManager\Tool\CliTool . \n" ,
201
+ '< ' . "?php \n/** \n * This file generated by Zend\ServiceManager\Tool\ConfigDumper . \n" ,
202
202
$ formatted
203
203
);
204
204
0 commit comments