Hello,
I made a test in web app using CodeIgtiter 4.4.3. It works locally (Debian GNU/Linux 11, PHP 8.2) when spawned from terminal or from VSCode but it terminated with errors when it spawned in GitLab CI/CD
Code:
$ php vendor/bin/phpunit --exclude-group Database tests
Fatal error: Uncaught Error: Undefined constant "CodeIgniter\Test\SUPPORTPATH" in /builds/SKIPPED/vendor/phpunit/phpunit/src/Framework/TestBuilder.php:138
Stack trace:
#0 /builds/SKIPPED/vendor/phpunit/phpunit/src/Framework/TestBuilder.php(117): PHPUnit\Framework\TestBuilder->buildTestWithoutData('PersonModelTest')
#1 /builds/SKIPPED/vendor/phpunit/phpunit/src/Framework/TestSuite.php(890): PHPUnit\Framework\TestBuilder->build(Object(ReflectionClass), 'testPersonModel...')
#2 /builds/SKIPPED/vendor/phpunit/phpunit/src/Framework/TestSuite.php(231): PHPUnit\Framework\TestSuite->addTestMethod(Object(ReflectionClass), Object(ReflectionMethod))
#3 /builds/SKIPPED/vendor/phpunit/phpunit/src/Framework/TestSuite.php(361): PHPUnit\Framework\TestSuite->__construct(Object(ReflectionClass))
#4 /builds/SKIPPED/vendor/phpunit/phpunit/src/Framework/TestSuite.php(511): PHPUnit\Framework\TestSuite->addTestSuite(Object(ReflectionClass))
#5 /builds/SKIPPED/vendor/phpunit/phpunit/src/Framework/TestSuite.php(536): PHPUnit\Framework\TestSuite->addTestFile('/builds/trestol...')
#6 /builds/SKIPPED/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php(98): PHPUnit\Framework\TestSuite->addTestFiles(Array)
#7 /builds/SKIPPED/vendor/phpunit/phpunit/src/TextUI/Command.php(119): PHPUnit\Runner\BaseTestRunner->getTest('/builds/SKIPPED...', Array)
#8 /builds/SKIPPED/vendor/phpunit/phpunit/src/TextUI/Command.php(97): PHPUnit\TextUI\Command->run(Array, true)
#9 /builds/SKIPPED/vendor/phpunit/phpunit/phpunit(107): PHPUnit\TextUI\Command::main()
#10 /builds/SKIPPED/vendor/bin/phpunit(122): include('/builds/SKIPPED...')
#11 {main}
Next PHPUnit\TextUI\RuntimeException: Undefined constant "CodeIgniter\Test\SUPPORTPATH" in /builds/SKIPPED/vendor/phpunit/phpunit/src/TextUI/Command.php on line 99
PHPUnit\TextUI\RuntimeException: Undefined constant "CodeIgniter\Test\SUPPORTPATH" in /builds/SKIPPED/vendor/phpunit/phpunit/src/TextUI/Command.php on line 99
PersonModelTest skipped if tests are executel locally with --exclude-group Database but here I see an error.
tests/database/PersonModelTest.php is:
PHP Code:
<?php
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\DatabaseTestTrait;
use App\Models\PersonModel;
/**
* @group Database
*/
class PersonModelTest extends CIUnitTestCase
{
use DatabaseTestTrait;
protected $migrateOnce = true;
public function testPersonModelHasFields()
{
$model = new PersonModel();
$table = $model->table;
foreach (['document_number', 'address', 'email', 'phone'] as $field) {
// Get field names
// Check if table has $field
// Check if model allows to change $field
$columns = $model->getFieldNames($table);
$this->assertContains($field, $columns);
$this->assertContains($field, $model->allowedFields);
}
}
}
I tried to find solution here and in GutHub issues but without any success. How can I eliminate this error? Is there any documentation about CI4 and GitLab’s CI/CD?