public function CrawlerTest::testForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/dom-crawler/Tests/CrawlerTest.php \Symfony\Component\DomCrawler\Tests\CrawlerTest::testForm()
File
- vendor/
symfony/ dom-crawler/ Tests/ CrawlerTest.php, line 805
Class
Namespace
Symfony\Component\DomCrawler\TestsCode
public function testForm() {
$testCrawler = $this
->createTestCrawler('http://example.com/bar/');
$crawler = $testCrawler
->selectButton('FooValue');
$crawler2 = $testCrawler
->selectButton('FooBarValue');
$this
->assertInstanceOf('Symfony\\Component\\DomCrawler\\Form', $crawler
->form(), '->form() returns a Form instance');
$this
->assertInstanceOf('Symfony\\Component\\DomCrawler\\Form', $crawler2
->form(), '->form() returns a Form instance');
$this
->assertEquals($crawler
->form()
->getFormNode()
->getAttribute('id'), $crawler2
->form()
->getFormNode()
->getAttribute('id'), '->form() works on elements with form attribute');
$this
->assertEquals(array(
'FooName' => 'FooBar',
'TextName' => 'TextValue',
'FooTextName' => 'FooTextValue',
), $crawler
->form(array(
'FooName' => 'FooBar',
))
->getValues(), '->form() takes an array of values to submit as its first argument');
$this
->assertEquals(array(
'FooName' => 'FooValue',
'TextName' => 'TextValue',
'FooTextName' => 'FooTextValue',
), $crawler
->form()
->getValues(), '->getValues() returns correct form values');
$this
->assertEquals(array(
'FooBarName' => 'FooBarValue',
'TextName' => 'TextValue',
'FooTextName' => 'FooTextValue',
), $crawler2
->form()
->getValues(), '->getValues() returns correct form values');
try {
$this
->createTestCrawler()
->filterXPath('//ol')
->form();
$this
->fail('->form() throws an \\InvalidArgumentException if the node list is empty');
} catch (\InvalidArgumentException $e) {
$this
->assertTrue(true, '->form() throws an \\InvalidArgumentException if the node list is empty');
}
}