Skip to content

Instantly share code, notes, and snippets.

@veganista
Created May 4, 2012 20:37
Show Gist options
  • Save veganista/2597579 to your computer and use it in GitHub Desktop.
Save veganista/2597579 to your computer and use it in GitHub Desktop.
CakePHP Controller Tetsing
<?php
/* Users Test cases generated on: 2012-03-13 19:59:39 : 1331668779*/
App::uses('UsersController', 'Controller');
/**
* TestUsersController *
*/
class TestUsersController extends UsersController {
/**
* Auto render
*
* @var boolean
*/
public $autoRender = false;
/**
* Redirect action
*
* @param mixed $url
* @param mixed $status
* @param boolean $exit
* @return void
*/
public function redirect($url, $status = null, $exit = true) {
$this->redirectUrl = $url;
}
}
/**
* UsersController Test Case
*
*/
class UsersControllerTestCase extends ControllerTestCase {
/**
* Fixtures
*
* @var array
*/
public $fixtures = array('app.user', 'app.group');
/**
* setUp method
*
* @return void
*/
public function setUp() {
parent::setUp();
$this->Users = new TestUsersController();
}
/**
* tearDown method
*
* @return void
*/
public function tearDown() {
unset($this->Users);
parent::tearDown();
}
/**
* testAdminIndex method
*
* @return void
*/
public function testAdminIndex() {
$result = $this->testAction('admin/users/index');
debug($result);
}
/**
* testAdminView method
*
* @return void
*/
public function testAdminView() {
}
/**
* testAdminAdd method
*
* @return void
*/
public function testAdminAdd() {
}
/**
* testAdminEdit method
*
* @return void
*/
public function testAdminEdit() {
}
/**
* testAdminDelete method
*
* @return void
*/
public function testAdminDelete() {
}
}
@veganista
Copy link
Author

Th error im getting is:

Undefined index: params
Test case: UsersControllerTestCase(testAdminIndex)

@veganista
Copy link
Author

More of the error:

PHPUnit_Framework_Error_Notice
Undefined index: params
Test case: UsersControllerTestCase(testAdminIndex)
Stack trace:
E:\wamp\www\cakephp\lib\Cake\Controller\Component\AuthComponent.php : 719
E:\wamp\www\cakephp\lib\Cake\Controller\Component\AuthComponent.php : 316
AuthComponent::startup
E:\wamp\www\cakephp\lib\Cake\Utility\ObjectCollection.php : 130
ObjectCollection::trigger
E:\wamp\www\cakephp\lib\Cake\Event\CakeEventManager.php : 246
E:\wamp\www\cakephp\lib\Cake\Controller\Controller.php : 671
E:\wamp\www\cakephp\lib\Cake\Routing\Dispatcher.php : 100
E:\wamp\www\cakephp\lib\Cake\Routing\Dispatcher.php : 85
E:\wamp\www\cakephp\lib\Cake\TestSuite\ControllerTestCase.php : 266

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment