From c1cb92e1207ecbd612459273a3a6253aeda91e0a Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 14 Aug 2024 17:26:23 +0300 Subject: [PATCH] fixed tests and added tests for other application paths. --- tests/Configuration/ConfigurationTest.php | 74 +++++++++++++++++++++-- 1 file changed, 69 insertions(+), 5 deletions(-) diff --git a/tests/Configuration/ConfigurationTest.php b/tests/Configuration/ConfigurationTest.php index 64ff8a9..eb1dcc6 100644 --- a/tests/Configuration/ConfigurationTest.php +++ b/tests/Configuration/ConfigurationTest.php @@ -9,9 +9,18 @@ */ class ConfigurationTest extends TestCase { + const string DEFAULT_ENV_GITHUB_WORKSPACE = '/usr/bin/app'; + const string OTHER_ENV_GITHUB_WORKSPACE = '/app'; + const string OTHER_ENV_BUILD_DIRECTORY_NAME = '.build_directory'; + const string OTHER_ENV_BUILD_FILE_NAME = 'build_file.zip'; + + protected Configuration $configuration; + protected function setUp(): void { + putenv('GITHUB_WORKSPACE=' . self::DEFAULT_ENV_GITHUB_WORKSPACE); + $this->configuration = new Configuration(); } /** @@ -20,30 +29,85 @@ protected function setUp(): void */ public function testCheckDefaultOptionRoot() { + $this->assertEquals( + $this->configuration->get('root'), + self::DEFAULT_ENV_GITHUB_WORKSPACE + ); + } + + /** + * @covers Configuration::get + * @return void + */ + public function testCheckDefaultOptionBuildDirectory() + { + $this->assertEquals( + $this->configuration->get('build.directory'), + self::DEFAULT_ENV_GITHUB_WORKSPACE . '/.build' + ); + } + + /** + * @covers Configuration::get + * @return void + */ + public function testCheckDefaultOptionBuildFile() + { + $this->assertEquals( + $this->configuration->get('build.file'), + self::DEFAULT_ENV_GITHUB_WORKSPACE . '/.build/package.zip' + ); + } + + /** + * @covers Configuration::get + * @return void + */ + public function testCheckOtherOptionRoot() + { + putenv('GITHUB_WORKSPACE=' . self::OTHER_ENV_GITHUB_WORKSPACE); + $configuration = new Configuration(); - $this->assertEquals($configuration->get('root'), '/usr/bin/app'); + $this->assertEquals( + $configuration->get('root'), + self::OTHER_ENV_GITHUB_WORKSPACE + ); } /** * @covers Configuration::get * @return void */ - public function testCheckDefaultOptionBuildDirectory() + public function testCheckOtherOptionBuildDirectory() { + putenv('GITHUB_WORKSPACE=' . self::OTHER_ENV_GITHUB_WORKSPACE); + putenv('BUILD_DIRECTORY_NAME=' . self::OTHER_ENV_BUILD_DIRECTORY_NAME); + $configuration = new Configuration(); - $this->assertEquals($configuration->get('build.directory'), '/usr/bin/app/.build'); + $this->assertEquals( + $configuration->get('build.directory'), + self::OTHER_ENV_GITHUB_WORKSPACE . DIRECTORY_SEPARATOR . self::OTHER_ENV_BUILD_DIRECTORY_NAME + ); } /** * @covers Configuration::get * @return void */ - public function testCheckDefaultOptionBuildFile() + public function testCheckOtherOptionBuildFile() { + putenv('GITHUB_WORKSPACE=' . self::OTHER_ENV_GITHUB_WORKSPACE); + putenv('BUILD_DIRECTORY_NAME=' . self::OTHER_ENV_BUILD_DIRECTORY_NAME); + putenv('BUILD_FILE_NAME=' . self::OTHER_ENV_BUILD_FILE_NAME); + $configuration = new Configuration(); - $this->assertEquals($configuration->get('build.file'), '/usr/bin/app/.build/package.zip'); + $this->assertEquals( + $configuration->get('build.file'), + self::OTHER_ENV_GITHUB_WORKSPACE . DIRECTORY_SEPARATOR . self::OTHER_ENV_BUILD_DIRECTORY_NAME . + DIRECTORY_SEPARATOR . self::OTHER_ENV_BUILD_FILE_NAME + ); } }