Skip to content

Commit 8c594b4

Browse files
authored
Merge pull request #31 from silinternational/feature/update-phpunit
Update phpunit
2 parents 371666a + 38d2e1f commit 8c594b4

File tree

3 files changed

+40
-38
lines changed

3 files changed

+40
-38
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"psr-4": {"Sil\\PhpEnv\\": "src/"}
88
},
99
"require": {
10-
"php": "^7.4 || ^8.0"
10+
"php": "^8.0"
1111
},
1212
"require-dev": {
13-
"phpunit/phpunit": "^9.0"
13+
"phpunit/phpunit": "^12.0"
1414
}
1515
}

tests/phpunit.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<phpunit bootstrap="bootstrap.php"
22
colors="false"
3-
convertErrorsToExceptions="true"
4-
convertNoticesToExceptions="true"
5-
convertWarningsToExceptions="true"
63
processIsolation="true"
74
stopOnFailure="false">
85

tests/unit/EnvTest.php

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Sil\PhpEnv\tests;
34

45
use PHPUnit\Framework\TestCase;
@@ -28,6 +29,10 @@ protected function putEnv($setting)
2829
. 'test: "' . $setting . '"'
2930
);
3031
}
32+
list ($variable, $value) = explode('=', $setting);
33+
$variable = trim($variable);
34+
$value = trim($value);
35+
$_ENV[$variable] = $value;
3136
}
3237

3338
public function testGet_notFoundNull()
@@ -40,7 +45,7 @@ public function testGet_notFoundNull()
4045
$actual = Env::get($varname);
4146

4247
// Assert
43-
$this->assertSame($expected, $actual);
48+
self::assertSame($expected, $actual);
4449
}
4550

4651
public function testGet_emptyString()
@@ -54,7 +59,7 @@ public function testGet_emptyString()
5459
$actual = Env::get($varname);
5560

5661
// Assert
57-
$this->assertSame(
62+
self::assertSame(
5863
$expected,
5964
$actual,
6065
'Expected to get the default value if only whitespace was found.'
@@ -72,7 +77,7 @@ public function testGet_spacesString()
7277
$actual = Env::get($varname);
7378

7479
// Assert
75-
$this->assertSame(
80+
self::assertSame(
7681
$expected,
7782
$actual,
7883
'Expected to get the default value if only whitespace was found.'
@@ -90,7 +95,7 @@ public function testGet_whiteSpaceString()
9095
$actual = Env::get($varname);
9196

9297
// Assert
93-
$this->assertSame($expected, $actual);
98+
self::assertSame($expected, $actual);
9499
}
95100

96101
public function testGet_false()
@@ -104,7 +109,7 @@ public function testGet_false()
104109
$actual = Env::get($varname);
105110

106111
// Assert
107-
$this->assertSame($expected, $actual);
112+
self::assertSame($expected, $actual);
108113
}
109114

110115
public function testGet_falseTitlecase()
@@ -118,7 +123,7 @@ public function testGet_falseTitlecase()
118123
$actual = Env::get($varname);
119124

120125
// Assert
121-
$this->assertSame($expected, $actual);
126+
self::assertSame($expected, $actual);
122127
}
123128

124129
public function testGet_falseUppercase()
@@ -132,7 +137,7 @@ public function testGet_falseUppercase()
132137
$actual = Env::get($varname);
133138

134139
// Assert
135-
$this->assertSame($expected, $actual);
140+
self::assertSame($expected, $actual);
136141
}
137142

138143
public function testGet_nonEmptyLowercaseString()
@@ -146,7 +151,7 @@ public function testGet_nonEmptyLowercaseString()
146151
$actual = Env::get($varname);
147152

148153
// Assert
149-
$this->assertSame($expected, $actual);
154+
self::assertSame($expected, $actual);
150155
}
151156

152157
public function testGet_nonEmptyMixedCaseString()
@@ -160,7 +165,7 @@ public function testGet_nonEmptyMixedCaseString()
160165
$actual = Env::get($varname);
161166

162167
// Assert
163-
$this->assertSame($expected, $actual);
168+
self::assertSame($expected, $actual);
164169
}
165170

166171
public function testGet_nonEmptyUppercaseString()
@@ -174,7 +179,7 @@ public function testGet_nonEmptyUppercaseString()
174179
$actual = Env::get($varname);
175180

176181
// Assert
177-
$this->assertSame($expected, $actual);
182+
self::assertSame($expected, $actual);
178183
}
179184

180185
public function testGet_notSetHasDefault()
@@ -188,7 +193,7 @@ public function testGet_notSetHasDefault()
188193
$actual = Env::get($varname, $default);
189194

190195
// Assert
191-
$this->assertSame($expected, $actual);
196+
self::assertSame($expected, $actual);
192197
}
193198

194199
public function testGet_notSetNoDefault()
@@ -201,7 +206,7 @@ public function testGet_notSetNoDefault()
201206
$actual = Env::get($varname);
202207

203208
// Assert
204-
$this->assertSame($expected, $actual);
209+
self::assertSame($expected, $actual);
205210
}
206211

207212
public function testGet_null()
@@ -215,7 +220,7 @@ public function testGet_null()
215220
$actual = Env::get($varname);
216221

217222
// Assert
218-
$this->assertSame($expected, $actual);
223+
self::assertSame($expected, $actual);
219224
}
220225

221226
public function testGet_nullTitlecase()
@@ -229,7 +234,7 @@ public function testGet_nullTitlecase()
229234
$actual = Env::get($varname);
230235

231236
// Assert
232-
$this->assertSame($expected, $actual);
237+
self::assertSame($expected, $actual);
233238
}
234239

235240
public function testGet_nullUppercase()
@@ -243,7 +248,7 @@ public function testGet_nullUppercase()
243248
$actual = Env::get($varname);
244249

245250
// Assert
246-
$this->assertSame($expected, $actual);
251+
self::assertSame($expected, $actual);
247252
}
248253

249254
public function testGet_true()
@@ -257,7 +262,7 @@ public function testGet_true()
257262
$actual = Env::get($varname);
258263

259264
// Assert
260-
$this->assertSame($expected, $actual);
265+
self::assertSame($expected, $actual);
261266
}
262267

263268
public function testGet_trueTitlecase()
@@ -271,7 +276,7 @@ public function testGet_trueTitlecase()
271276
$actual = Env::get($varname);
272277

273278
// Assert
274-
$this->assertSame($expected, $actual);
279+
self::assertSame($expected, $actual);
275280
}
276281

277282
public function testGet_trueUppercase()
@@ -285,7 +290,7 @@ public function testGet_trueUppercase()
285290
$actual = Env::get($varname);
286291

287292
// Assert
288-
$this->assertSame($expected, $actual);
293+
self::assertSame($expected, $actual);
289294
}
290295

291296
public function testRequireEnv_exists()
@@ -299,7 +304,7 @@ public function testRequireEnv_exists()
299304
$actual = Env::requireEnv($varname);
300305

301306
// Assert
302-
$this->assertSame($expected, $actual);
307+
self::assertSame($expected, $actual);
303308
}
304309

305310
public function testRequireEnv_notfound()
@@ -340,7 +345,7 @@ public function testGetArray_notFound()
340345
$actual = Env::getArray($varname);
341346

342347
// Assert
343-
$this->assertSame($expected, $actual);
348+
self::assertSame($expected, $actual);
344349
}
345350

346351
public function testGetArray_existsButNoValue()
@@ -354,7 +359,7 @@ public function testGetArray_existsButNoValue()
354359
$actual = Env::getArray($varname);
355360

356361
// Assert
357-
$this->assertSame($expected, $actual);
362+
self::assertSame($expected, $actual);
358363
}
359364

360365
public function testGetArray_existsButNoValueHasDefault()
@@ -369,7 +374,7 @@ public function testGetArray_existsButNoValueHasDefault()
369374
$actual = Env::getArray($varname, $default);
370375

371376
// Assert
372-
$this->assertSame($expected, $actual);
377+
self::assertSame($expected, $actual);
373378
}
374379

375380
public function testGetArray_1exists()
@@ -383,7 +388,7 @@ public function testGetArray_1exists()
383388
$actual = Env::getArray($varname);
384389

385390
// Assert
386-
$this->assertSame($expected, $actual);
391+
self::assertSame($expected, $actual);
387392
}
388393

389394
public function testGetArray_multiExists()
@@ -397,7 +402,7 @@ public function testGetArray_multiExists()
397402
$actual = Env::getArray($varname);
398403

399404
// Assert
400-
$this->assertSame($expected, $actual);
405+
self::assertSame($expected, $actual);
401406
}
402407

403408
public function testGetArray_multiEmptyExists()
@@ -411,7 +416,7 @@ public function testGetArray_multiEmptyExists()
411416
$actual = Env::getArray($varname);
412417

413418
// Assert
414-
$this->assertSame($expected, $actual);
419+
self::assertSame($expected, $actual);
415420
}
416421

417422
public function testGetArray_existsWithDefault()
@@ -426,7 +431,7 @@ public function testGetArray_existsWithDefault()
426431
$actual = Env::getArray($varname, $default);
427432

428433
// Assert
429-
$this->assertSame($expected, $actual);
434+
self::assertSame($expected, $actual);
430435
}
431436

432437
public function testGetArray_notFoundWithDefault()
@@ -440,7 +445,7 @@ public function testGetArray_notFoundWithDefault()
440445
$actual = Env::getArray($varname, $default);
441446

442447
// Assert
443-
$this->assertSame($expected, $actual);
448+
self::assertSame($expected, $actual);
444449
}
445450

446451
public function testGetArray_existsWithInvalidDefaultType()
@@ -481,7 +486,7 @@ public function testGetArray_notFoundWithNullDefault()
481486
$actual = Env::getArray($varname, null);
482487

483488
// Assert
484-
$this->assertNull($actual);
489+
self::assertNull($actual);
485490
}
486491

487492
public function testGetArrayFromPrefix_multiple()
@@ -500,7 +505,7 @@ public function testGetArrayFromPrefix_multiple()
500505
'fourthOne' => null,
501506
'andAFifth' => '123',
502507
];
503-
508+
504509
// Act
505510
try {
506511
$actual = Env::getArrayFromPrefix($prefix);
@@ -509,7 +514,7 @@ public function testGetArrayFromPrefix_multiple()
509514
}
510515

511516
// Assert
512-
$this->assertSame($expected, $actual);
517+
self::assertSame($expected, $actual);
513518
}
514519

515520
public function testGetArrayFromPrefix_notFound()
@@ -526,7 +531,7 @@ public function testGetArrayFromPrefix_notFound()
526531
}
527532

528533
// Assert
529-
$this->assertSame($expected, $actual);
534+
self::assertSame($expected, $actual);
530535
}
531536

532537
public function testGetArrayFromPrefix_one()
@@ -546,7 +551,7 @@ public function testGetArrayFromPrefix_one()
546551
}
547552

548553
// Assert
549-
$this->assertSame($expected, $actual);
554+
self::assertSame($expected, $actual);
550555
}
551556

552557
public function testRequireArray_exists()
@@ -560,7 +565,7 @@ public function testRequireArray_exists()
560565
$actual = Env::requireArray($varname);
561566

562567
// Assert
563-
$this->assertSame($expected, $actual);
568+
self::assertSame($expected, $actual);
564569
}
565570

566571
public function testRequireArray_notfound()

0 commit comments

Comments
 (0)