Skip to content

ApiTestCase: assertJsonContains throws ArraySubset class not found error #3962

@geoff-maddock

Description

@geoff-maddock

API Platform version(s) affected: 2.5.9

Description
This issue started after upgrading API Platform core from 2.5.7 to 2.5.9

When making an assertion such as:

        $this->assertJsonContains([
            'content' => '127.0.0.1',
        ]);

The ArraySubset class is not being found:

20) App\Tests\Functional\ZoneTest::testPutMasterIp
Error: Class 'ApiPlatform\Core\Bridge\Symfony\Bundle\Test\Constraint\ArraySubset' not found

/srv/api/vendor/api-platform/core/src/Bridge/Symfony/Bundle/Test/ApiTestAssertionsTrait.php:98
/srv/api/vendor/api-platform/core/src/Bridge/Symfony/Bundle/Test/ApiTestAssertionsTrait.php:57
/srv/api/tests/Functional/ZoneTest.php:126

Looking at ArraySubset, it was changed from a class to an alias which should match to:
ApiPlatform\Core\Bridge\Symfony\Bundle\Test\Constraint\ArraySubsetV9
or
ApiPlatform\Core\Bridge\Symfony\Bundle\Test\Constraint\ArraySubsetLegacy

Which both appear to be in the project.

How to reproduce
Make a call to $this->assertJsonContains in a class that extends ApiTestCase

Possible Solution
Unknown.

Additional Context
Symfony 4.4. In phpunit.xml.dist we have

        <server name="SYMFONY_PHPUNIT_VERSION" value="8.3" />

I tried 8.4 and got the same error. 8.5 and I ran into more issues.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions