liip / LiipFunctionalTestBundle

Some helper classes for writing functional tests in Symfony

Home Page:http://liip.ch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

$this->assertValidationErrors error: Cannot call constructor

lukepass opened this issue · comments

Preconditions

I am using Symfony 3.4 with the following bundles:

liip/functional-test-bundle 3.1.0 3.1.0 This bundles provides additional functional test-cases fo...
liip/test-fixtures-bundle   1.0.1 1.0.1 This bundles enables efficient loading of Doctrine fixtur...

Steps to reproduce

  1. Create a class that extends Liip\FunctionalTestBundle\Test\WebTestCase
  2. Use the following method: $this->assertValidationErrors([], $client->getContainer())

Expected result

  1. The list of validation errors should be shown

Actual result

My code:

    public function testRegisterNoInput()
    {
        $client  = $this->makeClient();
        $crawler = $client->request(
            'POST',
            '/api/patients/register'
        );

        $this->assertIsBadRequestRestApiError($client, ApiResponse::CODE_INVALID_INPUT);
        $this->assertValidationErrors([], $client->getContainer());
    }
PHPUnit 8.2.4 by Sebastian Bergmann and contributors.

Testing Project Test Suite
E                                                                   1 / 1 (100%)

Time: 290 ms, Memory: 36.25 MB

There was 1 error:

1) Tests\AppBundle\Controller\Api\PatientControllerTest::testRegisterNoInput
Error: Cannot call constructor

/vendor/liip/functional-test-bundle/src/Test/ValidationErrorsConstraint.php:33
/vendor/liip/functional-test-bundle/src/Utils/HttpAssertions.php:101
/vendor/liip/functional-test-bundle/src/Test/WebTestCase.php:409
/tests/AppBundle/Controller/Api/PatientControllerTest.php:19

ERRORS!
Tests: 1, Assertions: 5, Errors: 1.

Remaining direct deprecation notices (3)

Remaining indirect deprecation notices (3)

It seems that the class ValidationErrorsConstraint is calling parent::__construct() but Constraint doesn't have a parent constructor.

The constructor of PHPUnit\Framework\Constraint was removed in PHPUnit 8.

The issue will be fixed in #541

commented

Unfortunately this is still open. @alexislefebvre Why don't you finish your fix?