I'm getting Static method "user" cannot be invoked on mock object
even did not mock auth->user
.
Im using php7, cakephp2.x and phpunit4+ According to cakephp2 documentation :
https://book.cakephp.org/2.0/en/development/testing.html
If you are using PHPUnit 4 or 5, staticExpects() does not exist anymore. Instead, you should insert the necessary data into the session with CakeSession::write('Auth.User', $user) before calling the action.
I tried using :
$user = [
'id' => 1,
'username' => 'mark'
];
CakeSession::write('Auth.User', $user);
But when calling :
$user = $this->Controller->Auth->user();
Im still getting :
Static method "user" cannot be invoked on mock object
error
Surely i'm missing something here but I don't know what. could you please help me the correct approach here.
Thank you