title: Unit testing the Auth Component
body: <p>I am using the following code to test the login action in UsersController</p>
  
  <pre><code>public function testLogin() {
      $data = array('User' =&gt; array(
                  'username' =&gt; 'hello',
                  'password' =&gt; '411'
                      )
              );
      $this-&gt;Users = $this-&gt;generate('Users',array('components'=&gt; array('Auth','Session')));
      $this-&gt;Users-&gt;Auth-&gt;staticExpects($this-&gt;once())
                          -&gt;method('user')
                          -&gt;with('id');
      $this-&gt;testAction('/users/login', array('data' =&gt; $data, 'method' =&gt; 'post'));
  
  }
  </code></pre>
  
  <p>and the fixture is-</p>
  
  <pre><code>class UserFixture extends CakeTestFixture {
      public $import = array('model' =&gt; 'User', 'records' =&gt; true, 'connection' =&gt; 'fixture');
  }
  </code></pre>
  
  <p>adn action is-</p>
  
  <pre><code>public function login() {
  
          if($this-&gt;request-&gt;is('post')) {
              if($this-&gt;Auth-&gt;login()) {
                  $this-&gt;redirect($this-&gt;Auth-&gt;redirect());
              } else {
                  return false;
                  $this-&gt;Session-&gt;setFlash(__('Wrong Username Or Password,Please Try Again'));
              }
          }
      }
  </code></pre>
  
  <p>It always showing</p>
  
  <blockquote>
    <p>Expectation failed for method name is equal to  when invoked 1 time(s).
    Method was expected to be called 1 times, actually called 0 times.  </p>
  </blockquote>
  
  <p>What is the problem?Cant find any solution,and the reason also.Please help.</p>