diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CompilerTest.php | 13 | ||||
-rw-r--r-- | tests/DotenvTest.php | 9 | ||||
-rw-r--r-- | tests/ParserTest.php | 5 | ||||
-rw-r--r-- | tests/mocks/MockCompiler.php | 11 | ||||
-rw-r--r-- | tests/mocks/MockParser.php | 7 |
5 files changed, 19 insertions, 26 deletions
diff --git a/tests/CompilerTest.php b/tests/CompilerTest.php index 9a820ec..ed9e757 100644 --- a/tests/CompilerTest.php +++ b/tests/CompilerTest.php @@ -6,7 +6,6 @@ declare(strict_types=1); * @license: MIT */ -use NeonXP\Dotenv\Types\KeyValue; use PHPUnit\Framework\TestCase; /** @@ -29,16 +28,16 @@ class CompilerTest extends TestCase 'KEY4' => 'Test VALUE1 VALUE3 => VALUE3', ]; $compiler = new \NeonXP\Dotenv\Compiler\Compiler(); - $collectionOfKeyValues = []; + $collectionOfarrays = []; foreach ($collection as $key => $value) { - $collectionOfKeyValues[] = new KeyValue($key, $value); + $collectionOfarrays[] = ['key' => $key, 'value' => $value]; } - $compiler->setRawCollection($collectionOfKeyValues); + $compiler->setRawCollection($collectionOfarrays); foreach ($tests as $key => $expected) { - $result = $compiler->compileKeyValue(new KeyValue($key, $collection[$key])); - $this->assertEquals($key, $result->getKey()); - $this->assertEquals($expected, $result->getValue()); + $result = $compiler->compile(['key' => $key, 'value' => $collection[$key]]); + $this->assertEquals($key, $result['key']); + $this->assertEquals($expected, $result['value']); } } }
\ No newline at end of file diff --git a/tests/DotenvTest.php b/tests/DotenvTest.php index 59dd8b0..757ce70 100644 --- a/tests/DotenvTest.php +++ b/tests/DotenvTest.php @@ -11,7 +11,6 @@ use NeonXP\Dotenv\Dotenv; use NeonXP\Dotenv\Exception\RuntimeException; use NeonXP\Dotenv\Loader\LoaderInterface; use NeonXP\Dotenv\Parser\ParserInterface; - use PHPUnit\Framework\TestCase; /** @@ -45,12 +44,8 @@ class DotenvTest extends TestCase { $dotenv = new Dotenv($this->mockLoader, $this->mockParser, $this->mockCompiler); - try { - $dotenv->get('TEST1'); - $this->assertTrue(false, 'Dotenv must throws exception if it not loaded'); - } catch (RuntimeException $exception) { - $this->assertTrue(true, 'Dotenv must throws exception if it not loaded'); - } + $this->expectException(RuntimeException::class); + $dotenv->get('TEST1'); $dotenv->load(); diff --git a/tests/ParserTest.php b/tests/ParserTest.php index 9f13261..c67056b 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -5,6 +5,7 @@ declare(strict_types=1); * @author: Alexander Kiryukhin <alexander@kiryukhin.su> * @license: MIT */ + use NeonXP\Dotenv\Parser\Parser; use PHPUnit\Framework\TestCase; @@ -30,8 +31,8 @@ class ParserTest extends TestCase foreach ($tests as $test => $expected) { $result = $parser->parseLine($test); - $this->assertEquals($expected[0], $result->getKey()); - $this->assertEquals($expected[1], $result->getValue()); + $this->assertEquals($expected[0], $result['key']); + $this->assertEquals($expected[1], $result['value']); } } }
\ No newline at end of file diff --git a/tests/mocks/MockCompiler.php b/tests/mocks/MockCompiler.php index 89db68f..fced5a2 100644 --- a/tests/mocks/MockCompiler.php +++ b/tests/mocks/MockCompiler.php @@ -7,7 +7,6 @@ declare(strict_types=1); */ use NeonXP\Dotenv\Compiler\CompilerInterface; -use NeonXP\Dotenv\Types\KeyValue; /** * Class MockCompiler @@ -16,7 +15,7 @@ class MockCompiler implements CompilerInterface { /** - * @param KeyValue[] $collection + * @param array[] $collection */ function setRawCollection(array $collection): void { @@ -24,11 +23,11 @@ class MockCompiler implements CompilerInterface } /** - * @param KeyValue $keyValue - * @return KeyValue + * @param array $array + * @return array */ - function compileKeyValue(KeyValue $keyValue): KeyValue + function compile(array $array): array { - return $keyValue; + return $array; } }
\ No newline at end of file diff --git a/tests/mocks/MockParser.php b/tests/mocks/MockParser.php index 39c369c..d327f9f 100644 --- a/tests/mocks/MockParser.php +++ b/tests/mocks/MockParser.php @@ -7,7 +7,6 @@ declare(strict_types=1); */ use NeonXP\Dotenv\Parser\ParserInterface; -use NeonXP\Dotenv\Types\KeyValue; /** * Class MockParser @@ -17,12 +16,12 @@ class MockParser implements ParserInterface /** * @param string $line - * @return KeyValue + * @return array */ - public function parseLine(string $line): KeyValue + public function parseLine(string $line): array { list($key, $value) = explode("=", $line); - return new KeyValue($key, $value); + return ['key' => $key, 'value' => $value]; } }
\ No newline at end of file |