Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self referencing array breaks with PHPUnit 5.7 but worked with PHPUnit 4.8 #2572

Closed
lebris opened this issue Mar 17, 2017 · 0 comments
Closed

Comments

@lebris
Copy link

lebris commented Mar 17, 2017

Q A
PHPUnit version 5.7.16
PHP version 5.6.30
Installation Method Composer

I'm trying to run the following test with Phpunit 5.7.16. The test does not fail when using PHPUnit 4.8.35.
I'm using PHP 5.6.30.

<?php

namespace Puzzle\Pieces;

class Json
{
        public static function encode($value, $option = 0, $depth = 512)
        {
            $json = json_encode($value, $option, $depth);

            if($json === false)
            {
                $jsonLastError = json_last_error();

                throw new Exceptions\JsonEncodeError(json_last_error_msg());
            }

            return $json;
        }
}
<?php

namespace Puzzle\Pieces;

class JsonTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @dataProvider providerTestJsonEncodeException
     * @expectedException Puzzle\Pieces\Exceptions\JsonEncodeError
     */
    public function testJsonEncodeException($data)
    {
        Json::encode($data);
    }

    public function providerTestJsonEncodeException()
    {
        $recursionData = array();
        $recursionData[] = &$recursionData;

        return [
            'JSON_ERROR_RECURSION' => [
                'data' => $recursionData,
            ]
        ];
    }
}

Here the error.

Fatal error: Maximum function nesting level of '256' reached, aborting! in /usr/src/puzzle-pieces/vendor/phpunit/phpunit/src/Framework/TestCase.php on line 2442
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants