Skip to content

Commit

Permalink
fixed tests and added tests for other application paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
rosven9856 committed Aug 14, 2024
1 parent 704168f commit c1cb92e
Showing 1 changed file with 69 additions and 5 deletions.
74 changes: 69 additions & 5 deletions tests/Configuration/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand All @@ -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
);
}
}

0 comments on commit c1cb92e

Please sign in to comment.