Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"psr-4": {"Sil\\PhpEnv\\": "src/"}
},
"require": {
"php": "^7.4 || ^8.0"
"php": "^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0"
"phpunit/phpunit": "^12.0"
}
}
3 changes: 0 additions & 3 deletions tests/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<phpunit bootstrap="bootstrap.php"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false">

Expand Down
71 changes: 38 additions & 33 deletions tests/unit/EnvTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Sil\PhpEnv\tests;

use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -28,6 +29,10 @@ protected function putEnv($setting)
. 'test: "' . $setting . '"'
);
}
list ($variable, $value) = explode('=', $setting);
$variable = trim($variable);
$value = trim($value);
$_ENV[$variable] = $value;
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame(
self::assertSame(
$expected,
$actual,
'Expected to get the default value if only whitespace was found.'
Expand All @@ -72,7 +77,7 @@ public function testGet_spacesString()
$actual = Env::get($varname);

// Assert
$this->assertSame(
self::assertSame(
$expected,
$actual,
'Expected to get the default value if only whitespace was found.'
Expand All @@ -90,7 +95,7 @@ public function testGet_whiteSpaceString()
$actual = Env::get($varname);

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

public function testRequireEnv_notfound()
Expand Down Expand Up @@ -340,7 +345,7 @@ public function testGetArray_notFound()
$actual = Env::getArray($varname);

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

public function testGetArray_existsWithInvalidDefaultType()
Expand Down Expand Up @@ -481,7 +486,7 @@ public function testGetArray_notFoundWithNullDefault()
$actual = Env::getArray($varname, null);

// Assert
$this->assertNull($actual);
self::assertNull($actual);
}

public function testGetArrayFromPrefix_multiple()
Expand All @@ -500,7 +505,7 @@ public function testGetArrayFromPrefix_multiple()
'fourthOne' => null,
'andAFifth' => '123',
];

// Act
try {
$actual = Env::getArrayFromPrefix($prefix);
Expand All @@ -509,7 +514,7 @@ public function testGetArrayFromPrefix_multiple()
}

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

public function testGetArrayFromPrefix_notFound()
Expand All @@ -526,7 +531,7 @@ public function testGetArrayFromPrefix_notFound()
}

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

public function testGetArrayFromPrefix_one()
Expand All @@ -546,7 +551,7 @@ public function testGetArrayFromPrefix_one()
}

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

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

// Assert
$this->assertSame($expected, $actual);
self::assertSame($expected, $actual);
}

public function testRequireArray_notfound()
Expand Down