public function testTreeDbStorage() { $tree = ezcTreeXml::create($this->tempDir . 'testDbStorage.xml', $this->store); $this->addTestData($tree); self::assertSame("Western Hoolock Gibbon", $tree->fetchNodeById("Western_Hoolock_Gibbon")->data); // start over $tree = new ezcTreeXml($this->tempDir . 'testDbStorage.xml', $this->store); self::assertSame("Western Hoolock Gibbon", $tree->fetchNodeById("Western_Hoolock_Gibbon")->data); }
public function testTreeXmlToMemory() { $treeFrom = ezcTreeXml::create($this->tempDir . 'testTreeMemoryToXML.xml', $this->storeFromXml); $this->addTestData($treeFrom); $treeTo = ezcTreeMemory::create($this->storeToMem); self::doCopyTest($treeFrom, $treeTo); }
public function testTreeParentChildToXML() { $treeFrom = new ezcTreeDbParentChild($this->dbh, 'parent_child', $this->storeFrom); $this->addTestData($treeFrom); $treeTo = ezcTreeXml::create($this->tempDir . 'testTreeParentChildToXML.xml', $this->storeToXml); self::doCopyTest($treeFrom, $treeTo); }
public function testFetchDataXmlTree() { $store = new ezcTreePersistentObjectDataStore($this->session, 'FileEntry', 'id'); $tree = ezcTreeXml::create($this->tempDir . 'test-xml.xml', $store, 'ezc'); $this->emptyTables(); $this->addStandardData($tree); // start over $tree = new ezcTreeXml($this->tempDir . 'test-xml.xml', $store, 'ezc'); $node = $tree->fetchNodeById('3'); self::assertSame(3, (int) $node->data->id); self::assertSame(FileEntry::PARTITION, (int) $node->data->type); $node = $tree->fetchNodeById('grubby'); self::assertSame('grubby', $node->data->id); self::assertSame(172, (int) $node->data->size); }
<?php require_once 'tutorial_autoload.php'; $store = new ezcTreeXmlInternalDataStore(); $tree = ezcTreeXml::create('files/example1.xml', $store); $rootNode = $tree->createNode('Elements', 'Elements'); $tree->setRootNode($rootNode); $nonMetal = $tree->createNode('NonMetals', 'Non-Metals'); $rootNode->addChild($nonMetal); $nobleGasses = $tree->createNode('NobleGasses', 'Noble Gasses'); $rootNode->addChild($nobleGasses); $nonMetal->addChild($tree->createNode('H', 'Hydrogen')); $nonMetal->addChild($tree->createNode('C', 'Carbon')); $nonMetal->addChild($tree->createNode('N', 'Nitrogen')); $nonMetal->addChild($tree->createNode('O', 'Oxygen')); $nonMetal->addChild($tree->createNode('P', 'Phosphorus')); $nonMetal->addChild($tree->createNode('S', 'Sulfur')); $nonMetal->addChild($tree->createNode('Se', 'Selenium')); $nobleGasses->addChild($tree->createNode('F', 'Fluorine')); $nobleGasses->addChild($tree->createNode('Cl', 'Chlorine')); $nobleGasses->addChild($tree->createNode('Br', 'Bromine')); $nobleGasses->addChild($tree->createNode('I', 'Iodine'));
<?php require_once 'tutorial_autoload.php'; $store = new ezcTreeXmlInternalDataStore(); $tree = new ezcTreeXml('files/example1.xml', $store); $visitor = new ezcTreeVisitorPlainText(ezcTreeVisitorPlainText::SYMBOL_UTF8); $tree->accept($visitor); echo (string) $visitor; // print the plot
public function testFetchDataNode1() { $dirname = dirname(__FILE__); $tree = new ezcTreeXml("{$dirname}/files/fetch-data-test.xml", new ezcTreeXmlInternalDataStore()); try { $node = $tree->fetchNodeById(1); $data = $node->data; self::fail("Expected exception not thrown."); } catch (ezcTreeDataStoreMissingDataException $e) { self::assertEquals("The data store does not have data stored for the node with ID '1'.", $e->getMessage()); } }
<?php require_once 'tutorial_autoload.php'; $store = new ezcTreeXmlInternalDataStore(); $tree = new ezcTreeXml('files/example1.xml', $store); $noble = $tree->fetchChildren('NobleGasses'); echo "We found {$noble->size} noble gasses: \n"; foreach (new ezcTreeNodeListIterator($tree, $noble, true) as $nodeId => $nodeData) { echo "- {$nodeId}: {$nodeData} \n"; }
<?php require_once 'tutorial_autoload.php'; $store = new ezcTreeXmlInternalDataStore(); $tree = new ezcTreeXml('files/example1.xml', $store); if ($tree->fetchNodeById('F')->isDescendantOf($tree->fetchNodeById('NonMetals'))) { echo "Flourine is a non-metal.<br/>\n"; } if ($tree->isDescendantOf('O', 'NonMetals')) { echo "Oxygen is a non-metal.<br/>\n"; } $nonMetals = $tree->fetchSubtree('NonMetals'); echo "We found {$nonMetals->size} non-metals: \n"; foreach ($nonMetals->nodes as $node) { echo "- {$node->id}: {$node->data} \n"; }