Skip to content

Commit 0b6baeb

Browse files
author
Emmanuel Campait
committed
workflows Github correction
1 parent bc01aa2 commit 0b6baeb

File tree

5 files changed

+74
-5
lines changed

5 files changed

+74
-5
lines changed

.github/workflows/phpstan.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: PHPStan
22

3+
env:
4+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
5+
36
on:
47
push:
58
branches:

.github/workflows/phpunit.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: PHPUnit
22

3+
env:
4+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
5+
36
on:
47
push:
58
branches:
@@ -18,7 +21,8 @@ jobs:
1821
uses: shivammathur/setup-php@v2
1922
with:
2023
php-version: '8.2'
21-
coverage: none
24+
extensions: intl, mbstring
25+
coverage: xdebug
2226

2327
- name: Install dependencies
2428
run: composer install --no-interaction --prefer-dist

.github/workflows/psalm.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Psalm
22

3+
env:
4+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
5+
36
on:
47
push:
58
branches:

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
"domProjects\\CodeIgniterBootstrap\\Tests\\": "tests/"
4141
}
4242
},
43+
"minimum-stability": "dev",
44+
"prefer-stable": true,
4345
"config": {
4446
"allow-plugins": {
4547
"phpstan/extension-installer": true
@@ -55,7 +57,7 @@
5557
],
5658
"cs": "php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.dist.php",
5759
"cs-fix": "php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.dist.php",
58-
"test": "phpunit -c phpunit.xml.dist"
60+
"test": "@php -d xdebug.mode=coverage vendor/bin/phpunit -c phpunit.xml.dist"
5961
},
6062
"extra": {
6163
"branch-alias": {

tests/bootstrap.php

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@
1111
* the LICENSE file that was distributed with this source code.
1212
*/
1313

14-
$rootPath = realpath(__DIR__ . '/../../../../');
14+
$packageRoot = realpath(__DIR__ . '/..');
15+
$rootPath = $packageRoot;
16+
$packageMode = $packageRoot !== false && is_file($packageRoot . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
1517

16-
if ($rootPath === false) {
18+
if (! $packageMode) {
19+
$rootPath = realpath(__DIR__ . '/../../../../');
20+
}
21+
22+
if ($rootPath === false || ! is_file($rootPath . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php')) {
1723
throw new RuntimeException('Unable to resolve the project root for bootstrap tests.');
1824
}
1925

@@ -23,8 +29,59 @@
2329
throw new RuntimeException('Unable to create the test public directory for bootstrap tests.');
2430
}
2531

32+
if ($packageMode) {
33+
$testAppRoot = $rootPath . DIRECTORY_SEPARATOR . 'build' . DIRECTORY_SEPARATOR . 'test-app';
34+
$configPath = $testAppRoot . DIRECTORY_SEPARATOR . 'Config';
35+
$writablePath = $rootPath . DIRECTORY_SEPARATOR . 'build' . DIRECTORY_SEPARATOR . 'writable';
36+
$frameworkRoot = $rootPath . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'codeigniter4' . DIRECTORY_SEPARATOR . 'framework';
37+
$pathsFile = $configPath . DIRECTORY_SEPARATOR . 'Paths.php';
38+
39+
if (! is_dir($configPath) && ! mkdir($configPath, 0775, true) && ! is_dir($configPath)) {
40+
throw new RuntimeException('Unable to create the test config directory for bootstrap tests.');
41+
}
42+
43+
foreach ([$writablePath, $writablePath . DIRECTORY_SEPARATOR . 'cache', $writablePath . DIRECTORY_SEPARATOR . 'logs', $writablePath . DIRECTORY_SEPARATOR . 'session', $writablePath . DIRECTORY_SEPARATOR . 'uploads'] as $directory) {
44+
if (! is_dir($directory) && ! mkdir($directory, 0775, true) && ! is_dir($directory)) {
45+
throw new RuntimeException('Unable to create the writable directory for bootstrap tests.');
46+
}
47+
}
48+
49+
$pathsContents = <<<PHP
50+
<?php
51+
52+
namespace Config;
53+
54+
class Paths
55+
{
56+
public string \$systemDirectory = %s;
57+
public string \$appDirectory = %s;
58+
public string \$writableDirectory = %s;
59+
public string \$testsDirectory = %s;
60+
public string \$viewDirectory = %s;
61+
public string \$envDirectory = %s;
62+
}
63+
PHP;
64+
65+
$pathsContents = sprintf(
66+
$pathsContents,
67+
var_export(str_replace('\\', '/', $frameworkRoot . '/system'), true),
68+
var_export(str_replace('\\', '/', $frameworkRoot . '/app'), true),
69+
var_export(str_replace('\\', '/', $writablePath), true),
70+
var_export(str_replace('\\', '/', $rootPath . DIRECTORY_SEPARATOR . 'tests'), true),
71+
var_export(str_replace('\\', '/', $frameworkRoot . '/app/Views'), true),
72+
var_export(str_replace('\\', '/', $rootPath), true),
73+
);
74+
75+
if (! is_file($pathsFile) || file_get_contents($pathsFile) !== $pathsContents) {
76+
file_put_contents($pathsFile, $pathsContents);
77+
}
78+
79+
defined('CONFIGPATH') || define('CONFIGPATH', $configPath . DIRECTORY_SEPARATOR);
80+
} else {
81+
defined('CONFIGPATH') || define('CONFIGPATH', $rootPath . DIRECTORY_SEPARATOR . 'app/Config' . DIRECTORY_SEPARATOR);
82+
}
83+
2684
defined('HOMEPATH') || define('HOMEPATH', $rootPath . DIRECTORY_SEPARATOR);
27-
defined('CONFIGPATH') || define('CONFIGPATH', $rootPath . DIRECTORY_SEPARATOR . 'app/Config' . DIRECTORY_SEPARATOR);
2885
defined('PUBLICPATH') || define('PUBLICPATH', $publicPath . DIRECTORY_SEPARATOR);
2986
defined('TESTPATH') || define('TESTPATH', __DIR__ . DIRECTORY_SEPARATOR);
3087
defined('SUPPORTPATH') || define('SUPPORTPATH', __DIR__ . DIRECTORY_SEPARATOR . '_support' . DIRECTORY_SEPARATOR);

0 commit comments

Comments
 (0)