I'm trying to figure out how to do a proper test about if a function is being called or not.
This function busqueda is defined within a controller AnuncioController, so I expect it being called when a user clicks on a search button which posts to anuncios/busqueda.
As far as I'm concerned, this might be done with mocks. This is what I've tried:
use \App\Http\Controllers;
class ExampleTest extends TestCase
{
public function testSearch()
{
$mock_search = Mockery::mock('AnuncioController');
$mock_search->shouldReceive('busqueda')->once()->andReturn(null);
$this->visit('/')->submitForm('Buscar')->seePageIs('anuncios/busqueda');
}
}
But the assert always fails, am I using mocks wrongly?
Aucun commentaire:
Enregistrer un commentaire