I am using Laravel 4 with phpunit 4.5.0 and have some code that looks like:
public function someFunction(){
$cred = Input::only(
'email', 'password'
);
$response = Password::reset($cred, function($user, $password){
//do some stuff
});
}
I want to test it; however, I can't seem to get the PasswordBroker::reset mocked. I keep getting the error.
BadMethodCallException : Method Mockery_1_Illuminate_Auth_Reminders_PasswordBroker::remind() does not exist on this mock object
My test looks like:
<?php
protected $PasswordBrokerMock;
protected $ControllerTest;
class ControllerTest extends TestCase
{
public function setUp()
{
parent::setUp();
$this->PasswordBrokerMock = Mockery::mock('Illuminate\Auth\Reminders\PasswordBroker');
$this->assertInstanceOf('Illuminate\Auth\Reminders\PasswordBroker', $this->PasswordBrokerMock);
}
public function tearDown()
{
Mockery::close();
}
public function testFunction(){
Password::shouldReceive('reset')->andReturn(true);
$this->PasswordBrokerMock->shouldReceive('remind')->andReturn('something');
$this->route('get', 'page', array('identifier' => 'identifier'), array('email' => 'email', 'password' => 'password'));
$this->ControllerMock = new Controller;
$this->ControllerMock->someFunction();
}
}
Aucun commentaire:
Enregistrer un commentaire