slimphp / Slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.
http://slimframework.com
MIT License
11.94k stars 1.95k forks source link

PSR-7 Compatibility #1506

Closed geggleto closed 8 years ago

geggleto commented 9 years ago

Is Slim 3.0 actually PSR-7 Swappable? It is not.

Results of commenting out non-psr-7 methods on Slim Classes Tests: 362, Assertions: 231, Errors: 213.

Gist log of my PHPUnit test https://gist.github.com/geggleto/c4b73336ef9507e24c48

1) Slim\Http\Request::registerMediaTypeParser 2) Slim\Http\Uri::getBasePath() 3) Slim\Http\Uri::withBasePath() 4) Slim\Http\Response::write() 5) Response::withRedirect() 6) Response::isEmpty() 7) Response::isInformational() 8) Response::isOk() 9) Response::isSuccessful() 10) ... a lot of these are failing because they are just tests and not that they are used internally.

codeguy commented 9 years ago

All easy fixes though. Want to send a PR for each?

geggleto commented 9 years ago

Updated ... will add more detail later

ppetermann commented 8 years ago

Ok, quick look through the tests:

the most common one is undefined method for registerMediaTypeParser. This method is called from within the constructor of the request object, if you replace the request object, it won't be called either (thats the thing with commenting out methods, it doesn't have the same effect, as you'd have to comment out internal usage of 'em as well)

then theres a lot where the tests for response/request/uri test their methods, which is absolutely fine, and it is correct that they are failing if the methods are commented out. other psr-7 implementations should have their own tests (usually in the lib they come from)

Then there is a broken Test, as the test shouldn't be calling write, but use the PSR interface. 21) Slim\Tests\AppTest::testFinalize PHPUnit_Framework_Exception: Fatal error: Call to undefined method Slim\Http\Response::write() in C:\Users\Glenn\Documents\GitHub\Slim\tests\AppTest.php on line 850

and the last oneshould have been fixed a while ago: https://github.com/slimphp/Slim/issues/1420 not sure if it resurfaced (as your ticket is newer than the fix), or you used an old version when you run the tests.

23) Slim\Tests\Handlers\NotFoundTest::testNotFound with data set #2 ('text/html', '') PHPUnit_Framework_Exception: Fatal error: Call to undefined method Slim\Http\Uri::getBasePath() in C:\Users\Glenn\Documents\GitHub\Slim\Slim\Http\Uri.php on line 772

silentworks commented 8 years ago

I actually did a test by switching out our Request/Response objects for the Zend Diactoros ones and it worked without any issues, I think @akrabat is going to put it in his test rig and see if it all still works.

Here is the code I used with @akrabat slim 3 skeleton https://gist.github.com/silentworks/c9ae6b01e750256fae75

ppetermann commented 8 years ago

i couldn't have done the slim-within-my-framework-with-react-php stunt if it didn't work ;)