-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathTimezoneInstallTest.php
More file actions
60 lines (49 loc) · 2.62 KB
/
Copy pathTimezoneInstallTest.php
File metadata and controls
60 lines (49 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace DrevOps\VortexInstaller\Tests\Functional\Handlers;
use DrevOps\VortexInstaller\Prompts\Handlers\CiProvider;
use DrevOps\VortexInstaller\Prompts\Handlers\Timezone;
use DrevOps\VortexInstaller\Prompts\PromptManager;
use DrevOps\VortexInstaller\Tests\Functional\FunctionalTestCase;
use DrevOps\VortexInstaller\Utils\Env;
use PHPUnit\Framework\Attributes\CoversClass;
#[CoversClass(Timezone::class)]
class TimezoneInstallTest extends AbstractInstallTestCase {
public static function dataProviderInstall(): array {
return [
'timezone, gha' => [
static::cw(function (): void {
Env::put(PromptManager::makeEnvName(Timezone::id()), 'America/New_York');
Env::put(PromptManager::makeEnvName(CiProvider::id()), CiProvider::GITHUB_ACTIONS);
}),
static::cw(function (FunctionalTestCase $test): void {
// Timezone should be replaced in .env file.
$test->assertFileContainsString(static::$sut . '/.env', 'TZ=America/New_York');
$test->assertFileNotContainsString(static::$sut . '/.env', 'UTC');
// Timezone should be replaced in Renovate config.
$test->assertFileContainsString(static::$sut . '/renovate.json', '"timezone": "America/New_York"');
$test->assertFileNotContainsString(static::$sut . '/renovate.json', 'UTC');
// Timezone should not be replaced in GHA config in code as it should
// be overridden via UI.
$test->assertFileNotContainsString(static::$sut . '/.github/workflows/build-test-deploy.yml', 'America/New_York');
$test->assertFileContainsString(static::$sut . '/.github/workflows/build-test-deploy.yml', 'UTC');
// Timezone should not be replaced in Docker Compose config.
$test->assertFileNotContainsString(static::$sut . '/docker-compose.yml', 'America/New_York');
$test->assertFileContainsString(static::$sut . '/docker-compose.yml', 'UTC');
}),
],
'timezone, circleci' => [
static::cw(function (): void {
Env::put(PromptManager::makeEnvName(Timezone::id()), 'America/New_York');
Env::put(PromptManager::makeEnvName(CiProvider::id()), CiProvider::CIRCLECI);
}),
static::cw(function (FunctionalTestCase $test): void {
// Timezone should not be replaced in CircleCI config in code as it
// should be overridden via UI.
$test->assertFileNotContainsString(static::$sut . '/.circleci/config.yml', 'TZ: America/New_York');
$test->assertFileContainsString(static::$sut . '/.circleci/config.yml', 'TZ: UTC');
}),
],
];
}
}