diff --git a/rector.php b/rector.php index 0ef9397..20d190e 100644 --- a/rector.php +++ b/rector.php @@ -15,6 +15,6 @@ ]); $rectorConfig->sets([ LevelSetList::UP_TO_PHP_83, - DowngradeLevelSetList::DOWN_TO_PHP_81, + // DowngradeLevelSetList::DOWN_TO_PHP_81, ]); }; diff --git a/src/Configuration/Configuration.php b/src/Configuration/Configuration.php index c783f16..7849f40 100644 --- a/src/Configuration/Configuration.php +++ b/src/Configuration/Configuration.php @@ -4,9 +4,9 @@ namespace App\Configuration; -final class Configuration +final readonly class Configuration { - protected readonly array $options; + protected array $options; /** * @use diff --git a/tests/Configuration/ConfigurationTest.php b/tests/Configuration/ConfigurationTest.php index eb1dcc6..769d61b 100644 --- a/tests/Configuration/ConfigurationTest.php +++ b/tests/Configuration/ConfigurationTest.php @@ -9,13 +9,39 @@ */ 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'; + /** + * @var string + */ + private const string DEFAULT_ENV_GITHUB_WORKSPACE = '/usr/bin/app'; + + /** + * @var string + */ + private const string DEFAULT_ENV_BUILD_DIRECTORY_NAME = '.build'; + + /** + * @var string + */ + private const string DEFAULT_ENV_BUILD_FILE_NAME = 'package.zip'; + + /** + * @var string + */ + private const string OTHER_ENV_GITHUB_WORKSPACE = '/app'; + + /** + * @var string + */ + private const string OTHER_ENV_BUILD_DIRECTORY_NAME = '.build_directory'; + + /** + * @var string + */ + private const string OTHER_ENV_BUILD_FILE_NAME = 'build_file.zip'; protected Configuration $configuration; + #[\Override] protected function setUp(): void { putenv('GITHUB_WORKSPACE=' . self::DEFAULT_ENV_GITHUB_WORKSPACE); @@ -29,8 +55,14 @@ protected function setUp(): void */ public function testCheckDefaultOptionRoot() { + putenv('GITHUB_WORKSPACE=' . self::DEFAULT_ENV_GITHUB_WORKSPACE); + putenv('BUILD_DIRECTORY_NAME=' . self::DEFAULT_ENV_BUILD_DIRECTORY_NAME); + putenv('BUILD_FILE_NAME=' . self::DEFAULT_ENV_BUILD_FILE_NAME); + + $configuration = new Configuration(); + $this->assertEquals( - $this->configuration->get('root'), + $configuration->get('root'), self::DEFAULT_ENV_GITHUB_WORKSPACE ); } @@ -41,9 +73,15 @@ public function testCheckDefaultOptionRoot() */ public function testCheckDefaultOptionBuildDirectory() { + putenv('GITHUB_WORKSPACE=' . self::DEFAULT_ENV_GITHUB_WORKSPACE); + putenv('BUILD_DIRECTORY_NAME=' . self::DEFAULT_ENV_BUILD_DIRECTORY_NAME); + putenv('BUILD_FILE_NAME=' . self::DEFAULT_ENV_BUILD_FILE_NAME); + + $configuration = new Configuration(); + $this->assertEquals( - $this->configuration->get('build.directory'), - self::DEFAULT_ENV_GITHUB_WORKSPACE . '/.build' + $configuration->get('build.directory'), + self::DEFAULT_ENV_GITHUB_WORKSPACE . DIRECTORY_SEPARATOR . self::DEFAULT_ENV_BUILD_DIRECTORY_NAME ); } @@ -53,9 +91,16 @@ public function testCheckDefaultOptionBuildDirectory() */ public function testCheckDefaultOptionBuildFile() { + putenv('GITHUB_WORKSPACE=' . self::DEFAULT_ENV_GITHUB_WORKSPACE); + putenv('BUILD_DIRECTORY_NAME=' . self::DEFAULT_ENV_BUILD_DIRECTORY_NAME); + putenv('BUILD_FILE_NAME=' . self::DEFAULT_ENV_BUILD_FILE_NAME); + + $configuration = new Configuration(); + $this->assertEquals( - $this->configuration->get('build.file'), - self::DEFAULT_ENV_GITHUB_WORKSPACE . '/.build/package.zip' + $configuration->get('build.file'), + self::DEFAULT_ENV_GITHUB_WORKSPACE . DIRECTORY_SEPARATOR . self::DEFAULT_ENV_BUILD_DIRECTORY_NAME . + DIRECTORY_SEPARATOR . self::DEFAULT_ENV_BUILD_FILE_NAME ); } @@ -66,6 +111,8 @@ public function testCheckDefaultOptionBuildFile() public function testCheckOtherOptionRoot() { 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(); @@ -83,6 +130,7 @@ public function testCheckOtherOptionBuildDirectory() { 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();