Skip to content

Commit f400ff7

Browse files
committed
Fixed some documentation inconsistencies
fixes paquettg#15
1 parent 7b9464e commit f400ff7

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/PHPHtmlParser/Dom/Tag.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct($name)
4646

4747
public function __get($key)
4848
{
49-
return $this->getAttribute($key);
49+
return$this->getAttribute($key);
5050
}
5151

5252
public function __set($key, $value)
@@ -133,7 +133,7 @@ public function setAttributes(array $attr)
133133
{
134134
foreach ($attr as $key => $value)
135135
{
136-
$this->attr[$key] = $value;
136+
$this->setAttribute($key, $value);
137137
}
138138

139139
return $this;

tests/Node/TagTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,25 @@ public function testSetAttributes()
2525
$this->assertEquals('http://google.com', $tag->getAttribute('href')['value']);
2626
}
2727

28+
public function testSetAttributeNoArray()
29+
{
30+
$tag = new Tag('a');
31+
$tag->setAttribute('href', 'http://google.com');
32+
$this->assertEquals('http://google.com', $tag->getAttribute('href')['value']);
33+
}
34+
35+
public function testSetAttributesNoDoubleArray()
36+
{
37+
$attr = [
38+
'href' => 'http://google.com',
39+
'class' => 'funtimes',
40+
];
41+
42+
$tag = new Tag('a');
43+
$tag->setAttributes($attr);
44+
$this->assertEquals('funtimes', $tag->class['value']);
45+
}
46+
2847
public function testNoise()
2948
{
3049
$tag = new Tag('a');
@@ -45,6 +64,13 @@ public function testGetAttributeMagic()
4564
$this->assertEquals('http://google.com', $tag->href['value']);
4665
}
4766

67+
public function testSetAttributeMagic()
68+
{
69+
$tag = new Tag('a');
70+
$tag->href = 'http://google.com';
71+
$this->assertEquals('http://google.com', $tag->href['value']);
72+
}
73+
4874
public function testMakeOpeningTag()
4975
{
5076
$attr = [

0 commit comments

Comments
 (0)