The Slim Framework support forum has moved to http://discourse.slimframework.com. This Tender forum is no longer maintained or monitored.

How to test a Silm app

Franc's Avatar

Franc

01 Jun, 2012 08:55 PM

Hello,

Is there a class/module/something that can be used to test a Slim framework? or how do you usually unit test the result of the routes ?

  1. 1 Posted by Darius on 04 Jun, 2012 05:30 PM

    Darius's Avatar

    +1 I'll write a tutorial if need be, but I'm still pretty bad at php, so I'd prefer someone else show me the syntax.

    I've looked but I don't see a Rack::Test middleware analog. which would be handy.

  2. 2 Posted by Franc on 06 Jun, 2012 02:40 PM

    Franc's Avatar

    for running the Slim framewok tests you should use phpunit. If memory serves me well you should do: phpunit tests

    where tests is the Slim framework test folder.

    If you don't have phpunit install AND use a mac, see this: http://littlegists.blogspot.co.uk/2012/02/installing-phpunit-in-mac...

  3. 3 Posted by darius on 06 Jun, 2012 03:03 PM

    darius's Avatar

    thanks frank, got those two parts!

    I think the question was more: The best-practice ways to translate the syntax of sinatra tests into slim app tests, given that there is no rack-test middleware.

  4. Support Staff 4 Posted by Brian Nesbitt on 19 Jun, 2012 02:20 PM

    Brian Nesbitt's Avatar

    What are you looking for here. Just the ability to hit particular URI's via various request methods (GET/POST/etc), with data and assert on the content coming back in a phpunit test script?

  5. 5 Posted by darius on 19 Jun, 2012 02:39 PM

    darius's Avatar

    Yes. That's my 95% usecase.

    Custom matchers and other assertions would be a bonus.

  6. Support Staff 6 Posted by Brian Nesbitt on 19 Jun, 2012 02:46 PM

    Brian Nesbitt's Avatar

    Ya assertion helpers like assertTitleEquals(), assertTextPresent(), assertElementPresent(), assertTextInElement() all by id or also using css/jquery selectors.

    Thinking aloud, I think cookies and headers are more difficult but the general content stuff would be pretty simple. Maybe I'll talk to Josh about getting something like that rolling. A few different ways it could go.

  7. 7 Posted by Francisco Ruiz on 19 Jun, 2012 09:20 PM

    Francisco Ruiz's Avatar

    Something like that would be brilliant for the slim framework

  8. Andrew Smith closed this discussion on 20 Nov, 2012 12:19 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac