2

I'm discovering API Platform and i'm now at the "Testing the API" step.

I get two different errors I can't resolve, event avec a composer install / update :

1) App\Tests\BooksTest::testGetCollection
Error: Call to undefined method ApiPlatform\Core\Bridge\Symfony\Bundle\Test\Constraint\ArraySubsetLegacy::exporter()

/srv/api/vendor/api-platform/core/src/Bridge/Symfony/Bundle/Test/Constraint/ArraySubsetTrait.php:76
/srv/api/vendor/api-platform/core/src/Bridge/Symfony/Bundle/Test/Constraint/ArraySubsetTrait.php:84
/srv/api/vendor/api-platform/core/src/Bridge/Symfony/Bundle/Test/Constraint/ArraySubsetTrait.php:68
/srv/api/vendor/api-platform/core/src/Bridge/Symfony/Bundle/Test/Constraint/ArraySubsetLegacy.php:32
/srv/api/vendor/api-platform/core/src/Bridge/Symfony/Bundle/Test/ApiTestAssertionsTrait.php:100
/srv/api/vendor/api-platform/core/src/Bridge/Symfony/Bundle/Test/ApiTestAssertionsTrait.php:57
/srv/api/tests/BooksTest.php:26

and

4) App\Tests\BooksTest::testUpdateBook
TypeError: Argument 2 passed to ApiPlatform\Core\Bridge\Symfony\Bundle\Test\Client::request() must be of the type string, null given, called in /srv/api/tests/BooksTest.php on line 103

/srv/api/vendor/api-platform/core/src/Bridge/Symfony/Bundle/Test/Client.php:88
/srv/api/tests/BooksTest.php:103

Any idea ?

Thx :-)

SimonFA
  • 31
  • 6
  • Can you show your BooksTest please? The tests with the lines from the stack trace (26 and 103) should be enough, if the file is too long. – dbrumann Dec 29 '20 at 17:17

1 Answers1

3

according to this issue on API Platform the API Platform framework uses phpUnit 7.5 by default, but some of the test functions use phpUnit 8.

you can supposedly set SYMFONY_PHPUNIT_VERSION to 8.3 as an environment variable, but that didn't work in my case. I had to edit api/phpunit.xml.dist and change the value in there to look like this:

<server name="SYMFONY_PHPUNIT_VERSION" value="8.3" />
Bucky
  • 58
  • 6
  • Thanks, it worked ! I tried to set it to 9 and it worked well too I don't know why they didn't fix this in their release though – SimonFA Jan 11 '21 at 07:13
  • from what i gleaned from the issue on github, it is a backwards compatibility issue. – Bucky Jan 13 '21 at 05:05