22
22
23
23
class ConfigDumperTest extends TestCase
24
24
{
25
+ public function setUp ()
26
+ {
27
+ $ this ->dumper = new ConfigDumper ();
28
+ }
29
+
25
30
public function testCreateDependencyConfigExceptsIfClassNameIsNotString ()
26
31
{
27
32
self ::expectException (InvalidArgumentException::class);
28
33
self ::expectExceptionMessage ('Class name must be a string, integer given ' );
29
- ConfigDumper:: createDependencyConfig ([], 42 );
34
+ $ this -> dumper -> createDependencyConfig ([], 42 );
30
35
}
31
36
32
37
public function testCreateDependencyConfigExceptsIfClassDoesNotExist ()
33
38
{
34
39
$ className = 'Dirk\Gentley\Holistic\Detective\Agency ' ;
35
40
self ::expectException (InvalidArgumentException::class);
36
41
self ::expectExceptionMessage ('Cannot find class with name ' . $ className );
37
- ConfigDumper:: createDependencyConfig ([], $ className );
42
+ $ this -> dumper -> createDependencyConfig ([], $ className );
38
43
}
39
44
40
45
public function testCreateDependencyConfigInvokableObjectReturnsEmptyArray ()
41
46
{
42
- $ config = ConfigDumper:: createDependencyConfig ([], InvokableObject::class);
47
+ $ config = $ this -> dumper -> createDependencyConfig ([], InvokableObject::class);
43
48
self ::assertEquals (
44
49
[
45
50
ConfigAbstractFactory::class => [
@@ -52,7 +57,7 @@ public function testCreateDependencyConfigInvokableObjectReturnsEmptyArray()
52
57
53
58
public function testCreateDependencyConfigSimpleDependencyReturnsCorrectly ()
54
59
{
55
- $ config = ConfigDumper:: createDependencyConfig ([], SimpleDependencyObject::class);
60
+ $ config = $ this -> dumper -> createDependencyConfig ([], SimpleDependencyObject::class);
56
61
self ::assertEquals (
57
62
[
58
63
ConfigAbstractFactory::class => [
@@ -69,7 +74,7 @@ public function testCreateDependencyConfigSimpleDependencyReturnsCorrectly()
69
74
70
75
public function testCreateDependencyConfigClassWithoutConstructorChangesNothing ()
71
76
{
72
- $ config = ConfigDumper:: createDependencyConfig ([ConfigAbstractFactory::class => []], FailingFactory::class);
77
+ $ config = $ this -> dumper -> createDependencyConfig ([ConfigAbstractFactory::class => []], FailingFactory::class);
73
78
self ::assertEquals ([ConfigAbstractFactory::class => []], $ config );
74
79
}
75
80
@@ -79,7 +84,7 @@ public function testCreateDependencyConfigWithoutTypeHintedParameterExcepts()
79
84
self ::expectExceptionMessage (
80
85
'Cannot create config for ' . ObjectWithScalarDependency::class . ', it has no type hints in constructor '
81
86
);
82
- $ config = ConfigDumper:: createDependencyConfig (
87
+ $ config = $ this -> dumper -> createDependencyConfig (
83
88
[ConfigAbstractFactory::class => []],
84
89
ObjectWithScalarDependency::class
85
90
);
@@ -89,15 +94,15 @@ public function testCreateFactoryMappingsExceptsIfClassNameIsNotString()
89
94
{
90
95
self ::expectException (InvalidArgumentException::class);
91
96
self ::expectExceptionMessage ('Class name must be a string, integer given ' );
92
- ConfigDumper:: createFactoryMappings ([], 42 );
97
+ $ this -> dumper -> createFactoryMappings ([], 42 );
93
98
}
94
99
95
100
public function testCreateFactoryMappingsExceptsIfClassDoesNotExist ()
96
101
{
97
102
$ className = 'Dirk\Gentley\Holistic\Detective\Agency ' ;
98
103
self ::expectException (InvalidArgumentException::class);
99
104
self ::expectExceptionMessage ('Cannot find class with name ' . $ className );
100
- ConfigDumper:: createFactoryMappings ([], $ className );
105
+ $ this -> dumper -> createFactoryMappings ([], $ className );
101
106
}
102
107
103
108
public function testCreateFactoryMappingsReturnsUnmodifiedArrayIfMappingExists ()
@@ -109,7 +114,7 @@ public function testCreateFactoryMappingsReturnsUnmodifiedArrayIfMappingExists()
109
114
],
110
115
],
111
116
];
112
- self ::assertEquals ($ config , ConfigDumper:: createFactoryMappings ($ config , InvokableObject::class));
117
+ self ::assertEquals ($ config , $ this -> dumper -> createFactoryMappings ($ config , InvokableObject::class));
113
118
}
114
119
115
120
public function testCreateFactoryMappingsAddsClassIfNotExists ()
@@ -121,7 +126,7 @@ public function testCreateFactoryMappingsAddsClassIfNotExists()
121
126
],
122
127
],
123
128
];
124
- self ::assertEquals ($ expectedConfig , ConfigDumper:: createFactoryMappings ([], InvokableObject::class));
129
+ self ::assertEquals ($ expectedConfig , $ this -> dumper -> createFactoryMappings ([], InvokableObject::class));
125
130
}
126
131
127
132
public function testCreateFactoryMappingsIgnoresExistingsMappings ()
@@ -133,12 +138,12 @@ public function testCreateFactoryMappingsIgnoresExistingsMappings()
133
138
],
134
139
],
135
140
];
136
- self ::assertEquals ($ config , ConfigDumper:: createFactoryMappings ($ config , InvokableObject::class));
141
+ self ::assertEquals ($ config , $ this -> dumper -> createFactoryMappings ($ config , InvokableObject::class));
137
142
}
138
143
139
144
public function testCreateFactoryMappingsFromConfigReturnsIfNoConfigKey ()
140
145
{
141
- self ::assertEquals ([], ConfigDumper:: createFactoryMappingsFromConfig ([]));
146
+ self ::assertEquals ([], $ this -> dumper -> createFactoryMappingsFromConfig ([]));
142
147
}
143
148
144
149
public function testCreateFactoryMappingsFromConfigExceptsWhenConfigNotArray ()
@@ -148,7 +153,7 @@ public function testCreateFactoryMappingsFromConfigExceptsWhenConfigNotArray()
148
153
'Config key for ' . ConfigAbstractFactory::class . ' should be an array, boolean given '
149
154
);
150
155
151
- ConfigDumper:: createFactoryMappingsFromConfig (
156
+ $ this -> dumper -> createFactoryMappingsFromConfig (
152
157
[
153
158
ConfigAbstractFactory::class => true ,
154
159
]
@@ -188,15 +193,15 @@ public function testCreateFactoryMappingsFromConfigWithWorkingConfig()
188
193
],
189
194
];
190
195
191
- self ::assertEquals ($ expectedConfig , ConfigDumper:: createFactoryMappingsFromConfig ($ config ));
196
+ self ::assertEquals ($ expectedConfig , $ this -> dumper -> createFactoryMappingsFromConfig ($ config ));
192
197
}
193
198
194
199
/**
195
200
* @depends testCreateDependencyConfigSimpleDependencyReturnsCorrectly
196
201
*/
197
202
public function testDumpConfigFileReturnsContentsForConfigFileUsingUsingClassNotationAndShortArrays (array $ config )
198
203
{
199
- $ formatted = ConfigDumper:: dumpConfigFile ($ config );
204
+ $ formatted = $ this -> dumper -> dumpConfigFile ($ config );
200
205
$ this ->assertContains (
201
206
'< ' . "?php \n/** \n * This file generated by Zend\ServiceManager\Tool\ConfigDumper. \n" ,
202
207
$ formatted
0 commit comments