From 1fa778b338a803bee1566972a6171ec76dadcb3b Mon Sep 17 00:00:00 2001 From: flashwave Date: Wed, 31 Jul 2024 19:47:05 +0000 Subject: [PATCH] Removed most of the Environment class and renamed it to just Index as a library meta class. --- VERSION | 2 +- src/Environment.php | 340 -------------------------------------- src/IO/Stream.php | 5 +- src/Index.php | 34 ++++ tests/EnvironmentTest.php | 52 ------ tests/IndexTest.php | 22 +++ 6 files changed, 59 insertions(+), 396 deletions(-) delete mode 100644 src/Environment.php create mode 100644 src/Index.php delete mode 100644 tests/EnvironmentTest.php create mode 100644 tests/IndexTest.php diff --git a/VERSION b/VERSION index f38e5b3..667dcb6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2407.311920 +0.2407.311946 diff --git a/src/Environment.php b/src/Environment.php deleted file mode 100644 index ed07b27..0000000 --- a/src/Environment.php +++ /dev/null @@ -1,340 +0,0 @@ -write($line); - $this->write(Environment::NEWLINE); + $this->write(PHP_EOL); } abstract public function writeChar(string $char): void; diff --git a/src/Index.php b/src/Index.php new file mode 100644 index 0000000..96fb448 --- /dev/null +++ b/src/Index.php @@ -0,0 +1,34 @@ +assertEmpty(Environment::getVariable($varName)); - - Environment::setVariable($varName, 'the'); - $varValue = Environment::getVariable($varName); - $this->assertEquals('the', $varValue); - - Environment::removeVariable($varName); - $this->assertEmpty(Environment::getVariable($varName)); - } - - public function testIndexVersion(): void { - $strVersion = trim(file_get_contents(__DIR__ . '/../VERSION')); - $rawVersion = explode('.', $strVersion); - $version = Environment::getIndexVersion(); - - $this->assertEquals((int)$rawVersion[0], $version->getMajor()); - $this->assertEquals((int)$rawVersion[1], $version->getMinor()); - $this->assertEquals((int)$rawVersion[2], $version->getPatch()); - $this->assertEquals($strVersion, (string)$version); - } - - public function testPHPAndExtVersion(): void { - $version = Environment::getPHPVersion(); - $extVersion = Environment::getPHPExtensionVersion('Core'); - - $this->assertEquals(PHP_MAJOR_VERSION, $version->getMajor()); - $this->assertEquals(PHP_MINOR_VERSION, $version->getMinor()); - $this->assertEquals(PHP_RELEASE_VERSION, $version->getPatch()); - $this->assertTrue($version->equals($extVersion)); - } - - // not really sure how you would test the platform and sapi functions, so i won't -} diff --git a/tests/IndexTest.php b/tests/IndexTest.php new file mode 100644 index 0000000..72c3aa1 --- /dev/null +++ b/tests/IndexTest.php @@ -0,0 +1,22 @@ +assertIsString($expectedVersion); + + $expectedVersion = trim($expectedVersion); + $this->assertEquals($expectedVersion, Index::version()); + } +}