Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Tests
  • Hi, First of love the structure of the framework, I was just about to build one myself using the exact same structure/principles. I read on a blog somewhere that fuel does have testing built in but it's not documented...would you be able to give me an example of how I would go about writing tests in fuel? Many thanks, CJ
  • Hi CJ, Yes, we have baked in support for PHPUnit. Basically, you just write your tests inside of the app/tests folder. When you are in there you need to make sure your class name starts with Tests_ and that is extends the TestCase class. You should also use the @group comment so that you can test your app without testing the whole framework. Example:
    <?php
    
    /**
     * Foo Tests
     * 
     * @group App
     * @group Foo
     */
    class Tests_Foo extends TestCase {
        public function test_that_foo_is foo()
        {
            $this->assertEquals(Foo::get(), 'foo');
        }
    }
    

    Then you can run them from the command line using oil:
    $ php oil test -group="App"
    

    Hope that helps Dan
  • Thank you both for the quick response, I'll give it a go :)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion