Closed pgee70 closed 3 years ago
ok, i have found a fix for this in your library, on version 3.0.0
i changed all the instances of TestCase::isTestingEnv()
to CIPHPUnitTestCase::isTestingEnv()
and the issue resolves.
This makes sense because your code-base is not name-spaced, and mine is. ie my tests are name-spaced as i3soft\tests and use psr autoloading. By explicitly referencing CIPHPUnitTestCase i run your code.
@pgee70 Yes, ci-phpunit-test requires not name-spaced TestCase::isTestingEnv()
.
This is so that CIPHPUnitTestCase::isTestingEnv()
can be overridden.
To override the method you can change the environment testing
during test execution:
https://github.com/kenjis/ci-phpunit-test/blob/202441b1d2143eb602a3804854297da1d23dc4d5/application/tests/_ci_phpunit_test/CIPHPUnitTestCase.php#L467-L470
If you don't change testing
, your solution is no problem.
Another solution is to make a class alias:
class_alias('i3soft\tests\TestCase', 'TestCase');
i have been using your framework for a number of years now.
using kenjis/ci-phpunit-test installed via composer, "kenjis/ci-phpunit-test": "3.x-dev", phpunit is also installed via composer: "phpunit/phpunit": "9.5.4"
I haven't changed my unit tests, which were working before the upgrade. i removed the cache folder after upgrading.
After recent updates i am having the problem of
Error: Class 'TestCase' not found
This error only occurs in tests that use controllers. for example:my tracing found that in the file
vendor/kenjis/ci-phpunit-test/application/tests/_ci_phpunit_test/replacing/core/Common.php
line 304:the line 304 is TestCase::isTestingEnv(), and for some reason TestCase is not loaded. Furthermore my spl_autoload_register has a case to load TestCase, which it does, and the line still fails to find the class.
my TestCase.php is in
application/tests
and extends CIPHPUnitTestCaseabstract class TestCase extends CIPHPUnitTestCase
all my tests then extend TestCase.So any help working out what i have done wrong with the update from the earlier version would be appreciated!