1
1
<?php
2
+
2
3
namespace Sil \PhpEnv \tests ;
3
4
4
5
use PHPUnit \Framework \TestCase ;
@@ -28,6 +29,10 @@ protected function putEnv($setting)
28
29
. 'test: " ' . $ setting . '" '
29
30
);
30
31
}
32
+ list ($ variable , $ value ) = explode ('= ' , $ setting );
33
+ $ variable = trim ($ variable );
34
+ $ value = trim ($ value );
35
+ $ _ENV [$ variable ] = $ value ;
31
36
}
32
37
33
38
public function testGet_notFoundNull ()
@@ -40,7 +45,7 @@ public function testGet_notFoundNull()
40
45
$ actual = Env::get ($ varname );
41
46
42
47
// Assert
43
- $ this -> assertSame ($ expected , $ actual );
48
+ self :: assertSame ($ expected , $ actual );
44
49
}
45
50
46
51
public function testGet_emptyString ()
@@ -54,7 +59,7 @@ public function testGet_emptyString()
54
59
$ actual = Env::get ($ varname );
55
60
56
61
// Assert
57
- $ this -> assertSame (
62
+ self :: assertSame (
58
63
$ expected ,
59
64
$ actual ,
60
65
'Expected to get the default value if only whitespace was found. '
@@ -72,7 +77,7 @@ public function testGet_spacesString()
72
77
$ actual = Env::get ($ varname );
73
78
74
79
// Assert
75
- $ this -> assertSame (
80
+ self :: assertSame (
76
81
$ expected ,
77
82
$ actual ,
78
83
'Expected to get the default value if only whitespace was found. '
@@ -90,7 +95,7 @@ public function testGet_whiteSpaceString()
90
95
$ actual = Env::get ($ varname );
91
96
92
97
// Assert
93
- $ this -> assertSame ($ expected , $ actual );
98
+ self :: assertSame ($ expected , $ actual );
94
99
}
95
100
96
101
public function testGet_false ()
@@ -104,7 +109,7 @@ public function testGet_false()
104
109
$ actual = Env::get ($ varname );
105
110
106
111
// Assert
107
- $ this -> assertSame ($ expected , $ actual );
112
+ self :: assertSame ($ expected , $ actual );
108
113
}
109
114
110
115
public function testGet_falseTitlecase ()
@@ -118,7 +123,7 @@ public function testGet_falseTitlecase()
118
123
$ actual = Env::get ($ varname );
119
124
120
125
// Assert
121
- $ this -> assertSame ($ expected , $ actual );
126
+ self :: assertSame ($ expected , $ actual );
122
127
}
123
128
124
129
public function testGet_falseUppercase ()
@@ -132,7 +137,7 @@ public function testGet_falseUppercase()
132
137
$ actual = Env::get ($ varname );
133
138
134
139
// Assert
135
- $ this -> assertSame ($ expected , $ actual );
140
+ self :: assertSame ($ expected , $ actual );
136
141
}
137
142
138
143
public function testGet_nonEmptyLowercaseString ()
@@ -146,7 +151,7 @@ public function testGet_nonEmptyLowercaseString()
146
151
$ actual = Env::get ($ varname );
147
152
148
153
// Assert
149
- $ this -> assertSame ($ expected , $ actual );
154
+ self :: assertSame ($ expected , $ actual );
150
155
}
151
156
152
157
public function testGet_nonEmptyMixedCaseString ()
@@ -160,7 +165,7 @@ public function testGet_nonEmptyMixedCaseString()
160
165
$ actual = Env::get ($ varname );
161
166
162
167
// Assert
163
- $ this -> assertSame ($ expected , $ actual );
168
+ self :: assertSame ($ expected , $ actual );
164
169
}
165
170
166
171
public function testGet_nonEmptyUppercaseString ()
@@ -174,7 +179,7 @@ public function testGet_nonEmptyUppercaseString()
174
179
$ actual = Env::get ($ varname );
175
180
176
181
// Assert
177
- $ this -> assertSame ($ expected , $ actual );
182
+ self :: assertSame ($ expected , $ actual );
178
183
}
179
184
180
185
public function testGet_notSetHasDefault ()
@@ -188,7 +193,7 @@ public function testGet_notSetHasDefault()
188
193
$ actual = Env::get ($ varname , $ default );
189
194
190
195
// Assert
191
- $ this -> assertSame ($ expected , $ actual );
196
+ self :: assertSame ($ expected , $ actual );
192
197
}
193
198
194
199
public function testGet_notSetNoDefault ()
@@ -201,7 +206,7 @@ public function testGet_notSetNoDefault()
201
206
$ actual = Env::get ($ varname );
202
207
203
208
// Assert
204
- $ this -> assertSame ($ expected , $ actual );
209
+ self :: assertSame ($ expected , $ actual );
205
210
}
206
211
207
212
public function testGet_null ()
@@ -215,7 +220,7 @@ public function testGet_null()
215
220
$ actual = Env::get ($ varname );
216
221
217
222
// Assert
218
- $ this -> assertSame ($ expected , $ actual );
223
+ self :: assertSame ($ expected , $ actual );
219
224
}
220
225
221
226
public function testGet_nullTitlecase ()
@@ -229,7 +234,7 @@ public function testGet_nullTitlecase()
229
234
$ actual = Env::get ($ varname );
230
235
231
236
// Assert
232
- $ this -> assertSame ($ expected , $ actual );
237
+ self :: assertSame ($ expected , $ actual );
233
238
}
234
239
235
240
public function testGet_nullUppercase ()
@@ -243,7 +248,7 @@ public function testGet_nullUppercase()
243
248
$ actual = Env::get ($ varname );
244
249
245
250
// Assert
246
- $ this -> assertSame ($ expected , $ actual );
251
+ self :: assertSame ($ expected , $ actual );
247
252
}
248
253
249
254
public function testGet_true ()
@@ -257,7 +262,7 @@ public function testGet_true()
257
262
$ actual = Env::get ($ varname );
258
263
259
264
// Assert
260
- $ this -> assertSame ($ expected , $ actual );
265
+ self :: assertSame ($ expected , $ actual );
261
266
}
262
267
263
268
public function testGet_trueTitlecase ()
@@ -271,7 +276,7 @@ public function testGet_trueTitlecase()
271
276
$ actual = Env::get ($ varname );
272
277
273
278
// Assert
274
- $ this -> assertSame ($ expected , $ actual );
279
+ self :: assertSame ($ expected , $ actual );
275
280
}
276
281
277
282
public function testGet_trueUppercase ()
@@ -285,7 +290,7 @@ public function testGet_trueUppercase()
285
290
$ actual = Env::get ($ varname );
286
291
287
292
// Assert
288
- $ this -> assertSame ($ expected , $ actual );
293
+ self :: assertSame ($ expected , $ actual );
289
294
}
290
295
291
296
public function testRequireEnv_exists ()
@@ -299,7 +304,7 @@ public function testRequireEnv_exists()
299
304
$ actual = Env::requireEnv ($ varname );
300
305
301
306
// Assert
302
- $ this -> assertSame ($ expected , $ actual );
307
+ self :: assertSame ($ expected , $ actual );
303
308
}
304
309
305
310
public function testRequireEnv_notfound ()
@@ -340,7 +345,7 @@ public function testGetArray_notFound()
340
345
$ actual = Env::getArray ($ varname );
341
346
342
347
// Assert
343
- $ this -> assertSame ($ expected , $ actual );
348
+ self :: assertSame ($ expected , $ actual );
344
349
}
345
350
346
351
public function testGetArray_existsButNoValue ()
@@ -354,7 +359,7 @@ public function testGetArray_existsButNoValue()
354
359
$ actual = Env::getArray ($ varname );
355
360
356
361
// Assert
357
- $ this -> assertSame ($ expected , $ actual );
362
+ self :: assertSame ($ expected , $ actual );
358
363
}
359
364
360
365
public function testGetArray_existsButNoValueHasDefault ()
@@ -369,7 +374,7 @@ public function testGetArray_existsButNoValueHasDefault()
369
374
$ actual = Env::getArray ($ varname , $ default );
370
375
371
376
// Assert
372
- $ this -> assertSame ($ expected , $ actual );
377
+ self :: assertSame ($ expected , $ actual );
373
378
}
374
379
375
380
public function testGetArray_1exists ()
@@ -383,7 +388,7 @@ public function testGetArray_1exists()
383
388
$ actual = Env::getArray ($ varname );
384
389
385
390
// Assert
386
- $ this -> assertSame ($ expected , $ actual );
391
+ self :: assertSame ($ expected , $ actual );
387
392
}
388
393
389
394
public function testGetArray_multiExists ()
@@ -397,7 +402,7 @@ public function testGetArray_multiExists()
397
402
$ actual = Env::getArray ($ varname );
398
403
399
404
// Assert
400
- $ this -> assertSame ($ expected , $ actual );
405
+ self :: assertSame ($ expected , $ actual );
401
406
}
402
407
403
408
public function testGetArray_multiEmptyExists ()
@@ -411,7 +416,7 @@ public function testGetArray_multiEmptyExists()
411
416
$ actual = Env::getArray ($ varname );
412
417
413
418
// Assert
414
- $ this -> assertSame ($ expected , $ actual );
419
+ self :: assertSame ($ expected , $ actual );
415
420
}
416
421
417
422
public function testGetArray_existsWithDefault ()
@@ -426,7 +431,7 @@ public function testGetArray_existsWithDefault()
426
431
$ actual = Env::getArray ($ varname , $ default );
427
432
428
433
// Assert
429
- $ this -> assertSame ($ expected , $ actual );
434
+ self :: assertSame ($ expected , $ actual );
430
435
}
431
436
432
437
public function testGetArray_notFoundWithDefault ()
@@ -440,7 +445,7 @@ public function testGetArray_notFoundWithDefault()
440
445
$ actual = Env::getArray ($ varname , $ default );
441
446
442
447
// Assert
443
- $ this -> assertSame ($ expected , $ actual );
448
+ self :: assertSame ($ expected , $ actual );
444
449
}
445
450
446
451
public function testGetArray_existsWithInvalidDefaultType ()
@@ -481,7 +486,7 @@ public function testGetArray_notFoundWithNullDefault()
481
486
$ actual = Env::getArray ($ varname , null );
482
487
483
488
// Assert
484
- $ this -> assertNull ($ actual );
489
+ self :: assertNull ($ actual );
485
490
}
486
491
487
492
public function testGetArrayFromPrefix_multiple ()
@@ -500,7 +505,7 @@ public function testGetArrayFromPrefix_multiple()
500
505
'fourthOne ' => null ,
501
506
'andAFifth ' => '123 ' ,
502
507
];
503
-
508
+
504
509
// Act
505
510
try {
506
511
$ actual = Env::getArrayFromPrefix ($ prefix );
@@ -509,7 +514,7 @@ public function testGetArrayFromPrefix_multiple()
509
514
}
510
515
511
516
// Assert
512
- $ this -> assertSame ($ expected , $ actual );
517
+ self :: assertSame ($ expected , $ actual );
513
518
}
514
519
515
520
public function testGetArrayFromPrefix_notFound ()
@@ -526,7 +531,7 @@ public function testGetArrayFromPrefix_notFound()
526
531
}
527
532
528
533
// Assert
529
- $ this -> assertSame ($ expected , $ actual );
534
+ self :: assertSame ($ expected , $ actual );
530
535
}
531
536
532
537
public function testGetArrayFromPrefix_one ()
@@ -546,7 +551,7 @@ public function testGetArrayFromPrefix_one()
546
551
}
547
552
548
553
// Assert
549
- $ this -> assertSame ($ expected , $ actual );
554
+ self :: assertSame ($ expected , $ actual );
550
555
}
551
556
552
557
public function testRequireArray_exists ()
@@ -560,7 +565,7 @@ public function testRequireArray_exists()
560
565
$ actual = Env::requireArray ($ varname );
561
566
562
567
// Assert
563
- $ this -> assertSame ($ expected , $ actual );
568
+ self :: assertSame ($ expected , $ actual );
564
569
}
565
570
566
571
public function testRequireArray_notfound ()
0 commit comments