いつもお世話になっております。
現在、下記のメンバー関数のユニットテストを作成しています。
その中で躓いているのが、200が返ってくることをテストしようとテストコードを書きましたが、
Call to undefined method {class-path}::assertStatus()
と怒られます。
resultの中身は
protected $content => string(0) "" protected $version => string(3) "1.0" protected $statusCode => int(200) protected $statusText => string(2) "OK" protected $charset => NULL public $original => NULL public $exception => NULL
が入っていました。statusの確認をすること自体が間違っているのでしょうか?
どなたか教えてください。
よろしくお願いします。
php
1public function downloadCsv() 2{ 3 $data = DB::table('table_name') 4 ->get(['id', 'flg']) 5 ->toArray(); 6 7 $file = new File(); 8 $csv = $file->createFile($data); 9 10 $headers = [ 11 'Content-Type' => 'text/csv', 12 'Content-Disposition' => 'attachment; filename="' . 'hoge.csv' . '"', 13 ]; 14 15 return response()->make($csv, 200, $headers); 16}
public function testtesttest() { $builder = Mockery::mock("\Illuminate\Database\Query\Builder"); $builder->shouldReceive('get->toArray')->andReturn([1]); \DB::shouldReceive('Table')->with('table_name')->once()->andReturn($builder); $mock = Mockery::mock('{createfileのクラス}'); $mock->shouldReceive('createFile'); $obj = new {presenter_name}(); $result = $obj->downloadCsv(); $this->assertStatus(200); }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/06 00:44