You are here

protected function ChoiceFormFieldTest::createSelectNode in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dom-crawler/Tests/Field/ChoiceFormFieldTest.php \Symfony\Component\DomCrawler\Tests\Field\ChoiceFormFieldTest::createSelectNode()
7 calls to ChoiceFormFieldTest::createSelectNode()
ChoiceFormFieldTest::testDisableValidation in vendor/symfony/dom-crawler/Tests/Field/ChoiceFormFieldTest.php
ChoiceFormFieldTest::testMultipleSelects in vendor/symfony/dom-crawler/Tests/Field/ChoiceFormFieldTest.php
ChoiceFormFieldTest::testSelect in vendor/symfony/dom-crawler/Tests/Field/ChoiceFormFieldTest.php
ChoiceFormFieldTest::testSelects in vendor/symfony/dom-crawler/Tests/Field/ChoiceFormFieldTest.php
ChoiceFormFieldTest::testSelectWithEmptyBooleanAttribute in vendor/symfony/dom-crawler/Tests/Field/ChoiceFormFieldTest.php

... See full list

File

vendor/symfony/dom-crawler/Tests/Field/ChoiceFormFieldTest.php, line 346

Class

ChoiceFormFieldTest

Namespace

Symfony\Component\DomCrawler\Tests\Field

Code

protected function createSelectNode($options, $attributes = array(), $selectedAttrText = 'selected') {
  $document = new \DOMDocument();
  $node = $document
    ->createElement('select');
  foreach ($attributes as $name => $value) {
    $node
      ->setAttribute($name, $value);
  }
  $node
    ->setAttribute('name', 'name');
  foreach ($options as $value => $selected) {
    $option = $document
      ->createElement('option', $value);
    $option
      ->setAttribute('value', $value);
    if ($selected) {
      $option
        ->setAttribute('selected', $selectedAttrText);
    }
    $node
      ->appendChild($option);
  }
  return $node;
}