Skip to content

Commit 6d82e66

Browse files
jrfnlgrogy
authored andcommitted
GH Actions: actually get the tests running on all PHP versions
This fixes the problem originally identified by roelofr with the `Fatal error: Interface 'JsonSerializable' not found` error. The problem had nothing to do with the PHP setup, but everything with some inane setting of the Nette testing framework as can be seen in the transcript of older, failing trial runs done by roelofr while setting up the GH Actions workflows: ``` Run composer test > @php vendor/bin/tester -p php tests _____ ___ ___ _____ ___ ___ |_ _/ __)( __/_ _/ __)| _ ) |_| \___ /___) |_| \___ |_|_\ v2.3.5 Note: No php.ini is used. ``` The key here is the `Note: No php.ini is used.`. As the system `php.ini` was not being used, no extensions were loaded, which was causing the errors. This is a change which was introduced in Nette Tester 2.0.0. As of that version, you need to always tell the Nette testing framework explicitly which `php.ini` file to use, `-C` tells it to use the system-wide `php.ini`, with `-c` you can specify a path to a `php.ini` file and by default **_no `php.ini` is used_**. (_honestly, why did anyone ever think making that the default was a good idea ?!!?_) As the tests will be running on different versions of the Nette Framework, Nette 1.x for PHP 5.4 and 5.5 and Nette 2.x for PHP 5.6+ and Nette 1.x, does not yet support the `-C` option and breaks when it is used, I've added a second test script to the `composer.json` file with the correct command line options to run Nette on PHP 5.4/5.5 and added conditions to the GH Actions workflow to use the correct script depending on the PHP/Nette test framework version being used. Refs: * https://tester.nette.org/en/running-tests#toc-c-path * https://tester.nette.org/en/guide#toc-supported-php-versions * https://github.com/nette/tester/releases/tag/v2.0.0
1 parent 1c6b059 commit 6d82e66

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ jobs:
102102
- name: Install Composer dependencies
103103
uses: ramsey/composer-install@v1
104104

105-
- name: Run unit tests
105+
- name: 'Run unit tests PHP 5.4, 5.5'
106+
if: ${{ matrix.php < 5.6 }}
107+
run: composer testphp5
108+
109+
- name: 'Run unit tests PHP >= 5.6'
110+
if: ${{ matrix.php >= 5.6 }}
106111
run: composer test
107112

108113
- name: 'Integration test 1 - linting own code, no colors'

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"parallel-lint"
3838
],
3939
"scripts": {
40-
"test": "@php vendor/bin/tester -p php tests"
40+
"test": "@php vendor/bin/tester -C -p php tests",
41+
"testphp5": "@php vendor/bin/tester -p php tests"
4142
},
4243
"scripts-descriptions": {
4344
"test": "Run all tests!"

0 commit comments

Comments
 (0)