Skip to content

Commit 7e77236

Browse files
committed
removed -n flag, deprecated -C option [WIP]
1 parent 8188882 commit 7e77236

6 files changed

Lines changed: 24 additions & 22 deletions

File tree

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- run: composer install --no-progress --prefer-dist
2525
- run: src/tester --info
2626
shell: bash
27-
- run: src/tester tests -s -C
27+
- run: src/tester tests -s
2828
shell: bash
2929
- if: failure()
3030
uses: actions/upload-artifact@v4
@@ -59,7 +59,7 @@ jobs:
5959
coverage: none
6060

6161
- run: composer install --no-progress --prefer-dist
62-
- run: src/tester -p phpdbg tests -s -C --coverage ./coverage.xml --coverage-src ./src
62+
- run: src/tester -p phpdbg tests -s --coverage ./coverage.xml --coverage-src ./src
6363
- run: wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.3/php-coveralls.phar
6464
- env:
6565
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CLAUDE.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Nette Tester is a lightweight, standalone PHP testing framework designed for sim
1616

1717
```bash
1818
# or directly:
19-
src/tester tests -s -C
19+
src/tester tests -s
2020

2121
# Run specific test file
22-
src/tester tests/Framework/Assert.phpt -s -C
22+
src/tester tests/Framework/Assert.phpt -s
2323

2424
# or simply
2525
php tests/Framework/Assert.phpt
@@ -806,10 +806,7 @@ Assert::fail('Error in connection');
806806

807807
### PHP INI Handling
808808

809-
Tester runs PHP processes with `-n` flag (no php.ini loaded):
810-
- Ensures consistent test environment
811-
- System extensions from `/etc/php/conf.d/*.ini` are NOT loaded
812-
- Use `-C` flag to load system php.ini
809+
Tester runs PHP processes with the system php.ini:
813810
- Use `-c path/to/php.ini` for custom php.ini
814811
- Use `-d key=value` for individual INI settings
815812

readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Now we run tests from command-line using the `tester` command:
8585
|_ _/ __)( __/_ _/ __)| _ )
8686
|_| \___ /___) |_| \___ |_|_\ v2.6
8787
88-
PHP 8.2.0 | php -n | 8 threads
88+
PHP 8.2.0 | php | 8 threads
8989
.
9090
OK (1 tests, 0 skipped, 0.0 seconds)
9191
```
@@ -217,8 +217,8 @@ Usage:
217217
218218
Options:
219219
-p <path> Specify PHP interpreter to run (default: php).
220-
-c <path> Look for php.ini file (or look in directory) <path>.
221-
-C Use system-wide php.ini.
220+
-c <path> Use custom php.ini, ignore system configuration.
221+
-C With -c, include system configuration as well.
222222
-l | --log <path> Write log to file <path>.
223223
-d <key=value>... Define INI entry 'key' with value 'val'.
224224
-s Show information about skipped tests.

src/Runner/CliTester.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ private function loadOptions(): CommandLine
108108
109109
Options:
110110
-p <path> Specify PHP interpreter to run (default: php).
111-
-c <path> Look for php.ini file (or look in directory) <path>.
112-
-C Use system-wide php.ini.
111+
-c <path> Use custom php.ini, ignore system configuration.
112+
-C With -c, include system configuration as well.
113113
-d <key=value>... Define INI entry 'key' with value 'value'.
114114
-s Show information about skipped tests.
115115
--stop-on-fail Stop execution upon the first failure.
@@ -189,11 +189,12 @@ private function loadOptions(): CommandLine
189189

190190
private function createPhpInterpreter(): void
191191
{
192-
$args = $this->options['-C'] ? [] : ['-n'];
192+
$args = [];
193193
if ($this->options['-c']) {
194+
if (!$this->options['-C']) {
195+
$args[] = '-n';
196+
}
194197
array_push($args, '-c', $this->options['-c']);
195-
} elseif (!$this->options['--info'] && !$this->options['-C']) {
196-
echo "Note: No php.ini is used.\n";
197198
}
198199

199200
if (in_array($this->stdoutFormat, ['tap', 'junit'], strict: true)) {

tests/Runner/PhpInterpreter.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,10 @@ if (extension_loaded('pcov')) {
3333
}
3434

3535
Assert::count($count, $engines);
36+
37+
38+
// createInterpreter() uses same php.ini as parent
39+
if (!$interpreter->isCgi()) {
40+
$output = shell_exec($interpreter->withArguments(['-r echo php_ini_loaded_file();'])->getCommandLine());
41+
Assert::same(php_ini_loaded_file(), $output);
42+
}

tests/bootstrap.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@
1414

1515
function createInterpreter(): PhpInterpreter
1616
{
17-
$args = strlen((string) php_ini_scanned_files())
18-
? []
19-
: ['-n'];
20-
21-
if (php_ini_loaded_file()) {
22-
array_push($args, '-c', php_ini_loaded_file());
17+
$args = [];
18+
if ($file = php_ini_loaded_file()) {
19+
array_push($args, '-n', '-c', $file);
2320
}
2421

2522
return new PhpInterpreter(PHP_BINARY, $args);

0 commit comments

Comments
 (0)