Example #1
0
 function it_should_set_value_for_multi_select_element(NodeInterface $nodeInterface)
 {
     $value = [2, 3];
     $document = new \DOMDocument('1.0', 'utf-8');
     $node = $document->createElement('select');
     $option_1 = $document->createElement('option');
     $option_1->setAttribute('value', '1');
     $option_2 = $document->createElement('option');
     $option_2->setAttribute('value', '2');
     $option_3 = $document->createElement('option');
     $option_3->setAttribute('value', '3');
     $node->appendChild($option_1);
     $node->appendChild($option_2);
     $node->appendChild($option_3);
     $results = [];
     $results[] = $option_2;
     $results[] = $option_3;
     $nodeInterface->hasAttribute('multi')->shouldBeCalled();
     $nodeInterface->getChildNodes()->willReturn($node->childNodes);
     $nodeInterface->getChildElementByAttribute('value', $value)->willReturn($results);
     $this->setValue($value);
 }