Skip to content

Commit 7b105b0

Browse files
committed
Updated File and PHPUnit helpers versions.
1 parent f171ed6 commit 7b105b0

10 files changed

Lines changed: 39 additions & 102 deletions

.vortex/tests/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"php": ">=8.2"
1313
},
1414
"require-dev": {
15-
"alexskrypnyk/file": "^0.9",
16-
"alexskrypnyk/phpunit-helpers": "main-dev",
15+
"alexskrypnyk/file": "^0.10",
16+
"alexskrypnyk/phpunit-helpers": "^0.10",
1717
"alexskrypnyk/shellvar": "^1.2",
1818
"czproject/git-php": "^4.4",
1919
"dealerdirect/phpcodesniffer-composer-installer": "^1",

.vortex/tests/composer.lock

Lines changed: 9 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vortex/tests/phpunit/Functional/FunctionalTestCase.php

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -165,64 +165,4 @@ public function volumesMounted(): bool {
165165
return getenv('VORTEX_DEV_VOLUMES_SKIP_MOUNT') != 1;
166166
}
167167

168-
protected function assertFilesExist(string $directory, array $files): void {
169-
foreach ($files as $file) {
170-
$this->assertFileExists($directory . DIRECTORY_SEPARATOR . $file);
171-
}
172-
}
173-
174-
/**
175-
* Assert that files matching wildcard pattern(s) exist.
176-
*
177-
* @param string|array $patterns
178-
* Wildcard pattern(s) to match files against.
179-
*/
180-
protected function assertFilesWildcardExists(string|array $patterns): void {
181-
$patterns = is_array($patterns) ? $patterns : [$patterns];
182-
183-
if (empty($patterns)) {
184-
throw new \InvalidArgumentException('Empty patterns - no files to check');
185-
}
186-
187-
foreach ($patterns as $pattern) {
188-
$matches = glob($pattern);
189-
190-
if ($matches === FALSE) {
191-
throw new \RuntimeException(sprintf('Failed to read files matching wildcard pattern: %s', $pattern));
192-
}
193-
194-
$this->assertNotEmpty(
195-
$matches,
196-
sprintf('No files found matching wildcard pattern: %s', $pattern)
197-
);
198-
}
199-
}
200-
201-
/**
202-
* Assert that files matching wildcard pattern(s) do not exist.
203-
*
204-
* @param string|array $patterns
205-
* Wildcard pattern(s) to match files against.
206-
*/
207-
protected function assertFilesWildcardDoNotExist(string|array $patterns): void {
208-
$patterns = is_array($patterns) ? $patterns : [$patterns];
209-
210-
if (empty($patterns)) {
211-
throw new \InvalidArgumentException('Empty patterns - no files to check');
212-
}
213-
214-
foreach ($patterns as $pattern) {
215-
$matches = glob($pattern);
216-
217-
if ($matches === FALSE) {
218-
throw new \RuntimeException(sprintf('Failed to read files matching wildcard pattern: %s', $pattern));
219-
}
220-
221-
$this->assertEmpty(
222-
$matches,
223-
sprintf('Found %d file(s) matching wildcard pattern that should not exist: %s', count($matches), $pattern)
224-
);
225-
}
226-
}
227-
228168
}

.vortex/tests/phpunit/Traits/AssertFilesTrait.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ protected function assertCommonFilesPresent(string $webroot = 'web', string $pro
2222

2323
// Assert that project name is correct.
2424
Assert::assertFileExists('.env');
25-
$this->assertFileContainsString('VORTEX_PROJECT=' . $project_name, '.env');
25+
$this->assertFileContainsString('.env', 'VORTEX_PROJECT=' . $project_name);
2626

2727
// Assert that Vortex version was replaced in README.md.
2828
Assert::assertFileExists('README.md');
2929
$vortex_version = getenv('TEST_VORTEX_VERSION') ?: 'develop';
30-
$this->assertFileContainsString(sprintf('badge/Vortex-%s-65ACBC.svg', $vortex_version), 'README.md');
31-
$this->assertFileContainsString('https://github.com/drevops/vortex/tree/' . $vortex_version, 'README.md');
32-
$this->assertFileNotContainsString('The following list includes', 'README.md');
30+
$this->assertFileContainsString('README.md', sprintf('badge/Vortex-%s-65ACBC.svg', $vortex_version));
31+
$this->assertFileContainsString('README.md', 'https://github.com/drevops/vortex/tree/' . $vortex_version);
32+
$this->assertFileNotContainsString('README.md', 'The following list includes');
3333
Assert::assertFileDoesNotExist('README.dist.md');
3434

35-
$this->assertFileContainsString('This repository was created using the [Vortex](https://github.com/drevops/vortex) Drupal project template', 'README.md', 'Assert that Vortex footnote remains.');
35+
$this->assertFileContainsString('README.md', 'This repository was created using the [Vortex](https://github.com/drevops/vortex) Drupal project template', 'Assert that Vortex footnote remains.');
3636

3737
// Assert Drupal files are present.
3838
$this->assertDrupalFilesPresent($webroot);
@@ -200,12 +200,12 @@ protected function assertVortexFilesPresent(string $webroot = 'web'): void {
200200
Assert::assertFileDoesNotExist('.github/workflows/vortex-test-installer.yml');
201201

202202
if (file_exists('.circleci/config.yml')) {
203-
$this->assertFileNotContainsString('vortex-dev', '.circleci/config.yml', 'CircleCI config should not contain development Vortex references');
203+
$this->assertFileNotContainsString('.circleci/config.yml', 'vortex-dev', 'CircleCI config should not contain development Vortex references');
204204
}
205205

206206
// Assert that documentation was processed correctly.
207207
if (file_exists('README.md')) {
208-
$this->assertFileNotContainsString('# Vortex', 'README.md');
208+
$this->assertFileNotContainsString('README.md', '# Vortex');
209209
}
210210

211211
// Check directory doesn't contain .vortex references.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ protected function stepBuild(string $webroot = 'web', array $env = []): void {
4343

4444
$this->logSubstep('Assert only minified compiled CSS exists');
4545
$this->assertFileExists($webroot . '/themes/custom/star_wars/build/css/star_wars.min.css', 'Minified CSS file should exist');
46-
$this->assertFileNotContainsString('background: #7e57e2', $webroot . '/themes/custom/star_wars/build/css/star_wars.min.css', 'CSS should not contain development colors');
46+
$this->assertFileNotContainsString($webroot . '/themes/custom/star_wars/build/css/star_wars.min.css', 'background: #7e57e2', 'CSS should not contain development colors');
4747
$this->assertFileDoesNotExist($webroot . '/themes/custom/star_wars/build/css/star_wars.css', 'Non-minified CSS should not exist');
4848

4949
$this->logSubstep('Assert only minified compiled JS exists');
5050
$this->assertFileExists($webroot . '/themes/custom/star_wars/build/js/star_wars.min.js', 'Minified JS file should exist');
51-
$this->assertFileContainsString('!function(Drupal){"use strict";Drupal.behaviors.star_wars', $webroot . '/themes/custom/star_wars/build/js/star_wars.min.js', 'JS should contain expected minified content');
51+
$this->assertFileContainsString($webroot . '/themes/custom/star_wars/build/js/star_wars.min.js', '!function(Drupal){"use strict";Drupal.behaviors.star_wars', 'JS should contain expected minified content');
5252
$this->assertFileDoesNotExist($webroot . '/themes/custom/star_wars/build/js/star_wars.js', 'Non-minified JS should not exist');
5353

5454
$this->logStepFinish();

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ protected function stepEnvChanges(): void {
3030
$this->logStepStart();
3131

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

3636
// Assert that test variable is not available inside of containers.
3737
$this->cmdFail('ahoy cli "printenv | grep -q MY_CUSTOM_VAR"');
@@ -45,8 +45,8 @@ protected function stepEnvChanges(): void {
4545
$this->syncToContainer();
4646

4747
// Assert that .env contains test values.
48-
$this->assertFileContainsString('MY_CUSTOM_VAR', '.env');
49-
$this->assertFileContainsString('my_custom_var_value', '.env');
48+
$this->assertFileContainsString('.env', 'MY_CUSTOM_VAR');
49+
$this->assertFileContainsString('.env', 'my_custom_var_value');
5050

5151
// Assert that test variable and values are available inside of containers.
5252
$this->cmd('ahoy cli "printenv | grep MY_CUSTOM_VAR"', 'my_custom_var_value');
@@ -60,8 +60,8 @@ protected function stepEnvChanges(): void {
6060
$this->cmd('ahoy up cli');
6161
$this->syncToContainer();
6262

63-
$this->assertFileNotContainsString('MY_CUSTOM_VAR', '.env');
64-
$this->assertFileNotContainsString('my_custom_var_value', '.env');
63+
$this->assertFileNotContainsString('.env', 'MY_CUSTOM_VAR');
64+
$this->assertFileNotContainsString('.env', 'my_custom_var_value');
6565
$this->cmdFail('ahoy cli "printenv | grep -q MY_CUSTOM_VAR"');
6666
$this->cmdFail('ahoy cli \'echo $MY_CUSTOM_VAR | grep my_custom_var_value\'', '! my_custom_var_value');
6767

@@ -73,7 +73,7 @@ protected function stepTimezone(): void {
7373

7474
// Assert that .env contains a default value.
7575
// Note that AEDT changes to AEST during winter.
76-
$this->assertFileContainsString('TZ=UTC', '.env');
76+
$this->assertFileContainsString('.env', 'TZ=UTC');
7777
$this->cmd('docker compose exec -T cli date', 'UTC');
7878
$this->cmd('docker compose exec -T php date', 'UTC');
7979
$this->cmd('docker compose exec -T nginx date', 'UTC');

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected function stepAhoyFe(string $webroot = 'web'): void {
4040
$variables_file = $webroot . '/themes/custom/star_wars/scss/_variables.scss';
4141
$minified_file = $webroot . '/themes/custom/star_wars/build/css/star_wars.min.css';
4242

43-
$this->assertFileNotContainsString($test_color1, $webroot . '/themes/custom/star_wars/build/css/star_wars.min.css');
43+
$this->assertFileNotContainsString($webroot . '/themes/custom/star_wars/build/css/star_wars.min.css', $test_color1);
4444

4545
$original_content = File::read($variables_file);
4646
$new_content = $original_content . "\n\$color-tester: {$test_color1};\n\$color-primary: \$color-tester;\n";
@@ -52,11 +52,11 @@ protected function stepAhoyFe(string $webroot = 'web'): void {
5252
$this->syncToHost();
5353
// Assets compiled for production are minified (no spaces between
5454
// properties and their values).
55-
$this->assertFileContainsString('background:' . $test_color1, $minified_file);
55+
$this->assertFileContainsString($minified_file, 'background:' . $test_color1);
5656

5757
$this->logSubstep('Build FE assets for development');
5858

59-
$this->assertFileNotContainsString($test_color2, $minified_file);
59+
$this->assertFileNotContainsString($minified_file, $test_color2);
6060

6161
$dev_content = $new_content . "\n\$color-please: {$test_color2};\n\$color-primary: \$color-please;\n";
6262
File::remove($variables_file);
@@ -67,7 +67,7 @@ protected function stepAhoyFe(string $webroot = 'web'): void {
6767
$this->syncToHost();
6868
// Note that assets compiled for development are not minified (contains
6969
// spaces between properties and their values).
70-
$this->assertFileContainsString('background: ' . $test_color2, $minified_file);
70+
$this->assertFileContainsString($minified_file, 'background: ' . $test_color2);
7171

7272
$this->logStepFinish();
7373
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ protected function adjustCodebaseForUnmountedVolumes(): void {
9090
if (File::exists('docker-compose.yml')) {
9191
$this->logSubstep('Fixing host dependencies in docker-compose.yml');
9292
File::removeLine('docker-compose.yml', '###');
93-
$this->assertFileNotContainsString('###', 'docker-compose.yml', 'Lines with ### should be removed from docker-compose.yml');
93+
$this->assertFileNotContainsString('docker-compose.yml', '###', 'Lines with ### should be removed from docker-compose.yml');
9494
File::replaceContentInFile('docker-compose.yml', '##', '');
95-
$this->assertFileNotContainsString('##', 'docker-compose.yml', 'Lines with ## should be removed from docker-compose.yml');
95+
$this->assertFileNotContainsString('docker-compose.yml', '##', 'Lines with ## should be removed from docker-compose.yml');
9696
}
9797

9898
if (file_exists('.ahoy.yml')) {
@@ -104,8 +104,8 @@ protected function adjustCodebaseForUnmountedVolumes(): void {
104104
$this->logSubstep('Pre-processing .ahoy.yml to copy database file to container');
105105

106106
$this->assertFileContainsString(
107-
'ahoy cli ./scripts/vortex/provision.sh',
108107
'.ahoy.yml',
108+
'ahoy cli ./scripts/vortex/provision.sh',
109109
'Initial Ahoy command to provision the container should exist in .ahoy.yml'
110110
);
111111

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected function stepTestBdd(): void {
3232
$this->syncToHost();
3333

3434
$this->logSubstep('Checking that BDD tests have created screenshots and test results');
35-
$this->assertDirectoryContainsString('html', '.logs/screenshots', message: 'Screenshots directory should not be empty after BDD tests');
35+
$this->assertDirectoryContainsString('.logs/screenshots', 'html', message: 'Screenshots directory should not be empty after BDD tests');
3636
$this->assertFileExists('.logs/test_results/behat/default.xml', 'Behat test results XML file should exist');
3737

3838
$this->logSubstep('Cleaning up after the test');

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@ protected function stepAhoyTestBdd(string $webroot = 'web'): void {
226226

227227
$this->logSubstep('Assert that screenshots and test results are created');
228228
$this->assertFileExists('.logs/screenshots/behat-test-screenshot.html');
229-
$this->assertFileContainsString('Current URL: http://nginx:8080/', '.logs/screenshots/behat-test-screenshot.html');
230-
$this->assertFileContainsString('Feature: Behat configuration', '.logs/screenshots/behat-test-screenshot.html');
231-
$this->assertFileContainsString('Step: save screenshot with name', '.logs/screenshots/behat-test-screenshot.html');
232-
$this->assertFileContainsString('Datetime:', '.logs/screenshots/behat-test-screenshot.html');
229+
$this->assertFileContainsString('.logs/screenshots/behat-test-screenshot.html', 'Current URL: http://nginx:8080/');
230+
$this->assertFileContainsString('.logs/screenshots/behat-test-screenshot.html', 'Feature: Behat configuration');
231+
$this->assertFileContainsString('.logs/screenshots/behat-test-screenshot.html', 'Step: save screenshot with name');
232+
$this->assertFileContainsString('.logs/screenshots/behat-test-screenshot.html', 'Datetime:');
233233

234234
File::remove('.logs/screenshots');
235235
$this->cmd('ahoy cli rm -rf /app/.logs/screenshots/*');

0 commit comments

Comments
 (0)