laravel / lumen-framework

The Laravel Lumen Framework.
https://lumen.laravel.com
MIT License
1.48k stars 419 forks source link

Dispatching the Symfony\Component\HttpFoundation\Request during Unit Tests is not working correctly when compared to using Postman #990

Closed Hell4Ge closed 5 years ago

Hell4Ge commented 5 years ago

Description:

Dispatching the object of Request::create(...) works as expected using Postman, but not during unit tests.

Steps To Reproduce:

Ensure the port 8080 is free or change it in docker-compose.yml file

git clone https://github.com/Hell4Ge/lumenbug-1.git cd lumenbug-1/.docker/ && docker-compose -p lumenbug-1 up -d --build docker exec lumenbug-1_php_1 cp .env.example .env docker exec lumenbug-1 composer update docker exec lumenbug-1_php_1 vendor/bin/phpunit

The failure of unit test is expected as it is a proof, the result is different from executing a POST request to http://localhost:8080/anotherExampleRoute using Postman.

Use Case

I am designing the API that needs to call other routes from single route as its easier to rollback the database and storage if something fails. As long as this bug persists I am not able to test if efficiently

Side notes

Happened also on 5.* version of Lumen, I noticed that once the unit test has been run then some of the things stays the same, like the providers seems to do not run again with every next request (ie. you cannot change user by sending different token in future requests, instead you HAVE TO use actingAs method which was not in my favor as it was quite custom login method).

driesvints commented 5 years ago

Hey there,

Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to report back and I'll gladly help you out and re-open this issue.

Thanks!

Hell4Ge commented 5 years ago

Hey there,

Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to report back and I'll gladly help you out and re-open this issue.

Thanks!

I don't understand, are you trying to make me believe its not a bug, but a feature? Where can I find somebody to help me "identify this as a bug" if not here

driesvints commented 5 years ago

@Hell4Ge on the channels I listed above