首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >phpunit 6.5.1 symfony 3.4按钮问题的功能测试

phpunit 6.5.1 symfony 3.4按钮问题的功能测试
EN

Stack Overflow用户
提问于 2018-08-07 23:29:29
回答 1查看 316关注 0票数 0

我正在尝试使用phpunit测试我的小web应用程序,但我在提交表单和使用爬虫访问按钮时遇到了困难。我似乎无法登录,因为节点总是报告为空。我认为问题可能出在提交按钮上,可能是试图引用它。

代码语言:javascript
复制
private $client = null;

 public function setUp()
 {
    $this->client = static::createClient();
    $this->testlogIn();
 }

   public function testLogIn()
{
    $crawler = $this->client->request('GET', '/login');
    $form = $crawler->filter('button#logIn')
      ->form(
            [
              '_username' => 'AdminAccountKyleTest',
              '_password' => 'test'
            ],
            'POST'
        );

    $this->client->submit($form);

    $this->assertContains('Homepage', $crawler->filter('body > div.main > div > div > div:nth-child(2) > h1')->text());
}    

这是按钮的树枝模板:

代码语言:javascript
复制
  <button class="btn btn-lg btn-primary btn-block" id="logIn" 
type="submit">Sign in</button>

当按钮呈现在细枝中而不是表单上的SubmitType中时,phpunit会有问题吗?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51730455

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档