Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How do I Unit Test a Controller?
  • Hello,

    I'm writing unit tests for my controllers. I tried creating a Controller instance with "$controller_users = new Controller_Users();" but it's saying it needs a Request object of some kind when it is instantiated:

    1) Test_Controller_Users::test_action_index_template
    Fuel\Core\PhpErrorException: Argument 1 passed to Fuel\Core\Controller::__construct() must be an instance of Request, none given, called in /home/huertad/www/hello/fuel/app/tests/controller/controller_users.Test.php on line 11 and defined

    Are there any examples of how to write a test for Fuel Controller functions I could look at?
  • A controller needs access to the request that creates it, so you need to mock that, by creating a dummy request object yourself, and pass that to the constructor.

Howdy, Stranger!

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

In this Discussion