title: Creating Mock Auth Object in CakePHP Controller Test
body: <p>Just begun creating some unit tests for my controllers within my CakePHP application however I am completely flummoxed on how I should create a mock for the Auth Component, I have read the CookBook and thought I had it right, but keep getting thrown this error. </p>
  
  <pre><code>Error: Call to a member function allow() on a non-object    
  </code></pre>
  
  <p>Within the controller I am testing there is a beforeFilter function with the following code: </p>
  
  <pre><code>public function beforeFilter() {
      parent::beforeFilter();
      $this-&gt;Auth-&gt;allow('create');
  }
  </code></pre>
  
  <p>Within my test I have included the following: </p>
  
  <pre><code>$Leagues = $this-&gt;generate('Leagues', array(
      'components' =&gt; array(
          'Auth'
      )
  ));
  </code></pre>
  
  <p>I have played around with <code>staticExpects()</code> also but it doesn't seem to have much affect (I am also unsure what I need to put in to <code>staticExpects()</code>). </p>