Skip to content

Commit f2cb62d

Browse files
committed
Added assertion messages for some traits.
1 parent 9649c8b commit f2cb62d

2 files changed

Lines changed: 21 additions & 34 deletions

File tree

.vortex/tests/phpunit/Traits/Steps/StepEnvironmentTrait.php

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,22 @@ protected function stepGitignore(): void {
2929
protected function stepEnvChanges(): void {
3030
$this->logStepStart();
3131

32-
// Assert that .env does not contain test values.
33-
$this->assertFileNotContainsString('.env', 'MY_CUSTOM_VAR');
34-
$this->assertFileNotContainsString('.env', 'my_custom_var_value');
32+
$this->assertFileNotContainsString('.env', 'MY_CUSTOM_VAR', '.env does not contain test values');
33+
$this->assertFileNotContainsString('.env', 'my_custom_var_value', '.env does not contain test values');
3534

36-
// Assert that test variable is not available inside of containers.
3735
$this->cmdFail('ahoy cli "printenv | grep -q MY_CUSTOM_VAR"');
3836

39-
// Assert that test value is not available inside of containers.
4037
$this->cmdFail('ahoy cli \'echo $MY_CUSTOM_VAR | grep -q my_custom_var_value\'', '! my_custom_var_value');
4138

4239
// Add variable to the .env file and apply the change to container.
4340
$this->addVarToFile('.env', 'MY_CUSTOM_VAR', 'my_custom_var_value');
4441
$this->cmd('ahoy up cli');
4542
$this->syncToContainer();
4643

47-
// Assert that .env contains test values.
48-
$this->assertFileContainsString('.env', 'MY_CUSTOM_VAR');
49-
$this->assertFileContainsString('.env', 'my_custom_var_value');
50-
51-
// Assert that test variable and values are available inside of containers.
52-
$this->cmd('ahoy cli "printenv | grep MY_CUSTOM_VAR"', 'my_custom_var_value');
53-
54-
// Assert that test variable and value are available inside of containers.
55-
$this->cmd('ahoy cli \'echo $MY_CUSTOM_VAR | grep my_custom_var_value\'', 'my_custom_var_value');
44+
$this->assertFileContainsString('.env', 'MY_CUSTOM_VAR', '.env contains test values');
45+
$this->assertFileContainsString('.env', 'my_custom_var_value', '.env contains test values');
46+
$this->cmd('ahoy cli "printenv | grep MY_CUSTOM_VAR"', 'my_custom_var_value', 'Assert that test variable and values are available inside of containers.');
47+
$this->cmd('ahoy cli \'echo $MY_CUSTOM_VAR | grep my_custom_var_value\'', 'my_custom_var_value', 'Assert that test variable and values are available inside of containers.');
5648

5749
// Restore file, apply changes and assert that original behaviour has been
5850
// restored.
@@ -71,26 +63,25 @@ protected function stepEnvChanges(): void {
7163
protected function stepTimezone(): void {
7264
$this->logStepStart();
7365

74-
// Assert that .env contains a default value.
75-
// Note that AEDT changes to AEST during winter.
76-
$this->assertFileContainsString('.env', 'TZ=UTC');
77-
$this->cmd('docker compose exec -T cli date', 'UTC');
78-
$this->cmd('docker compose exec -T php date', 'UTC');
79-
$this->cmd('docker compose exec -T nginx date', 'UTC');
80-
$this->cmd('docker compose exec -T database date', 'UTC');
66+
$this->logSubstep('Assert default timezone values.');
67+
$this->assertFileContainsString('.env', 'TZ=UTC', '.env contains a default value.');
68+
$this->cmd('docker compose exec -T cli date', 'UTC', 'Date is in default timezone inside CLI container by default');
69+
$this->cmd('docker compose exec -T php date', 'UTC', 'Date is in default timezone inside PHP container by default');
70+
$this->cmd('docker compose exec -T nginx date', 'UTC', 'Date is in default timezone inside Nginx container by default');
71+
$this->cmd('docker compose exec -T database date', 'UTC', 'Date is in default timezone inside Database container by default');
8172

82-
// Add variable to the .env file and apply the change to container.
73+
$this->logSubstep('Add variable to the .env file and apply the change to container.');
8374
$this->addVarToFile('.env', 'TZ', '"Australia/Perth"');
8475
$this->syncToContainer();
8576
$this->cmd('ahoy up');
8677

87-
$this->cmd('docker compose exec -T cli date', 'AWST');
88-
$this->cmd('docker compose exec -T php date', 'AWST');
89-
$this->cmd('docker compose exec -T nginx date', 'AWST');
90-
$this->cmd('docker compose exec -T database date', 'AWST');
78+
$this->logSubstep('Assert custom timezone values.');
79+
$this->cmd('docker compose exec -T cli date', 'AWST', 'Date is in custom timezone inside CLI container');
80+
$this->cmd('docker compose exec -T php date', 'AWST', 'Date is in custom timezone inside PHP container');
81+
$this->cmd('docker compose exec -T nginx date', 'AWST', 'Date is in custom timezone inside Nginx container');
82+
$this->cmd('docker compose exec -T database date', 'AWST', 'Date is in custom timezone inside Database container');
9183

92-
// Restore file, apply changes and assert that original behaviour has been
93-
// restored.
84+
$this->logSubstep('Restore file, apply changes and assert that original behaviour has been restored.');
9485
$this->restoreFile('.env');
9586
$this->syncToContainer();
9687
$this->cmd('ahoy up');

.vortex/tests/phpunit/Traits/Steps/StepFrontendTrait.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ protected function stepAhoyFe(string $webroot = 'web'): void {
5050
$this->syncToContainer();
5151
$this->cmd('ahoy fe');
5252
$this->syncToHost();
53-
// Assets compiled for production are minified (no spaces between
54-
// properties and their values).
55-
$this->assertFileContainsString($minified_file, 'background:' . $test_color1);
53+
$this->assertFileContainsString($minified_file, 'background:' . $test_color1, 'Assets compiled for production are minified (no spaces between properties and their values)');
5654

5755
$this->logSubstep('Build FE assets for development');
5856

@@ -65,9 +63,7 @@ protected function stepAhoyFe(string $webroot = 'web'): void {
6563
$this->syncToContainer();
6664
$this->cmd('ahoy fed');
6765
$this->syncToHost();
68-
// Note that assets compiled for development are not minified (contains
69-
// spaces between properties and their values).
70-
$this->assertFileContainsString($minified_file, 'background: ' . $test_color2);
66+
$this->assertFileContainsString($minified_file, 'background: ' . $test_color2, 'Assets compiled for development are not minified (contains spaces between properties and their values)');
7167

7268
$this->logStepFinish();
7369
}

0 commit comments

Comments
 (0)