function testXPath() { $xml = "<Collection>\n \t\t\t<DVD>\n\t\t \t<ProfileTimestamp>2007-05-19T23:03:06.000Z</ProfileTimestamp>\n\t\t \t<ID>012236115007</ID>\n\t\t\t <MediaTypes>\n\t\t\t <DVD>True</DVD>\n\t\t\t <HDDVD>False</HDDVD>\n\t\t\t <BluRay>False</BluRay>\n\t\t\t </MediaTypes>\n\t\t </DVD>\n\t\t</Collection>"; $handler = new StringFileHandler($xml); $implortPlugin = new TestImportPlugin(); $importHandler = new XMLImportPluginHandler($implortPlugin, $handler); if ($importHandler->handleImport()) { $this->assertTrue(true, "XML Successful"); $this->assertEquals(8, count($implortPlugin->getStartElementXPaths()), ''); $startXPaths = $implortPlugin->getStartElementXPaths(); $this->assertEquals("/Collection", $startXPaths[0], 'start xpath 1'); $this->assertEquals("/Collection/DVD", $startXPaths[1], 'start xpath 2'); $this->assertEquals("/Collection/DVD/ProfileTimestamp", $startXPaths[2], 'start xpath 3'); $this->assertEquals("/Collection/DVD/ID", $startXPaths[3], 'start xpath 4'); $this->assertEquals("/Collection/DVD/MediaTypes", $startXPaths[4], 'start xpath 5'); $this->assertEquals("/Collection/DVD/MediaTypes/DVD", $startXPaths[5], 'start xpath 6'); $this->assertEquals("/Collection/DVD/MediaTypes/HDDVD", $startXPaths[6], 'start xpath 7'); $this->assertEquals("/Collection/DVD/MediaTypes/BluRay", $startXPaths[7], 'start xpath 8'); $this->assertEquals(8, count($implortPlugin->getEndElementXPaths()), ''); $endXPaths = $implortPlugin->getEndElementXPaths(); $this->assertEquals("/Collection/DVD/ProfileTimestamp", $endXPaths[0], 'end xpath 1'); $this->assertEquals("/Collection/DVD/ID", $endXPaths[1], 'end xpath 2'); $this->assertEquals("/Collection/DVD/MediaTypes/DVD", $endXPaths[2], 'end xpath 3'); $this->assertEquals("/Collection/DVD/MediaTypes/HDDVD", $endXPaths[3], 'end xpath 4'); $this->assertEquals("/Collection/DVD/MediaTypes/BluRay", $endXPaths[4], 'end xpath 5'); $this->assertEquals("/Collection/DVD/MediaTypes", $endXPaths[5], 'end xpath 6'); $this->assertEquals("/Collection/DVD", $endXPaths[6], 'end xpath 7'); $this->assertEquals("/Collection", $endXPaths[7], 'end xpath 8'); } else { $this->fail("XML Parser failed"); } }
function testXMLParse() { $plugin = new DVDProfilerImportPlugin(); $importHandler = new TestItemImportHandler(); $plugin->setItemImportHandler($importHandler); $f = fopen(dirname(__FILE__) . "/resources/DVDProfilerCollection.xml", 'rb'); if ($f) { $fileHandler = new WrapperFileHandler($f); $xmlHandler = new XMLImportPluginHandler($plugin, $fileHandler); if ($xmlHandler->handleImport()) { $this->assertEquals(4, $importHandler->getItemCount()); } else { $this->fail("XML Parser failed"); } fclose($f); } else { $this->fail("Could not open DVDProfilerCollection.xml"); } }
$listingObject->addHeaderColumn(get_opendb_lang_var('title'), 'title', FALSE); //$listingObject->addHeaderColumn(get_opendb_lang_var('owner')); if ($cfg_override_status_type !== TRUE) { $listingObject->addHeaderColumn(get_opendb_lang_var('s_status_type'), 's_status_type', FALSE); } $listingObject->addHeaderColumn(get_opendb_lang_var('attributes'), 'attributes', FALSE); if ($importPlugin->get_plugin_type() == 'row') { $rowHandler = new RowImportPluginHandler($itemImportHandler, $importPlugin, $fileHandler, $HTTP_VARS['field_column'], $HTTP_VARS['field_default'], $HTTP_VARS['field_initcap']); if (($resultOfImport = $rowHandler->handleImport($cfg_include_header_row, $HTTP_VARS['s_item_type'])) !== TRUE) { $importError = $xmlHandler->getError(); } } else { if ($importPlugin->get_plugin_type() == 'xml') { // XML plugins will perform callbacks directly. $importPlugin->setItemImportHandler($itemImportHandler); $xmlHandler = new XMLImportPluginHandler($importPlugin, $fileHandler); if (($resultOfImport = $xmlHandler->handleImport()) !== TRUE) { $importError = $xmlHandler->getError(); } } } // Close file. unset($fileHandler); @fclose($inFile); $listingObject->endListing(); if ($resultOfImport !== TRUE) { $listingObject->setNoRowsMessage($importError); echo format_error_block($importError); } if ($cfg_is_trial_run) { echo "<form action=\"{$PHP_SELF}\" method=\"POST\">";