Skip to content

Instantly share code, notes, and snippets.

@raisen
Created December 17, 2013 21:16
Show Gist options
  • Save raisen/8012741 to your computer and use it in GitHub Desktop.
Save raisen/8012741 to your computer and use it in GitHub Desktop.
// controller
class MediaController extends AppController {
private $foreign_id, $model, $user_id;
public $components = array('Paginator', 'RequestHandler',
'Crud.Crud' => array(
'actions' => array(
'create' => 'Crud.add',
),
'listeners' => array(
'Crud.Api',
'Crud.ApiPagination',
'Crud.ApiQueryLog',
)
)
);
function create() {
return $this->Crud->execute();
}
// test
class MediaControllerTest extends ControllerTestCase {
public $fixtures = array('app.media', 'app.user', 'app.user_activity');
public function testMediaCreate() {
$this->controller = $this->generate('Media', array(
'components' => array('Auth')
));
$this->controller->Auth->staticExpects($this->any())
->method('user')
->with('id')
->will($this->returnValue(1));
$result = $this->testAction('/user/media/create', array('return' => 'contents'));
debug($result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment