Description
Tests fail because of an incompatibility between phpunit, api-platform and symfony/test-pack.
Error: Declaration of ApiPlatform\Core\Bridge\Symfony\Bundle\Test\Constraint\ArraySubset::evaluate($other, string $description = '', bool $returnResult = false) should be compatible with PHPUnit\Framework\Constraint\Constraint::evaluate($other, $description = '', $returnResult = false)
How to reproduce
Downloaded and extracted API Platform 2.5.5 tarball.
docker-compose up
run composer require --dev alice test-pack http-client justinrainbow/json-schema in php instance
<?php
namespace App\Tests;
use ApiPlatform\Core\Bridge\Symfony\Bundle\Test\ApiTestCase;
use Hautelook\AliceBundle\PhpUnit\RefreshDatabaseTrait;
class GreetingTest extends ApiTestCase
{
use RefreshDatabaseTrait;
public function testGetCollection(): void
{
static::createClient()->request('GET', '/greetings');
$this->assertJsonContains([
'@context' => '/contexts/Greeting',
]);
}
}
run tests: php bin/phpunit
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.
Testing Project Test Suite
E 1 / 1 (100%)
Time: 693 ms, Memory: 32.50 MB
There was 1 error:
1) App\Tests\GreetingTest::testGetCollection
Declaration of ApiPlatform\Core\Bridge\Symfony\Bundle\Test\Constraint\ArraySubset::evaluate($other, string $description = '', bool $returnResult = false) should be compatible with PHPUnit\Framework\Constraint\Constraint::evaluate($other, $description = '', $returnResult = false)
/srv/api/vendor/api-platform/core/src/Bridge/Symfony/Bundle/Test/Constraint/ArraySubset.php:46
/srv/api/vendor/api-platform/core/src/Bridge/Symfony/Bundle/Test/Constraint/ArraySubset.php:32
/srv/api/vendor/symfony/error-handler/DebugClassLoader.php:337
/srv/api/vendor/api-platform/core/src/Bridge/Symfony/Bundle/Test/ApiTestAssertionsTrait.php:97
/srv/api/vendor/api-platform/core/src/Bridge/Symfony/Bundle/Test/ApiTestAssertionsTrait.php:56
/srv/api/tests/GreetingTest.php:17
Possible Solution
Changing SYMFONY_PHPUNIT_VERSION to 8.3 in api/phpunit.xml.dist had worked. should be added to docs!
API Platform version(s) affected: 2.5.5
Description
Tests fail because of an incompatibility between phpunit, api-platform and symfony/test-pack. Error:
Declaration of ApiPlatform\Core\Bridge\Symfony\Bundle\Test\Constraint\ArraySubset::evaluate($other, string $description = '', bool $returnResult = false) should be compatible with PHPUnit\Framework\Constraint\Constraint::evaluate($other, $description = '', $returnResult = false)
How to reproduce
composer require --dev alice test-pack http-client justinrainbow/json-schema
inphp
instanceapi/fixtures/greetings.yml
bin/console hautelook:fixtures:load
Created
api/tests/GreetingTest.php
run tests:
php bin/phpunit
Possible Solution
Changing
SYMFONY_PHPUNIT_VERSION
to8.3
inapi/phpunit.xml.dist
had worked. should be added to docs!Additional Context