1

I am using symfony 3.0 and phpunit 3.7.1.I want to submit a form via phpunit file. File Name: abcControllerTest.php

<?php

namespace AbcBundle\Tests\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Request;


class AbcControllerTest extends WebTestCase {

    public function testEmpty() {
        $whereParams = array('params' => array(
                'var' => '',

        ));

        return $whereParams;
    }

    /**
     * ABC Builder 
     * @depends testEmpty
     */
    public function testAbc(array $whereParams) {
        $client = static::createClient();
        $crawler = $client->request('GET', $GLOBALS['host'] . '/abc/ac_file/param', $whereParams);
        $buttonCrawlerNode = $crawler->selectButton('Submit');
        $form = $buttonCrawlerNode->form();
        $crawler = $client->submit($form);

    }


}

I am testing export report functionality thats why i am just creating a submit button and trying to submit form on specific url with some parameter. Error Message: InvalidArgumentException: The current node list is empty.

Anyone can suggest me what can i do?

Ashish Kumar Saxena
  • 4,400
  • 8
  • 27
  • 48
  • which line give you the error? You should check that the loading of the first page is ok with something like `$this->assertTrue($client->getResponse()->isSuccessful());` you could debug with `$client->getResponse()->getContent()` – Matteo Jan 19 '17 at 12:15
  • I am getting error on this line: $form = $buttonCrawlerNode->form(); – Ashish Kumar Saxena Jan 19 '17 at 12:28
  • The `node` is probably because either the `XHTML` is invalid, the path you use to look for your `submit` is wrong or because the request doesn't reach your webpage correctly. – Boris Guéry Jan 19 '17 at 13:54
  • By the way, favor reporting the stacktrace instead of the error message only. It's more helpful. – Boris Guéry Jan 19 '17 at 13:55

0 Answers0