Beispiel #1
0
 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);
 }
Beispiel #2
0
 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);
 }
Beispiel #3
0
 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);
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";
}