Comments (4)
I haven't tried your code yet this morning, but you may want to consider using the slim response object:
$app = new \Slim\Slim();
$app->response->headers->set('Content-Type', 'application/json');
When you send the header directly, it's going to be outside of the environment of the unit tests. If you are building out a lot of REST endpoints, you may also want to look at some middleware to make json simpler. Check out entomb / slim-json-api.
from slim-unit-testing-example.
Thanks for the reply and the link.
From little testings I suspect this line with the response object has the same effect of header('Content-type: application/json');
Take that back, I've now updated to phpunit 3.7.29 and checked again. It seems using the response object now works both for setting the response type and works well with the unit test, without the annotation. Thanks a lot, should have thought of that :) 👍
I will look further into this as well.
from slim-unit-testing-example.
Glad I could help, and thanks for the followup. I'll look at adding an older phpunit to the travis tests.
Is there anything that needs to be added to the documentation for this?
from slim-unit-testing-example.
At this point I'm not sure if there is. Will suggest something when it's discovered :)
from slim-unit-testing-example.
Related Issues (8)
- Multiple request in one test method. HOT 6
- Not able to access headers within the app when testing HOT 6
- Slim::getInstance HOT 5
- Upgrade project to Slim V3 HOT 3
- Question: Passing PUT variables with a test HOT 17
- Get parameters don't get through from the test? HOT 3
- Update samples to use render() instead of include HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slim-unit-testing-example.