I’m just trying out PHPUnit with CakePHP and i’m getting an the following error when trying to use the testAction() method in a controller test case.
Fatal error: Call to undefined method GroupsControllerTestCase::testAction()
The controller test case was baked with the console and i’m using the following from the 2.x docs.
public function testIndex() {
$result = $this->testAction('/groups/index');
debug($result);
}
GroupsControllerTest.php
<?php
App::uses('GroupsController', 'Controller');
class TestGroupsController extends GroupsController {
public $autoRender = false;
public function redirect($url, $status = null, $exit = true) {
$this->redirectUrl = $url;
}
}
class GroupsControllerTestCase extends CakeTestCase {
public $fixtures = array('app.group');
public function setUp() {
parent::setUp();
$this->Groups = new TestGroupsController();
$this->Groups->constructClasses();
}
public function tearDown() {
unset($this->Groups);
parent::tearDown();
}
public function testIndex() {
$results = $this->testAction('/groups/index');
debug($results);
}
.....
I believe your test case should extend ControllerTestCase, not CakeTestCase.