Testcase for a fatal error

I need to be able to create a test case, so I can avoid a fatal error in one of my projects.

https://sourceforge.net/tracker/?func=detail&aid=2979466&group_id=108380&atid=650322

How do I create a test case, when the error is?


class Bug2979466TestCase extends UnitTestCase {

    function __construct() {
        parent::__construct('Bug2979466 Test');
    }

    function testThisDoesNotWorkAsExpected() {
        $filename = dirname(__FILE__) . '/images/bug2979466.jpg';
        try {
            $jpeg = new PelJpeg($filename);

        } catch (Exception $e) {
            $this->fail('Test should not throw an exception');
        }
    }
}


Fatal error: Maximum function nesting level of '100' reached, aborting! in /home/lsolesen/workspace/pel-git/src/PelConvert.php on line 287

Call Stack:
    0.0005     341052   1. {main}() /home/lsolesen/workspace/pel-git/test/run-tests.php:0
    0.0601    4765064   2. TestSuite->run() /home/lsolesen/workspace/pel-git/test/run-tests.php:91
    1.3083    6477848   3. TestSuite->run() /usr/share/php/test_case.php:598
    1.3084    6478608   4. SimpleTestCase->run() /usr/share/php/test_case.php:595
    1.3092    6478088   5. SimpleExceptionTrappingInvoker->invoke() /usr/share/php/test_case.php:143
    1.3093    6478680   6. SimpleInvokerDecorator->invoke() /usr/share/php/exceptions.php:43
    1.3093    6478680   7. SimpleErrorTrappingInvoker->invoke() /usr/share/php/invoker.php:126
    1.3093    6479672   8. SimpleInvokerDecorator->invoke() /usr/share/php/errors.php:49
    1.3093    6479672   9. SimpleInvoker->invoke() /usr/share/php/invoker.php:126
    1.3093    6479716  10. Bug2979466TestCase->testThisDoesNotWorkAsExpected() /usr/share/php/invoker.php:68
    1.3093    6480204  11. PelJpeg->__construct() /home/lsolesen/workspace/pel-git/test/bug2979466.php:33
    1.3093    6480204  12. PelJpeg->loadFile() /home/lsolesen/workspace/pel-git/src/PelJpeg.php:167
    1.3094    6485188  13. PelJpeg->load() /home/lsolesen/workspace/pel-git/src/PelJpeg.php:313
    1.3099    6489072  14. PelExif->load() /home/lsolesen/workspace/pel-git/src/PelJpeg.php:242
    1.3100    6489388  15. PelTiff->load() /home/lsolesen/workspace/pel-git/src/PelExif.php:121
    1.3101    6490092  16. PelIfd->load() /home/lsolesen/workspace/pel-git/src/PelTiff.php:164
    1.3134    6526172  17. PelIfd->load() /home/lsolesen/workspace/pel-git/src/PelIfd.php:240
    1.3209    6603284  18. PelIfd->load() /home/lsolesen/workspace/pel-git/src/PelIfd.php:240
    1.3363    7106644  19. PelIfd->load() /home/lsolesen/workspace/pel-git/src/PelIfd.php:240
    1.3525    7635704  20. PelIfd->load() /home/lsolesen/workspace/pel-git/src/PelIfd.php:240
    1.3687    8190580  21. PelIfd->load() /home/lsolesen/workspace/pel-git/src/PelIfd.php:240
    1.3849    8770876  22. PelIfd->load() /home/lsolesen/workspace/pel-git/src/PelIfd.php:240
    1.4013    9376848  23. PelIfd->load() /home/lsolesen/workspace/pel-git/src/PelIfd.php:240
    1.4179   10008528  24. PelIfd->load() /home/lsolesen/workspace/pel-git/src/PelIfd.php:240

Thanks in advance :slight_smile:

After talking to kyberfabrikken, I think I will just fix the code, so it will not be stuck in an infinite loop. However, I have tried, but have not been able to figure out what the problem is.

Maybe, someone here can help?

Hi…

The load() call is stuck in an infinite loop. This is below the level SimpleTest operates.

The only way to protect the test suite from this type of error is to run that test in a separate process. Do you want instructions on doing that?

yours, Marcus