CodeIgniter
CodeIgniter copied to clipboard
unable to run phpunit in tests directory
I have encountered what appears to be a problem in the phpunit.xml file in the latest develop branch of CI3.
I posted another issue that the README file in the tests directory no longer works. I spent some time installing phpunit according to the latest instructions and I installed vfsStream using composer and tried to get around the error reported by composer on my MacOs laptop:
sed: 1: "vendor/mikey179/vfsstre ...": invalid command code v
Script sed -i s/name{0}/name[0]/ vendor/mikey179/vfsstream/src/main/php/org/bovigo/vfs/vfsstream.php handling the post-install-cmd event returned with error code 1
As suggested here I modified that sed statement as follows:
sed -i .bak s/name{0}/name[0]/ vendor/mikey179/vfsstream/src/main/php/org/bovigo/vfs/vfsstream.php
This seems to run. I do not know if this performs the necessary step, but phpunit appears to run now without vfstream complaints.
HOWEVER, phpunit fails:
$ phpunit
PHPUnit 10.0.19 by Sebastian Bergmann and contributors.
Test directory "/home/sneakyimp/ci3/tests/./codeigniter/core" not found
It would seem that there is a problem with the file tests/phpunit.xml, which specifies this path and a couple of others:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="./Bootstrap.php"
colors="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
beStrictAboutTestsThatDoNotTestAnything="false">
<testsuites>
<testsuite name="CodeIgniter Core Test Suite">
<directory suffix="test.php">./codeigniter/core</directory>
<directory suffix="test.php">./codeigniter/helpers</directory>
<directory suffix="test.php">./codeigniter/libraries</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">../system/</directory>
</whitelist>
</filter>
</phpunit>
These paths appear wrong? There is no folder/directory in the CI3 codebase named codeigniter. If you replace /codeigniter/ with /mocks/ then phpunit will run, but complains there is no helpers subdir. removing that, phpunit will finally run, but complains about a deprecated schema, and runs no tests:
$ phpunit
PHPUnit 10.0.19 by Sebastian Bergmann and contributors.
Runtime: PHP 8.2.3
Configuration: /home/sneakyimp/ci3/tests/phpunit.xml
There was 1 PHPUnit warning:
1) Your XML configuration validates against a deprecated schema. Migrate your XML configuration using "--migrate-configuration"!
No tests executed!
AFAIK, phpunit 10 is not supported as of today. You would have to migrate the configuration, but after this you will encounter other issues: See also https://github.com/bcit-ci/CodeIgniter/issues/6219
Try with a previous version.