Symfony2 functional testing InvalidArgumentException: The current node list is empty

前端 未结 7 555
伪装坚强ぢ
伪装坚强ぢ 2020-12-18 23:41

I get \"InvalidArgumentException: The current node list is empty.\" running functional tests through PHPUnit. Here is test i wrote:

public function testAdd()         


        
相关标签:
7条回答
  • 2020-12-19 00:42

    This error would occur when crawler can't find form element requested; Quite tricky when you are using, for instance, form builder as when run, it will create different input name:

    $form = $this-> createFormBuilder($store)
               ->add('storeNumber','text')
               ->add('storeName','text')
               ->add('save', 'submit')
               ->getForm(); 
    

    will output field name like:

    form_storeNumber
    

    which should be used in test class:

    $form=$crawler->selectButton('save')->form();
    $form['form_storeNumber']='10';
    
    0 讨论(0)
提交回复
热议问题