2017-10-06 4 views
1

하나의 컨트롤러 메서드에 대해 간단한 단위 테스트를 설정하려고합니다.Laravel 5.5 단위 테스트 컨트롤러 방법

목표는보기에 예상 값이 있는지 테스트하는 것입니다. 나는 다음과 같은 오류 얻을 내 conosle에서

/** 
* Does the homepage receive all companies when there is no licensekey provided. 
* 
* @return void 
*/ 
public function testAllCompaniesOnHomepageWithoutLicensekey() 
{ 
    $this->call('GET', '/'); 

    $allCompanies = Company::all(); 

    $this->assertViewHas('allCompanies', $allCompanies); 
} 

:이 Laravel 5.5에서 더 이상 availbale 경우

Error: Call to undefined method Tests\Unit\ExampleTest::assertViewHas()

을 나는 확실하지 않다하지?

누구나 내 목표를 테스트 할 수 있습니다.

+0

@Troyer 내가 볼 수 없습니다. 나는 browsertests를하려고하지 않고있다. – Chris

답변

2

이전 Laravel 버전에서 이전 하시겠습니까? https://laravel.com/docs/5.4/upgrade

는 Laravel 5.5 당신이 시도 할 수 Laravel 5.4 Laravel의 브라우저 테스트에 변화가 있었다 : 나는 이것을 위해 황혼을 사용하는 이유

$response = $this->get('/'); 

$allCompanies = Company::all(); 
$response->assertViewHas('allCompanies', $allCompanies); 
+1

아''get_class_methods ($ this)'를 디버깅하려고했지만 그걸 얻었습니다 ... (Y) –

+0

이전 Laravel 버전에서 마이그레이션하지 않겠습니다. – Chris