まったく合格しない簡単なテストに問題があります。コントローラー内にアクションがあります:
/**
* @Get("/parse")
* @param Dispatcher $dispatcher
* @return string
*/
public function parse(){
$xml_file = public_path()."/dummy.xml";
//File::get($xml_file); Tried this as well
$file = $this->file->get($xml_file);
return $file;
}
テストでは、次のようなメソッドがあります。
/**
* A basic functional test example.
*
* @return void
*/
public function testBasicExample(){
File::shouldReceive("get")->once();
$this->call('GET', '/parse');
}
また、Laravel のドキュメントでは、各 Facade をインスタンス化せずに直接モックできると書かれていますが、テストに合格することはなく、例外が発生します。
Mockery\Exception\InvalidCountException: Method get() from Mockery_0 should be called exactly 1 times but called 0 times.
PS : 私は Laravel 5 を持っており、Test Class には、ご参考までに、tearDown メソッドがあります。