diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-10-08 14:28:18 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-10-08 14:28:18 +0200 |
commit | 1fccfbbf261a704cb1890e7f2afdb4e4ae29cadd (patch) | |
tree | 36031777126dbe8b9de102124cfd7b8660cfcb6b /tests/unit | |
parent | 7aa8c06258637f33a050119de7178146cce63dbf (diff) |
try to fix scrutinizer bugs
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/utility/OPMLExporterTest.php | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/tests/unit/utility/OPMLExporterTest.php b/tests/unit/utility/OPMLExporterTest.php index 1b8e76ca4..fe7b142e8 100644 --- a/tests/unit/utility/OPMLExporterTest.php +++ b/tests/unit/utility/OPMLExporterTest.php @@ -45,6 +45,16 @@ class OPMLExporterTest extends \PHPUnit_Framework_TestCase { } + private function getAttribute($item, $name) { + // used to fix scrutinizer errors + if ($item instanceof \DOMElement) { + return $item->getAttribute($name); + } else { + return null; + } + } + + public function testBuildEmpty(){ $result = $this->exporter->build([], []); $xpath = new \DOMXpath($result); @@ -59,10 +69,10 @@ class OPMLExporterTest extends \PHPUnit_Framework_TestCase { $elems = $xpath->query('/opml/body/outline'); $this->assertEquals(2, $elems->length); - $this->assertEquals($this->folder1->getName(), $elems->item(0)->getAttribute('title')); - $this->assertEquals($this->folder1->getName(), $elems->item(0)->getAttribute('text')); - $this->assertEquals($this->folder2->getName(), $elems->item(1)->getAttribute('title')); - $this->assertEquals($this->folder2->getName(), $elems->item(1)->getAttribute('text')); + $this->assertEquals($this->folder1->getName(), $this->getAttribute($elems->item(0), 'title')); + $this->assertEquals($this->folder1->getName(), $this->getAttribute($elems->item(0), 'text')); + $this->assertEquals($this->folder2->getName(), $this->getAttribute($elems->item(1), 'title')); + $this->assertEquals($this->folder2->getName(), $this->getAttribute($elems->item(1), 'text')); } @@ -72,16 +82,16 @@ class OPMLExporterTest extends \PHPUnit_Framework_TestCase { $elems = $xpath->query('//outline'); $this->assertEquals(1, $elems->length); - $this->assertEquals($this->feed1->getTitle(), $elems->item(0)->getAttribute('title')); - $this->assertEquals($this->feed1->getTitle(), $elems->item(0)->getAttribute('text')); - $this->assertEquals($this->feed1->getUrl(), $elems->item(0)->getAttribute('xmlUrl')); - $this->assertEquals('', $elems->item(0)->getAttribute('htmlUrl')); + $this->assertEquals($this->feed1->getTitle(), $this->getAttribute($elems->item(0), 'title')); + $this->assertEquals($this->feed1->getTitle(), $this->getAttribute($elems->item(0), 'text')); + $this->assertEquals($this->feed1->getUrl(), $this->getAttribute($elems->item(0), 'xmlUrl')); + $this->assertEquals('', $this->getAttribute($elems->item(0), 'htmlUrl')); } public function testBuildReturnsFeedsAndFolders() { $result = $this->exporter->build( - [$this->folder1, $this->folder2], + [$this->folder1, $this->folder2], [$this->feed1, $this->feed2] ); $xpath = new \DOMXpath($result); @@ -90,10 +100,10 @@ class OPMLExporterTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(3, $elems->length); - $this->assertEquals($this->folder1->getName(), $elems->item(0)->getAttribute('title')); - $this->assertEquals($this->folder2->getName(), $elems->item(1)->getAttribute('text')); - $this->assertEquals($this->feed1->getUrl(), $elems->item(2)->getAttribute('xmlUrl')); - $this->assertEquals($this->feed2->getLink(), $elems->item(1)->childNodes->item(0)->getAttribute('htmlUrl')); + $this->assertEquals($this->folder1->getName(), $this->getAttribute($elems->item(0), 'title')); + $this->assertEquals($this->folder2->getName(), $this->getAttribute($elems->item(1), 'text')); + $this->assertEquals($this->feed1->getUrl(), $this->getAttribute($elems->item(2), 'xmlUrl')); + $this->assertEquals($this->feed2->getLink(), $this->getAttribute($elems->item(1)->childNodes->item(0), 'htmlUrl')); } |