Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 0.76 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. cakephp controller testing - how to test actions which require authorization?
  2. function testAdminIndex() {    
  3.     $result = $this->testAction('/admin/users/index');      
  4.     debug($result);
  5. }
  6.        
  7. function testAdminEdit() {
  8.     $this->Posts->Session->write('Auth.User', array(
  9.         'id' => 1,
  10.         'username' => 'markstory',
  11.     ));
  12.     $this->Posts->data = array(
  13.         'Post' => array(
  14.             'id' => 2,
  15.             'title' => 'Best article Evar!',
  16.             'body' => 'some text',
  17.         ),
  18.         'Tag' => array(
  19.             'Tag' => array(1,2,3),
  20.         )
  21.     );
  22.     $this->Posts->params = Router::parse('/admin/posts/edit/2');
  23.     $this->Posts->beforeFilter();
  24.     $this->Posts->Component->startup($this->Posts);
  25.     $this->Posts->admin_edit();
  26. }