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

PHPUnit broken in new setup project #2437

Closed
RobQuistNL opened this issue May 1, 2023 · 4 comments
Closed

PHPUnit broken in new setup project #2437

RobQuistNL opened this issue May 1, 2023 · 4 comments
Labels

Comments

@RobQuistNL
Copy link

RobQuistNL commented May 1, 2023

API Platform version(s) affected: core 3.1.10

Description
Creating a project from the Github template (https://github.com/api-platform/api-platform/generate), then running docker compose exec php php ./vendor/bin/simple-phpunit throws an exception;

$ docker compose exec php php ./vendor/bin/simple-phpunit
PHPUnit 9.5.28 by Sebastian Bergmann and contributors.

Testing 
PHP Fatal error:  Declaration of SebastianBergmann\Comparator\ArrayComparator::assertEquals(mixed $expected, mixed $actual, float $delta = 0, bool $canonicalize = false, bool $ignoreCase = false, array &$processed = []): void must be compatible with SebastianBergmann\Comparator\Comparator::assertEquals($expected, $actual, $delta = 0, $canonicalize = false, $ignoreCase = false) in /srv/app/vendor/sebastian/comparator/src/ArrayComparator.php on line 36

Fatal error: Declaration of SebastianBergmann\Comparator\ArrayComparator::assertEquals(mixed $expected, mixed $actual, float $delta = 0, bool $canonicalize = false, bool $ignoreCase = false, array &$processed = []): void must be compatible with SebastianBergmann\Comparator\Comparator::assertEquals($expected, $actual, $delta = 0, $canonicalize = false, $ignoreCase = false) in /srv/app/vendor/sebastian/comparator/src/ArrayComparator.php on line 36

Remaining indirect deprecation notices (1)

  1x: The "Monolog\Logger" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Bridge\Monolog\Logger".
    1x in AuthenticationTest::testLogin from App\Tests

Symfony\Component\ErrorHandler\Error\FatalError^ {#13
  #message: "Compile Error: Declaration of SebastianBergmann\Comparator\ArrayComparator::assertEquals(mixed $expected, mixed $actual, float $delta = 0, bool $canonicalize = false, bool $ignoreCase = false, array &$processed = []): void must be compatible with SebastianBergmann\Comparator\Comparator::assertEquals($expected, $actual, $delta = 0, $canonicalize = false, $ignoreCase = false)"
  #code: 0
  #file: "/srv/app/vendor/sebastian/comparator/src/ArrayComparator.php"
  #line: 36
  -error: array:4 [
    "type" => 64
    "message" => "Declaration of SebastianBergmann\Comparator\ArrayComparator::assertEquals(mixed $expected, mixed $actual, float $delta = 0, bool $canonicalize = false, bool $ignoreCase = false, array &$processed = []): void must be compatible with SebastianBergmann\Comparator\Comparator::assertEquals($expected, $actual, $delta = 0, $canonicalize = false, $ignoreCase = false)"
    "file" => "/srv/app/vendor/sebastian/comparator/src/ArrayComparator.php"
    "line" => 36
  ]
}

How to reproduce
Clone project
Add alice by running composer require alice as described in the docs
Run tests

Possible Solution
Change the versions of PHPUnit that are used?

@Romaixn
Copy link

Romaixn commented May 9, 2023

It seems that it is due to hautelook/alice-bundle which uses an older version of sebastian/comparator : sebastianbergmann/comparator#51 (comment). It is possible to work around the problem using the solution proposed in the issue or by depending on the fork of @theofidry like mentionned here : nelmio/alice#1089

Hope this helps!

@soyuka soyuka closed this as completed May 9, 2023
@RobQuistNL
Copy link
Author

Okay, so I've added

    "repositories": [
        {
            "type": "vcs",
            "url": "git@github.com:theofidry/AliceBundle"
        },
    ],

to my composer.json

Then ran docker compose exec php composer require --dev alice

But;

$ docker compose exec php php ./vendor/bin/simple-phpunit
PHPUnit 9.5.28 by Sebastian Bergmann and contributors.

Testing 
PHP Fatal error:  Declaration of SebastianBergmann\Comparator\ArrayComparator::assertEquals(mixed $expected, mixed $actual, float $delta = 0, bool $canonicalize = false, bool $ignoreCase = false, array &$processed = []): void must be compatible with SebastianBergmann\Comparator\Comparator::assertEquals($expected, $actual, $delta = 0, $canonicalize = false, $ignoreCase = false) in /srv/app/vendor/sebastian/comparator/src/ArrayComparator.php on line 36

Fatal error: Declaration of SebastianBergmann\Comparator\ArrayComparator::assertEquals(mixed $expected, mixed $actual, float $delta = 0, bool $canonicalize = false, bool $ignoreCase = false, array &$processed = []): void must be compatible with SebastianBergmann\Comparator\Comparator::assertEquals($expected, $actual, $delta = 0, $canonicalize = false, $ignoreCase = false) in /srv/app/vendor/sebastian/comparator/src/ArrayComparator.php on line 36

@RobQuistNL
Copy link
Author

Adding

    "optimize-autoloader": true,
    "prepend-autoloader": false,

in the config section of the composer.json seems to have helped.

@RobQuistNL
Copy link
Author

Turns out only the latter was required, so adding "prepend-autoloader": false, fixes it.

vasilvestre added a commit to vasilvestre/core that referenced this issue Oct 20, 2023
soyuka pushed a commit to api-platform/core that referenced this issue Oct 30, 2023
* ci: fix phpunit


???

* Unset handler_id for symfony 6.3+

* Fix serializer configuration for PHP 8.1 (dev)

* Fix api-platform/api-platform#2437

* Fix excepted deprecation in swagger


Trigger deprecation to fit tests. Can change test if needed


forgot semicolon


try fix deprecation

* remove copied WebTestCase to fix 8.1 dev

PR symfony/symfony#32207 got merged

* fix no deprecation

* try tag legacy to valide


add a bc layer for reworked profiler UI

* fix warning about deprecated method


ensure method exists

* skip an exceptDeprecation, this case fails for a particular CI run

* remove uneccesary changes

* change BC deprecation system for doctrine

* fix some deprecations about validation html mode and attributes for recent sf

* fix doctrine lexer deprecations

* fix bootstrap missing

* improve doc for sf 6


f


Fix tiny bug & deprecation


--

* fix possible deprecation on 7.4

* Update ci.yml

* Update ci.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants