Laravel phpunit模拟键盘按键
我正在为我的laravel应用程序中的搜索功能编写测试。我想模仿用户的行为,所以在我的测试中Laravel phpunit模拟键盘按键,php,unit-testing,laravel-5,phpunit,Php,Unit Testing,Laravel 5,Phpunit,我正在为我的laravel应用程序中的搜索功能编写测试。我想模仿用户的行为,所以在我的测试中 public function testSearchCanBeDone() { $this->visit('/') ->type('name', 'query') ->press('Search') //In my case press enter key ->seePageIs
public function testSearchCanBeDone()
{
$this->visit('/')
->type('name', 'query')
->press('Search') //In my case press enter key
->seePageIs('/search?query=name')
->see('Results');
}
}
我的问题是,现在我没有搜索按钮,按下('Find')。在我的情况下,在搜索字段中键入后,按enter键。我该怎么做呢。这是我的搜索表单的代码
<form method="GET" action="/search" role="search">
<div class="input-field">
<input name = "query" id="search" type="search" class="search" required>
<label for="search">
<i class="material-icons teal-text text-lighten-2">search</i>
</label>
<i class="material-icons">close</i>
</div>
</form>
搜索
关闭
我认为您跨越了UI测试和单元测试之间的界限。一种方法是调用$this->get('/search',$params)