2018-08-07 15:29
浏览 56

使用phpunit 6.5.1 symfony 3.4按钮问题进行功能测试

I am trying to test my small web app with phpunit but Im having difficulty submitting forms and accessing the buttons with the crawler. I can't seem to login as the node always reports as empty. I believe the issue may be with the submit button, possibly trying to reference it.

private $client = null;

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

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


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

This is the twig template for the button:

  <button class="btn btn-lg btn-primary btn-block" id="logIn" 
type="submit">Sign in</button>

Does phpunit have an issue when the button is rendered in the twig instead of a SubmitType on a form ?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题