[1.3.3] Phalcon phpunit bug $di::reset();
i have using Phalcon Test Case,and i receive an error.
Environment: phalcon 1.3.3 phalcon/incubator:dev-master
when test case more then two files, error logs:
PHPUnit 4.3.5 by Sebastian Bergmann.
Configuration read from /www/html/tests/phpunit.xml
.PHP Fatal error: Class name must be a valid object or a string in /vendor/phalcon/incubator/Library/Phalcon/Test/UnitTestCase.php on line 156
Fatal error: Class name must be a valid object or a string in /vendor/phalcon/incubator/Library/Phalcon/Test/UnitTestCase.php on line 156
when i Comments phalcon/incubator/Library/Phalcon/Test/UnitTestCase.php on line 156, its work
protected function tearDown()
{
$di = $this->getDI();
// $di::reset();
parent::tearDown();
}
my config:
phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./TestHelper.php"
backupGlobals="false"
backupStaticAttributes="false"
verbose="true"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="true">
<testsuite name="Phalcon - Testsuite">
<directory>./</directory>
</testsuite>
</phpunit>
other config same as http://docs.phalconphp.com/en/latest/reference/unit-testing.html
sorry for my poor english.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Any news on this? I'm running into the same error and can't figure it out. When running phpunit on my local machine, it works fine, but in Jenkins I see the above behavior. This seems to be related to Jenkins in a way, because when I start phpunit on Jenkins in the workspace-directory manually, it does work.
I managed to fix it: I was trying to connect to the wrong database, but the error ("Access denied for user 'root'@'localhost' (using password: NO)") never showed. Once I commented line 156 in UnitTestCase.php, the original error ("Class name must be a valid object or a string") disappeard and the database-error showed up, leading me to the solution.
Still a very strange behavior and a misleading error message.
Another cause for this can be too little resources on the database-server: each unit-test will create a new database-connect after di::reset(). Once the limit of connections that the server can handle, is reached, the unittests fail with the above error. Use "persistent => true" when opening your db-connection in the UnitTestCase to get rid of this annoying error.
Just chiming in that I too have run into this error. Don't know why reset is doing such a poor job at obscuring errors, but I would be extremely appreciative of a fix that allowed the actual error to pass through, instead of suppressing it and returning a baffling substitute.
I also got this error: Fatal error: Class name must be a valid object or a string in C:...\vendor\phalcon\incubator\Library\Phalcon\Test\UnitTestCase.php on line 167 Phalcon v. 2.0.7
The 1.3.x branch is not longer supported.