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

Not an issue, just a note - tests fail #2901

Closed
adriansuter opened this issue Dec 18, 2019 · 5 comments · Fixed by #2902
Closed

Not an issue, just a note - tests fail #2901

adriansuter opened this issue Dec 18, 2019 · 5 comments · Fixed by #2902
Labels

Comments

@adriansuter
Copy link
Contributor

adriansuter commented Dec 18, 2019

PHPUnit seems to fail when using the currently newest phpsec/prophecy version 1.10.0.

See phpspec/prophecy#457 and phpspec/prophecy#458

@adriansuter adriansuter changed the title Not an issue, just a note Not an issue, just a note - tests fail Dec 18, 2019
@l0gicgate
Copy link
Member

Do you have a log of the failures? We should probably address that

@adriansuter
Copy link
Contributor Author

Sure, here it is.

Composer output:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 65 installs, 0 updates, 0 removals
  - Installing ocramius/package-versions (1.4.2): Loading from cache
  - Installing nikic/fast-route (v1.3.0): Loading from cache
  - Installing ralouphie/getallheaders (3.0.3): Loading from cache
  - Installing psr/http-message (1.0.1): Loading from cache
  - Installing guzzlehttp/psr7 (1.6.1): Loading from cache
  - Installing psr/http-factory (1.0.1): Loading from cache
  - Installing http-interop/http-factory-guzzle (1.0.0): Loading from cache
  - Installing nyholm/psr7-server (0.3.0): Loading from cache
  - Installing slim/http (0.7): Loading from cache
  - Installing fig/http-message-util (1.1.3): Loading from cache
  - Installing slim/psr7 (0.3.0): Loading from cache
  - Installing psr/http-server-handler (1.0.1): Loading from cache
  - Installing psr/http-server-middleware (1.0.1): Loading from cache
  - Installing php-http/message-factory (v1.0.2): Loading from cache
  - Installing nyholm/psr7 (1.2.1): Loading from cache
  - Installing sebastian/version (2.0.1): Loading from cache
  - Installing sebastian/resource-operations (2.0.1): Loading from cache
  - Installing sebastian/recursion-context (3.0.0): Loading from cache
  - Installing sebastian/object-reflector (1.1.1): Loading from cache
  - Installing sebastian/object-enumerator (3.0.3): Loading from cache
  - Installing sebastian/global-state (2.0.0): Loading from cache
  - Installing sebastian/exporter (3.1.2): Loading from cache
  - Installing sebastian/environment (4.2.3): Loading from cache
  - Installing sebastian/diff (3.0.2): Loading from cache
  - Installing sebastian/comparator (3.0.2): Loading from cache
  - Installing phpunit/php-timer (2.1.2): Loading from cache
  - Installing phpunit/php-text-template (1.2.1): Loading from cache
  - Installing phpunit/php-file-iterator (2.0.2): Loading from cache
  - Installing theseer/tokenizer (1.1.3): Loading from cache
  - Installing sebastian/code-unit-reverse-lookup (1.0.1): Loading from cache
  - Installing phpunit/php-token-stream (3.1.1): Loading from cache
  - Installing phpunit/php-code-coverage (6.1.4): Loading from cache
  - Installing doctrine/instantiator (1.3.0): Loading from cache
  - Installing symfony/polyfill-ctype (v1.13.1): Loading from cache
  - Installing webmozart/assert (1.6.0): Loading from cache
  - Installing phpdocumentor/reflection-common (2.0.0): Loading from cache
  - Installing phpdocumentor/type-resolver (1.0.1): Loading from cache
  - Installing phpdocumentor/reflection-docblock (4.3.2): Loading from cache
  - Installing phpspec/prophecy (1.10.0): Loading from cache
  - Installing phar-io/version (2.0.1): Loading from cache
  - Installing phar-io/manifest (1.0.3): Loading from cache
  - Installing myclabs/deep-copy (1.9.4): Loading from cache
  - Installing phpunit/phpunit (7.5.18): Loading from cache
  - Installing symfony/finder (v4.4.1): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing symfony/service-contracts (v1.1.8): Loading from cache
  - Installing symfony/polyfill-php73 (v1.13.1): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.13.1): Loading from cache
  - Installing symfony/console (v4.4.1): Loading from cache
  - Installing psr/log (1.1.2): Loading from cache
  - Installing phpstan/phpdoc-parser (0.3.5): Loading from cache
  - Installing nikic/php-parser (v4.3.0): Loading from cache
  - Installing nette/utils (v3.0.2): Loading from cache
  - Installing nette/schema (v1.0.1): Loading from cache
  - Installing nette/finder (v2.5.1): Loading from cache
  - Installing nette/robot-loader (v3.2.0): Loading from cache
  - Installing nette/neon (v3.0.0): Loading from cache
  - Installing nette/php-generator (v3.3.1): Loading from cache
  - Installing nette/di (v3.0.1): Loading from cache
  - Installing nette/bootstrap (v3.0.1): Loading from cache
  - Installing jean85/pretty-package-versions (1.2): Loading from cache
  - Installing composer/xdebug-handler (1.4.0): Loading from cache
  - Installing phpstan/phpstan (0.11.19): Loading from cache
  - Installing squizlabs/php_codesniffer (3.5.3): Loading from cache
  - Installing zendframework/zend-diactoros (2.2.1): Loading from cache
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
sebastian/global-state suggests installing ext-uopz (*)
sebastian/environment suggests installing ext-posix (*)
phpunit/phpunit suggests installing phpunit/php-invoker (^2.0)
symfony/service-contracts suggests installing symfony/service-implementation
symfony/console suggests installing symfony/event-dispatcher
symfony/console suggests installing symfony/lock
symfony/console suggests installing symfony/process
nette/bootstrap suggests installing tracy/tracy (to use Configurator::enableTracy())
Writing lock file
Generating autoload files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class

PHPUnit output

PHPUnit 7.5.18 by Sebastian Bergmann and contributors.

...............................................................  63 / 411 ( 15%)
..........................F.................................... 126 / 411 ( 30%)
............................................................... 189 / 411 ( 45%)
............................................................... 252 / 411 ( 61%)
............................................................... 315 / 411 ( 76%)
......................EEEEEEEE.E..E............................ 378 / 411 ( 91%)
...........EEEE....EEEEF.........                               411 / 411 (100%)

Time: 10.37 seconds, Memory: 22.00 MB

There were 18 errors:

1) Slim\Tests\Routing\RouteCollectorProxyTest::testGet
TypeError: Return value of Double\RouteCollectorInterface\P4::map() must implement interface Slim\Interfaces\RouteInterface, null returned

D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:181
D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:123
D:\Documents\GitHub\Slim\tests\Routing\RouteCollectorProxyTest.php:148

2) Slim\Tests\Routing\RouteCollectorProxyTest::testPost
TypeError: Return value of Double\RouteCollectorInterface\P4::map() must implement interface Slim\Interfaces\RouteInterface, null returned

D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:181
D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:131
D:\Documents\GitHub\Slim\tests\Routing\RouteCollectorProxyTest.php:181

3) Slim\Tests\Routing\RouteCollectorProxyTest::testPut
TypeError: Return value of Double\RouteCollectorInterface\P4::map() must implement interface Slim\Interfaces\RouteInterface, null returned

D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:181
D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:139
D:\Documents\GitHub\Slim\tests\Routing\RouteCollectorProxyTest.php:214

4) Slim\Tests\Routing\RouteCollectorProxyTest::testPatch
TypeError: Return value of Double\RouteCollectorInterface\P4::map() must implement interface Slim\Interfaces\RouteInterface, null returned

D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:181
D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:147
D:\Documents\GitHub\Slim\tests\Routing\RouteCollectorProxyTest.php:247

5) Slim\Tests\Routing\RouteCollectorProxyTest::testDelete
TypeError: Return value of Double\RouteCollectorInterface\P4::map() must implement interface Slim\Interfaces\RouteInterface, null returned

D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:181
D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:155
D:\Documents\GitHub\Slim\tests\Routing\RouteCollectorProxyTest.php:280

6) Slim\Tests\Routing\RouteCollectorProxyTest::testOptions
TypeError: Return value of Double\RouteCollectorInterface\P4::map() must implement interface Slim\Interfaces\RouteInterface, null returned

D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:181
D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:163
D:\Documents\GitHub\Slim\tests\Routing\RouteCollectorProxyTest.php:313

7) Slim\Tests\Routing\RouteCollectorProxyTest::testAny
TypeError: Return value of Double\RouteCollectorInterface\P4::map() must implement interface Slim\Interfaces\RouteInterface, null returned

D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:181
D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:171
D:\Documents\GitHub\Slim\tests\Routing\RouteCollectorProxyTest.php:346

8) Slim\Tests\Routing\RouteCollectorProxyTest::testMap
TypeError: Return value of Double\RouteCollectorInterface\P4::map() must implement interface Slim\Interfaces\RouteInterface, null returned

D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:181
D:\Documents\GitHub\Slim\tests\Routing\RouteCollectorProxyTest.php:380

9) Slim\Tests\Routing\RouteCollectorProxyTest::testGroup
TypeError: Return value of Double\RouteCollectorInterface\P4::group() must implement interface Slim\Interfaces\RouteGroupInterface, null returned

D:\Documents\GitHub\Slim\Slim\Routing\RouteCollectorProxy.php:191
D:\Documents\GitHub\Slim\tests\Routing\RouteCollectorProxyTest.php:454

10) Slim\Tests\Routing\RouteCollectorTest::testMapPrependsGroupPattern
TypeError: Return value of Double\CallableResolverInterface\P3::resolve() must be callable, null returned

D:\Documents\GitHub\Slim\Slim\Routing\RouteGroup.php:72
D:\Documents\GitHub\Slim\Slim\Routing\RouteCollector.php:253
D:\Documents\GitHub\Slim\tests\Routing\RouteCollectorTest.php:81

11) Slim\Tests\RouteTest::testAddMiddleware
TypeError: Return value of Double\CallableResolverInterface\P3::resolve() must be callable, null returned

D:\Documents\GitHub\Slim\Slim\Routing\Route.php:360
D:\Documents\GitHub\Slim\tests\Routing\RouteTest.php:265
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:275
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\Routing\Route.php:333
D:\Documents\GitHub\Slim\tests\Routing\RouteTest.php:270

12) Slim\Tests\RouteTest::testAddMiddlewareOnGroup
TypeError: Return value of Double\CallableResolverInterface\P3::resolve() must be callable, null returned

D:\Documents\GitHub\Slim\Slim\Routing\Route.php:360
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\tests\Routing\RouteTest.php:301
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:275
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\Routing\Route.php:333
D:\Documents\GitHub\Slim\tests\Routing\RouteTest.php:325

13) Slim\Tests\RouteTest::testAddClosureMiddleware
TypeError: Return value of Double\CallableResolverInterface\P3::resolve() must be callable, null returned

D:\Documents\GitHub\Slim\Slim\Routing\Route.php:360
D:\Documents\GitHub\Slim\tests\Routing\RouteTest.php:337
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:275
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\Routing\Route.php:333
D:\Documents\GitHub\Slim\tests\Routing\RouteTest.php:341

14) Slim\Tests\RouteTest::testAddMiddlewareUsingDeferredResolution
TypeError: Return value of Double\CallableResolverInterface\P3::resolve() must be callable, null returned

D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:187
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\Routing\Route.php:333
D:\Documents\GitHub\Slim\tests\Routing\RouteTest.php:356

15) Slim\Tests\RouteTest::testControllerMethodAsStringResolvesWithContainer
TypeError: Return value of Double\CallableResolverInterface\P3::resolve() must be callable, null returned

D:\Documents\GitHub\Slim\Slim\Routing\Route.php:360
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\Routing\Route.php:333
D:\Documents\GitHub\Slim\tests\Routing\RouteTest.php:446

16) Slim\Tests\RouteTest::testProcessWhenReturningAResponse
TypeError: Return value of Double\CallableResolverInterface\P3::resolve() must be callable, null returned

D:\Documents\GitHub\Slim\Slim\Routing\Route.php:360
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\Routing\Route.php:333
D:\Documents\GitHub\Slim\tests\Routing\RouteTest.php:465

17) Slim\Tests\RouteTest::testRouteCallableDoesNotAppendEchoedOutput
TypeError: Return value of Double\CallableResolverInterface\P3::resolve() must be callable, null returned

D:\Documents\GitHub\Slim\Slim\Routing\Route.php:360
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\Routing\Route.php:333
D:\Documents\GitHub\Slim\tests\Routing\RouteTest.php:486

18) Slim\Tests\RouteTest::testRouteCallableAppendsCorrectOutputToResponse
TypeError: Return value of Double\CallableResolverInterface\P3::resolve() must be callable, null returned

D:\Documents\GitHub\Slim\Slim\Routing\Route.php:360
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\Routing\Route.php:333
D:\Documents\GitHub\Slim\tests\Routing\RouteTest.php:507

--

There were 2 failures:

1) Slim\Tests\AppTest::testInvokeWithNonExistentMethodOnCallableRegisteredInContainer
Failed asserting that exception of type "Error" matches expected exception "RuntimeException". Message was: "Call to a member function withAttribute() on null" at
D:\Documents\GitHub\Slim\Slim\Middleware\RoutingMiddleware.php:89
D:\Documents\GitHub\Slim\Slim\Routing\RouteRunner.php:71
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\App.php:208
D:\Documents\GitHub\Slim\tests\AppTest.php:1433
.

2) Slim\Tests\RouteTest::testInvokeWithException
Failed asserting that exception of type "TypeError" matches expected exception "\Exception". Message was: "Return value of Double\CallableResolverInterface\P3::resolve() must be callable, null returned" at
D:\Documents\GitHub\Slim\Slim\Routing\Route.php:360
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\Routing\Route.php:333
D:\Documents\GitHub\Slim\tests\Routing\RouteTest.php:523
.

ERRORS!
Tests: 411, Assertions: 714, Errors: 18, Failures: 2.

Generating code coverage report in HTML format ... done

@adriansuter
Copy link
Contributor Author

The problem might be, that the developers of the prophecy library have modified \Prophecy\Argument\Token\ExactValueToken::scoreArgument(). It returns false in case the argument is an object and the comparator fails, see

https://github.com/phpspec/prophecy/blob/d638ebbb58daba25a6a0dc7969e1358a0e3c6682/src/Prophecy/Argument/Token/ExactValueToken.php#L63

Unforunately, this is the case for the \Prophecy\Comparator\ClosureComparator. Because its assertEquals() throws an exception for all cases, see

https://github.com/phpspec/prophecy/blob/d638ebbb58daba25a6a0dc7969e1358a0e3c6682/src/Prophecy/Comparator/ClosureComparator.php#L30-L41

Back to Slim

Maybe, we should change the method prophecies containing a closure as expected argument.

I tried to change the line

->map(['GET'], $pattern, $callable)

into

            ->map(['GET'], $pattern, Argument::is($callable))

which seems to work. Not sure if that is the intended way to go, though.

By the way, Argument::is() returns a \Prophecy\Argument\Token\IdenticalValueToken which compares using a ===.

@adriansuter
Copy link
Contributor Author

adriansuter commented Dec 19, 2019

I brought it down to one failure and one error. See https://github.com/adriansuter/Slim/tree/patch-prophecies, Commit adriansuter@c853037

See also https://travis-ci.org/adriansuter/Slim/jobs/627200622#L563

There was 1 error:

1) Slim\Tests\RouteTest::testAddMiddlewareUsingDeferredResolution
TypeError: Return value of Double\CallableResolverInterface\P3::resolve() must be callable, null returned

D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:187
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\Routing\Route.php:333
D:\Documents\GitHub\Slim\tests\Routing\RouteTest.php:356

--

There was 1 failure:

1) Slim\Tests\AppTest::testInvokeWithNonExistentMethodOnCallableRegisteredInContainer
Failed asserting that exception of type "Error" matches expected exception "RuntimeException". Message was: "Call to a member function withAttribute() on null" at
D:\Documents\GitHub\Slim\Slim\Middleware\RoutingMiddleware.php:89
D:\Documents\GitHub\Slim\Slim\Routing\RouteRunner.php:71
D:\Documents\GitHub\Slim\Slim\MiddlewareDispatcher.php:73
D:\Documents\GitHub\Slim\Slim\App.php:208
D:\Documents\GitHub\Slim\tests\AppTest.php:1433
.

ERRORS!
Tests: 411, Assertions: 755, Errors: 1, Failures: 1.

@l0gicgate
Copy link
Member

That's so weird that they introduced such a breaking change on a minor version.. Well we definitely will need to fix all the repos. Ugh

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

Successfully merging a pull request may close this issue.

2 participants