I don't find a way to add "button" or "input" fields to a form to the crawler in Symfony for testing.
I'm doing this :
$crawler = $this->client->request('GET', '');
$document = new \DOMDocument();
$document->loadXml('<button type="submit" name="_submit" href="#">Create</button >');
$nodeList = $document->getElementsByTagName('button');
$node = $document->getElementsByTagName('button')->item(0);
$crawler->addNode($node, $form);
var_dump($crawler->filter('button[name="_submit"]')->text()); //Return Create Logic
But when i try to send my form i've got :
$form = $crawler->selectButton('_submit')->form(array(
'login-input' => 'XXXXXX',
'pass-input' => 'XXXXX',
));
This doesn't work i've got :
LogicException: The selected node does not have a form ancestor.
I don't have any button or input fields because it's a javascript submit.
Someone have any idea ?
EDIT
I've found an another way: I send directly ajax request, and i've got the same effect @redbirdo, your solution doesn't work for me, and isn't what i want at the start of my question