我只是試着用PHPPHP和CakePHP,並試圖在控制器測試用例中使用testAction()方法時出現以下錯誤。CakePHP 2.1.1。 testAction()undefined
致命錯誤:調用未定義方法GroupsControllerTestCase :: testAction()
控制器測試用例與控制檯烘烤和我使用從2.x的文檔以下。
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);
}
.....
你能提供更多的信息嗎?就像你的PHP版本和測試文件開頭的幾行一樣? – 2012-03-30 15:09:01
當然,運行PHP 5.3.6(MAMP)。我將用測試案例文件 – rossjha 2012-03-30 15:13:19