laravel view assertions
Version 1.2.0
Laravel 應用程式中視圖缺少斷言。
您必須按照幾個簡單的步驟來安裝此軟體包。
透過作曲家:
$ composer require sven/laravel-view-assertions --dev
或將套件加入composer.json
中的依賴項中,並在命令列上執行composer update
來下載套件:
{
"require-dev" : {
"sven/laravel-view-assertions" : " ^1.1 "
}
}
該包公開了一個特徵: SvenLaravelViewAssertionsInteractsWithViews
。當您在測試中use
此特徵時,如下所示,您將可以存取多個斷言:
use Sven LaravelViewAssertions InteractsWithViews ;
use Illuminate Foundation Testing TestCase ;
class ExampleTest extends TestCase
{
use InteractsWithViews;
public function test_it_creates_a_view ()
{
// ...
$ this -> assertViewExists ( ' some.view-file ' );
$ this -> assertViewsExist ([ ' posts.index ' , ' posts.show ' ]);
}
public function test_it_does_not_create_a_view ()
{
// ...
$ this -> assertViewDoesNotExist ( ' some.view-file ' );
$ this -> assertViewsDoNotExist ([ ' posts.edit ' , ' posts.create ' ]);
}
public function test_the_view_equals ()
{
// ...
$ this -> assertViewEquals ( ' The Expected Contents ' , ' index ' );
}
public function test_the_view_does_not_equal ()
{
// ...
$ this -> assertViewDoesNotEqual ( ' This Is Not The Content You ' re Looking For ' , ' index ' );
}
}
歡迎所有貢獻(拉取請求、問題和功能請求)。不過,請務必先通讀 CONTRIBUTING.md。請參閱貢獻者頁面以了解所有貢獻者。
sven/laravel-view-assertions
已獲得 MIT 許可證 (MIT) 許可。請參閱許可證文件以獲取更多資訊。