10
10
11
11
class BaseConfigTest extends CIUnitTestCase
12
12
{
13
-
14
13
protected $ fixturesFolder ;
15
14
16
- //--------------------------------------------------------------------
17
-
18
15
protected function setUp (): void
19
16
{
20
17
parent ::setUp ();
@@ -37,21 +34,16 @@ protected function setUp(): void
37
34
}
38
35
}
39
36
40
- //--------------------------------------------------------------------
41
-
42
37
public function testBasicValues ()
43
38
{
44
39
$ dotenv = new DotEnv ($ this ->fixturesFolder , '.env ' );
45
40
$ dotenv ->load ();
46
41
$ config = new SimpleConfig ();
47
42
48
- $ this ->assertEquals ('bar ' , $ config ->FOO );
49
- // empty treated as boolean false
50
- $ this ->assertEquals (false , $ config ->echo );
51
- // 'true' should be treated as boolean true
43
+ $ this ->assertNull ($ config ->FOO );
44
+ $ this ->assertSame ('' , $ config ->echo );
52
45
$ this ->assertTrue ($ config ->foxtrot );
53
- // numbers should be treated properly
54
- $ this ->assertEquals (18 , $ config ->golf );
46
+ $ this ->assertSame (18 , $ config ->golf );
55
47
}
56
48
57
49
/**
@@ -68,12 +60,10 @@ public function testServerValues()
68
60
$ dotenv ->load ();
69
61
$ config = new SimpleConfig ();
70
62
71
- $ this ->assertEquals ( 123 , $ config ->shortie );
72
- $ this ->assertEquals ( 456 , $ config ->longie );
63
+ $ this ->assertSame ( ' 123 ' , $ config ->shortie );
64
+ $ this ->assertSame ( ' 456 ' , $ config ->longie );
73
65
}
74
66
75
- //--------------------------------------------------------------------
76
-
77
67
public function testEnvironmentOverrides ()
78
68
{
79
69
$ dotenv = new DotEnv ($ this ->fixturesFolder , '.env ' );
@@ -82,81 +72,69 @@ public function testEnvironmentOverrides()
82
72
$ config = new SimpleConfig ();
83
73
84
74
// override config with ENV var
85
- $ this ->assertEquals ('pow ' , $ config ->alpha );
75
+ $ this ->assertSame ('pow ' , $ config ->alpha );
86
76
// config should not be over-written by wrongly named ENV var
87
- $ this ->assertEquals ('three ' , $ config ->charlie );
77
+ $ this ->assertSame ('three ' , $ config ->charlie );
88
78
// override config with shortPrefix ENV var
89
- $ this ->assertEquals ('hubbahubba ' , $ config ->delta );
79
+ $ this ->assertSame ('hubbahubba ' , $ config ->delta );
90
80
// incorrect env name should not inject property
91
81
$ this ->assertObjectNotHasAttribute ('notthere ' , $ config );
92
- // same ENV var as property, but not namespaced, still over-rides
93
- $ this ->assertEquals ('kazaam ' , $ config ->bravo );
94
82
// empty ENV var should not affect config setting
95
- $ this ->assertEquals ('pineapple ' , $ config ->fruit );
83
+ $ this ->assertSame ('pineapple ' , $ config ->fruit );
96
84
// non-empty ENV var should overrideconfig setting
97
- $ this ->assertEquals ('banana ' , $ config ->dessert );
85
+ $ this ->assertSame ('banana ' , $ config ->dessert );
98
86
// null property should not be affected
99
87
$ this ->assertNull ($ config ->QEMPTYSTR );
100
88
}
101
89
102
- //--------------------------------------------------------------------
103
-
104
90
public function testPrefixedValues ()
105
91
{
106
92
$ dotenv = new DotEnv ($ this ->fixturesFolder , '.env ' );
107
93
$ dotenv ->load ();
108
94
109
95
$ config = new SimpleConfig ();
110
96
111
- $ this ->assertEquals ('baz ' , $ config ->onedeep );
97
+ $ this ->assertSame ('baz ' , $ config ->onedeep );
112
98
}
113
99
114
- //--------------------------------------------------------------------
115
-
116
100
public function testPrefixedArrayValues ()
117
101
{
118
102
$ dotenv = new DotEnv ($ this ->fixturesFolder , '.env ' );
119
103
$ dotenv ->load ();
120
104
121
105
$ config = new SimpleConfig ();
122
106
123
- $ this ->assertEquals ('ci4 ' , $ config ->default ['name ' ]);
124
- $ this ->assertEquals ('Malcolm ' , $ config ->crew ['captain ' ]);
125
- $ this ->assertEquals ('Spock ' , $ config ->crew ['science ' ]);
126
- $ this ->assertFalse ( array_key_exists ( 'pilot ' , $ config ->crew ) );
107
+ $ this ->assertSame ('ci4 ' , $ config ->default ['name ' ]);
108
+ $ this ->assertSame ('Malcolm ' , $ config ->crew ['captain ' ]);
109
+ $ this ->assertSame ('Spock ' , $ config ->crew ['science ' ]);
110
+ $ this ->assertArrayNotHasKey ( 'pilot ' , $ config ->crew );
127
111
$ this ->assertTrue ($ config ->crew ['comms ' ]);
128
112
$ this ->assertFalse ($ config ->crew ['doctor ' ]);
129
113
}
130
114
131
- //--------------------------------------------------------------------
132
-
133
115
public function testArrayValues ()
134
116
{
135
117
$ dotenv = new DotEnv ($ this ->fixturesFolder , '.env ' );
136
118
$ dotenv ->load ();
137
119
138
120
$ config = new SimpleConfig ();
139
121
140
- $ this ->assertEquals ('complex ' , $ config ->simple ['name ' ]);
141
- $ this ->assertEquals ('foo ' , $ config ->first );
142
- $ this ->assertEquals ('bar ' , $ config ->second );
122
+ $ this ->assertSame ('complex ' , $ config ->simple ['name ' ]);
123
+ $ this ->assertSame ('foo ' , $ config ->first );
124
+ $ this ->assertSame ('bar ' , $ config ->second );
143
125
}
144
126
145
- //--------------------------------------------------------------------
146
-
147
127
public function testSetsDefaultValues ()
148
128
{
149
129
$ dotenv = new DotEnv ($ this ->fixturesFolder , 'commented.env ' );
150
130
$ dotenv ->load ();
151
131
152
132
$ config = new SimpleConfig ();
153
133
154
- $ this ->assertEquals ('foo ' , $ config ->first );
155
- $ this ->assertEquals ('bar ' , $ config ->second );
134
+ $ this ->assertSame ('foo ' , $ config ->first );
135
+ $ this ->assertSame ('bar ' , $ config ->second );
156
136
}
157
137
158
- //--------------------------------------------------------------------
159
-
160
138
/**
161
139
* @runInSeparateProcess
162
140
* @preserveGlobalState disabled
@@ -168,12 +146,10 @@ public function testSetsDefaultValuesEncryptionUsingHex2Bin()
168
146
$ config = new Encryption ();
169
147
170
148
// override config with ENV var
171
- $ this ->assertEquals ('f699c7fd18a8e082d0228932f3acd40e1ef5ef92efcedda32842a211d62f0aa6 ' , bin2hex ($ config ->key ));
172
- $ this ->assertEquals ('OpenSSL ' , $ config ->driver );
149
+ $ this ->assertSame ('f699c7fd18a8e082d0228932f3acd40e1ef5ef92efcedda32842a211d62f0aa6 ' , bin2hex ($ config ->key ));
150
+ $ this ->assertSame ('OpenSSL ' , $ config ->driver );
173
151
}
174
152
175
- //--------------------------------------------------------------------
176
-
177
153
/**
178
154
* @runInSeparateProcess
179
155
* @preserveGlobalState disabled
@@ -184,37 +160,31 @@ public function testSetDefaultValuesEncryptionUsingBase64()
184
160
$ dotenv ->load ();
185
161
$ config = new Encryption ('base64 ' );
186
162
187
- $ this ->assertEquals ('L40bKo6b8Nu541LeVeZ1i5RXfGgnkar42CPTfukhGhw= ' , base64_encode ($ config ->key ));
188
- $ this ->assertEquals ('OpenSSL ' , $ config ->driver );
163
+ $ this ->assertSame ('L40bKo6b8Nu541LeVeZ1i5RXfGgnkar42CPTfukhGhw= ' , base64_encode ($ config ->key ));
164
+ $ this ->assertSame ('OpenSSL ' , $ config ->driver );
189
165
}
190
166
191
- //--------------------------------------------------------------------
192
-
193
167
public function testSetsDefaultValuesHex2Bin ()
194
168
{
195
169
$ dotenv = new DotEnv ($ this ->fixturesFolder , 'commented.env ' );
196
170
$ dotenv ->load ();
197
171
$ config = new Encryption ();
198
172
199
173
// override config with ENV var
200
- $ this ->assertEquals ('84cf2c0811d5daf9e1c897825a3debce91f9a33391e639f72f7a4740b30675a2 ' , bin2hex ($ config ->key ));
201
- $ this ->assertEquals ('MCrypt ' , $ config ->driver );
174
+ $ this ->assertSame ('84cf2c0811d5daf9e1c897825a3debce91f9a33391e639f72f7a4740b30675a2 ' , bin2hex ($ config ->key ));
175
+ $ this ->assertSame ('MCrypt ' , $ config ->driver );
202
176
}
203
177
204
- //--------------------------------------------------------------------
205
-
206
178
public function testSetDefaultValuesBase64 ()
207
179
{
208
180
$ dotenv = new DotEnv ($ this ->fixturesFolder , 'commented.env ' );
209
181
$ dotenv ->load ();
210
182
$ config = new Encryption ('base64 ' );
211
183
212
- $ this ->assertEquals ('Psf8bUHRh1UJYG2M7e+5ec3MdjpKpzAr0twamcAvOcI= ' , base64_encode ($ config ->key ));
213
- $ this ->assertEquals ('MCrypt ' , $ config ->driver );
184
+ $ this ->assertSame ('Psf8bUHRh1UJYG2M7e+5ec3MdjpKpzAr0twamcAvOcI= ' , base64_encode ($ config ->key ));
185
+ $ this ->assertSame ('MCrypt ' , $ config ->driver );
214
186
}
215
187
216
- //--------------------------------------------------------------------
217
-
218
188
public function testRecognizesLooseValues ()
219
189
{
220
190
$ dotenv = new DotEnv ($ this ->fixturesFolder , 'loose.env ' );
@@ -224,12 +194,10 @@ public function testRecognizesLooseValues()
224
194
225
195
$ this ->assertEquals (0 , $ config ->QZERO );
226
196
$ this ->assertSame ('0 ' , $ config ->QZEROSTR );
227
- $ this ->assertEquals (' ' , $ config ->QEMPTYSTR );
197
+ $ this ->assertSame (' ' , $ config ->QEMPTYSTR );
228
198
$ this ->assertFalse ($ config ->QFALSE );
229
199
}
230
200
231
- //--------------------------------------------------------------------
232
-
233
201
public function testRegistrars ()
234
202
{
235
203
$ config = new RegistrarConfig ();
@@ -239,13 +207,13 @@ public function testRegistrars()
239
207
$ method ();
240
208
241
209
// no change to unmodified property
242
- $ this ->assertEquals ('bar ' , $ config ->foo );
210
+ $ this ->assertSame ('bar ' , $ config ->foo );
243
211
// add to an existing array property
244
- $ this ->assertEquals (['baz ' , 'first ' , 'second ' ], $ config ->bar );
212
+ $ this ->assertSame (['baz ' , 'first ' , 'second ' ], $ config ->bar );
245
213
// add a new property
246
- $ this ->assertEquals ('nice ' , $ config ->format );
214
+ $ this ->assertSame ('nice ' , $ config ->format );
247
215
// add a new array property
248
- $ this ->assertEquals (['apple ' , 'banana ' ], $ config ->fruit );
216
+ $ this ->assertSame (['apple ' , 'banana ' ], $ config ->fruit );
249
217
}
250
218
251
219
public function testBadRegistrar ()
@@ -259,7 +227,7 @@ public function testBadRegistrar()
259
227
$ method = $ this ->getPrivateMethodInvoker ($ config , 'registerProperties ' );
260
228
$ method ();
261
229
262
- $ this ->assertEquals ('bar ' , $ config ->foo );
230
+ $ this ->assertSame ('bar ' , $ config ->foo );
263
231
}
264
232
265
233
public function testNotEnabled ()
@@ -274,7 +242,7 @@ public function testNotEnabled()
274
242
$ method = $ this ->getPrivateMethodInvoker ($ config , 'registerProperties ' );
275
243
$ method ();
276
244
277
- $ this ->assertEquals ($ expected , $ config ::$ registrars );
245
+ $ this ->assertSame ($ expected , $ config ::$ registrars );
278
246
}
279
247
280
248
public function testDidDiscovery ()
@@ -289,7 +257,7 @@ public function testDidDiscovery()
289
257
$ method = $ this ->getPrivateMethodInvoker ($ config , 'registerProperties ' );
290
258
$ method ();
291
259
292
- $ this ->assertEquals (true , $ this ->getPrivateProperty ($ config , 'didDiscovery ' ));
260
+ $ this ->assertSame (true , $ this ->getPrivateProperty ($ config , 'didDiscovery ' ));
293
261
}
294
262
295
263
}
0 commit comments