protected function loadOriginFile() { $xmlString = file_get_contents($this->dataFile->getPathname()); if (false === $xmlString) { throw new InvalidArgumentException("Can not read file content from '{$this->dataFile->getPathname()}'!"); } $xml = new SimpleXMLElement($xmlString); return CiteCollection::loadFromXml($xml); }
public function testLoadFromJson() { $xml = new SimpleXMLElement(file_get_contents(WS_TESTS_FIXURES_DIRECTORY . '/cites.xml')); $collection1 = CiteCollection::loadFromXml($xml); $this->assertEquals(6, $collection1->count()); $collection2 = CiteCollection::loadFromJson($collection1->toJson()); $this->assertInstanceOf('CiteCollection', $collection2); $this->assertEquals(6, $collection2->count()); $this->assertEquals('Thomas Carlyle', $collection2[3]->getAuthor()); $this->assertEquals('', $collection2[3]->getTitle()); $this->assertEquals('Der schlimmste aller Fehler ist, sich keines solchen bewusst zu sein.', $collection2[3]->getText()); $this->assertEquals('Albert Einstein', $collection2[4]->getAuthor()); $this->assertEquals('', $collection2[4]->getTitle()); $this->assertEquals('Phantasie ist wichtiger als Wissen, denn Wissen ist begrenzt.', $collection2[4]->getText()); $this->assertEquals('Bla', $collection2[5]->getAuthor()); $this->assertEquals('Blubb title', $collection2[5]->getTitle()); $this->assertEquals('Albert Einstein', $collection2[5]->getText()); }