You are here

public function FormTest::testConstructorHandlesFormValues in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dom-crawler/Tests/FormTest.php \Symfony\Component\DomCrawler\Tests\FormTest::testConstructorHandlesFormValues()

File

vendor/symfony/dom-crawler/Tests/FormTest.php, line 121

Class

FormTest

Namespace

Symfony\Component\DomCrawler\Tests

Code

public function testConstructorHandlesFormValues() {
  $dom = $this
    ->createTestHtml5Form();
  $inputElements = $dom
    ->getElementsByTagName('input');
  $buttonElements = $dom
    ->getElementsByTagName('button');
  $form1 = new Form($inputElements
    ->item(3), 'http://example.com');
  $form2 = new Form($buttonElements
    ->item(0), 'http://example.com');

  // Tests if form values are correctly assigned to forms
  $values1 = array(
    'apples' => array(
      '1',
      '2',
    ),
    'form_name' => 'form-1',
    'button_1' => 'Capture fields',
    'outer_field' => 'success',
  );
  $values2 = array(
    'oranges' => array(
      '1',
      '2',
      '3',
    ),
    'form_name' => 'form_2',
    'button_2' => '',
    'app_frontend_form_type_contact_form_type' => array(
      'contactType' => '',
      'firstName' => 'John',
    ),
  );
  $this
    ->assertEquals($values1, $form1
    ->getPhpValues(), 'HTML5-compliant form attribute handled incorrectly');
  $this
    ->assertEquals($values2, $form2
    ->getPhpValues(), 'HTML5-compliant form attribute handled incorrectly');
}