setAttributes() public method

Sets the attributes for this tag
public setAttributes ( array $attr )
$attr array
Exemplo n.º 1
0
 public function testOuterHtmlEmpty()
 {
     $a = new Tag('a');
     $a->setAttributes(['href' => ['value' => 'http://google.com', 'doubleQuote' => false]]);
     $node = new HtmlNode($a);
     $this->assertEquals("<a href='http://google.com'></a>", $node->OuterHtml());
 }
Exemplo n.º 2
0
 public function testMakeOpeningTagEmptyAttr()
 {
     $attr = ['href' => ['value' => 'http://google.com', 'doubleQuote' => true]];
     $tag = new Tag('a');
     $tag->setAttributes($attr);
     $tag->selected = ['value' => null];
     $this->assertEquals('<a href="http://google.com" selected>', $tag->makeOpeningTag());
 }
Exemplo n.º 3
0
 public function testIterator()
 {
     $div = new Tag('div');
     $div->setAttributes(['class' => ['value' => 'all', 'doubleQuote' => true]]);
     $a = new Tag('a');
     $a->setAttributes(['href' => ['value' => 'http://google.com', 'doubleQuote' => false]]);
     $br = new Tag('br');
     $br->selfClosing();
     $parent = new HtmlNode($div);
     $childa = new HtmlNode($a);
     $childbr = new HtmlNode($br);
     $parent->addChild($childa);
     $parent->addChild($childbr);
     $childa->addChild(new TextNode('link'));
     $children = 0;
     foreach ($parent as $child) {
         ++$children;
     }
     $this->assertEquals(2, $children);
 }