Giter Site home page Giter Site logo

Comments (4)

 avatar commented on June 26, 2024

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.

origal avatar origal commented on June 26, 2024

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.

 avatar commented on June 26, 2024

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.

origal avatar origal commented on June 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.