Author: dr
Date: Fri Aug 10 10:42:39 2007
New Revision: 5862

Log:
- Added PersistentObject data store.

Added:
    trunk/TreePersistentObjectTiein/
    trunk/TreePersistentObjectTiein/CREDITS
      - copied unchanged from r5840, trunk/Tree/CREDITS
    trunk/TreePersistentObjectTiein/ChangeLog
      - copied unchanged from r5840, trunk/Tree/ChangeLog
    trunk/TreePersistentObjectTiein/DEPS
    trunk/TreePersistentObjectTiein/DESCRIPTION
    trunk/TreePersistentObjectTiein/design/
    trunk/TreePersistentObjectTiein/design/class_diagram.png   (with props)
    trunk/TreePersistentObjectTiein/docs/
    trunk/TreePersistentObjectTiein/src/
    trunk/TreePersistentObjectTiein/src/stores/
    trunk/TreePersistentObjectTiein/src/stores/persistent_object.php   (with 
props)
    trunk/TreePersistentObjectTiein/src/tree_persistent_autoload.php   (with 
props)
    trunk/TreePersistentObjectTiein/tests/
    trunk/TreePersistentObjectTiein/tests/files/
    trunk/TreePersistentObjectTiein/tests/files/classes/
    trunk/TreePersistentObjectTiein/tests/files/classes/fileentry.php   (with 
props)
    trunk/TreePersistentObjectTiein/tests/files/defs/
    trunk/TreePersistentObjectTiein/tests/files/defs/fileentry.php   (with 
props)
    trunk/TreePersistentObjectTiein/tests/files/persistent_store.dba
    trunk/TreePersistentObjectTiein/tests/po_store.php   (with props)
    trunk/TreePersistentObjectTiein/tests/suite.php   (with props)

Added: trunk/TreePersistentObjectTiein/DEPS
==============================================================================
--- trunk/TreePersistentObjectTiein/DEPS (added)
+++ trunk/TreePersistentObjectTiein/DEPS [iso-8859-1] Fri Aug 10 10:42:39 2007
@@ -1,0 +1,2 @@
+Tree: 1.0alpha1
+PersistentObject: 1.3

Added: trunk/TreePersistentObjectTiein/DESCRIPTION
==============================================================================
--- trunk/TreePersistentObjectTiein/DESCRIPTION (added)
+++ trunk/TreePersistentObjectTiein/DESCRIPTION [iso-8859-1] Fri Aug 10 
10:42:39 2007
@@ -1,0 +1,3 @@
+The Tree component handles the creating, manipulating and querying of tree
+structures.  This component uses persistent objects as data storage for the
+data elements of the tree nodes.

Added: trunk/TreePersistentObjectTiein/design/class_diagram.png
==============================================================================
Binary file - no diff available.

Propchange: trunk/TreePersistentObjectTiein/design/class_diagram.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: trunk/TreePersistentObjectTiein/src/stores/persistent_object.php
==============================================================================
--- trunk/TreePersistentObjectTiein/src/stores/persistent_object.php (added)
+++ trunk/TreePersistentObjectTiein/src/stores/persistent_object.php 
[iso-8859-1] Fri Aug 10 10:42:39 2007
@@ -1,0 +1,187 @@
+<?php
+/**
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ * @version //autogentag//
+ * @filesource
+ * @package Tree
+ */
+
+/**
+ * ezcTreePersistentObjectDataStore is a tree data store that stores persistent
+ * objects.
+ *
+ * @package Tree
+ * @version //autogentag//
+ * @mainclass
+ */
+class ezcTreePersistentObjectDataStore extends ezcTreeDbDataStore
+{
+    /**
+     * Contains the persistent session object
+     *
+     * @var ezcPersistentSession
+     */
+    private $session;
+
+    /**
+     * Contains the class name of the objects that belong to the tree
+     *
+     * @var string
+     */
+    private $class;
+
+    /**
+     * Contains the name of the table field that contains the ID.
+     *
+     * @var string
+     */
+    private $idField = null;
+
+    /**
+     * Contains the name of the object property that contains the ID.
+     *
+     * @var string
+     */
+    private $idProperty = null;
+
+    /**
+     * Constructs a new storage backend that stores objects through persistent
+     * objects.
+     *
+     * The store will use the persistent session specified by $session. The
+     * $class parameter specifies which object class is used.  The class'
+     * property that is matched against the node ID is specified with
+     * $idProperty.
+     *
+     * @param ezcPersistentSession $session
+     * @param string $class
+     * @param string $idProperty
+     */
+    public function __construct( ezcPersistentSession $session, $class, 
$idProperty )
+    {
+        $this->session = $session;
+        $this->class = $class;
+
+        // figure out which column belongs to the property in $idProperty
+        $def = $session->definitionManager->fetchDefinition( $class );
+
+        $this->idField = $def->idProperty->columnName;
+        $this->idProperty = $idProperty;
+    }
+
+    /**
+     * Deletes the data for the node $node from the data store.
+     *
+     * @param ezcTreeNode $node
+    public function deleteDataForNode( ezcTreeNode $node )
+    {
+    }
+     */
+
+    /**
+     * Deletes the data for all the nodes in the node list $nodeList.
+     *
+     * @param ezcTreeNodeList $nodeList
+     */
+    public function deleteDataForNodes( ezcTreeNodeList $nodeList )
+    {
+        $session = $this->session;
+
+        $nodeIdsToDelete = array();
+        foreach ( array_keys( $nodeList->getNodes() ) as $id )
+        {
+            $nodeIdsToDelete[] = (string) $id;
+        }
+
+        $q = $session->createDeleteQuery( $this->class );
+        $q->where( $q->expr->in( $this->session->database->quoteIdentifier( 
$this->idField ), $nodeIdsToDelete ) );
+        $session->deleteFromQuery( $q );
+    }
+
+    /**
+     * Deletes the data for all the nodes in the store.
+     */
+    public function deleteDataForAllNodes()
+    {
+        $session = $this->session;
+
+        $q = $session->createDeleteQuery( $this->class );
+        $session->deleteFromQuery( $q );
+    }
+
+    /**
+     * Retrieves the data for the node $node from the data store and assigns it
+     * to the node's 'data' property.
+     *
+     * @param ezcTreeNode $node
+     */
+    public function fetchDataForNode( ezcTreeNode $node )
+    {
+        $session = $this->session;
+
+        try
+        {
+            $q = $session->load( $this->class, $node->id );
+        }
+        catch ( ezcPersistentQueryException $e )
+        {
+            throw new ezcTreeDataStoreMissingDataException( $node->id );
+        }
+
+        $node->data = $q;
+        $node->dataFetched = true;
+    }
+
+    /**
+     * This method *tries* to fetch the data for all the nodes in the node list
+     * $nodeList and assigns this data to the nodes' 'data' properties.
+     *
+     * @param ezcTreeNodeList $nodeList
+     */
+    public function fetchDataForNodes( ezcTreeNodeList $nodeList )
+    {
+        $session = $this->session;
+
+        $nodeIdsToFetch = array();
+        foreach ( $nodeList->getNodes() as $node )
+        {
+            if ( $node->dataFetched === false )
+            {
+                $nodeIdsToFetch[] = $node->id;
+            }
+        }
+
+        $q = $session->createFindQuery( $this->class );
+        $q->where( $q->expr->in( $this->session->database->quoteIdentifier( 
$this->idField ), $nodeIdsToFetch ) );
+        $objects = $session->find( $q, $this->class );
+
+        foreach ( $objects as $object )
+        {
+            $nodeList[$object->id]->data = $object;
+            $nodeList[$object->id]->dataFetched = true;
+        }
+    }
+
+    /**
+     * Stores the data in the node to the data store.
+     *
+     * @param ezcTreeNode $node
+     */
+    public function storeDataForNode( ezcTreeNode $node )
+    {
+        $session = $this->session;
+
+        $idProperty = $this->idProperty;
+
+        // if the object's ID property is null, populate it with the node's ID
+        if ( $node->data->$idProperty === null )
+        {
+            $node->data->$idProperty = $node->id;
+        }
+        $session->saveOrUpdate( $node->data );
+
+        $node->dataStored = true;
+    }
+}
+?>

Propchange: trunk/TreePersistentObjectTiein/src/stores/persistent_object.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/TreePersistentObjectTiein/src/tree_persistent_autoload.php
==============================================================================
--- trunk/TreePersistentObjectTiein/src/tree_persistent_autoload.php (added)
+++ trunk/TreePersistentObjectTiein/src/tree_persistent_autoload.php 
[iso-8859-1] Fri Aug 10 10:42:39 2007
@@ -1,0 +1,15 @@
+<?php
+/**
+ * Autoloader definition for the TreePersistentObjectTiein component.
+ *
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ * @version //autogentag//
+ * @filesource
+ * @package TreePersistentObjectTiein
+ */
+
+return array(
+    'ezcTreePersistentObjectDataStore' => 
'TreePersistentObjectTiein/stores/persistent_object.php',
+);
+?>

Propchange: trunk/TreePersistentObjectTiein/src/tree_persistent_autoload.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/TreePersistentObjectTiein/tests/files/classes/fileentry.php
==============================================================================
--- trunk/TreePersistentObjectTiein/tests/files/classes/fileentry.php (added)
+++ trunk/TreePersistentObjectTiein/tests/files/classes/fileentry.php 
[iso-8859-1] Fri Aug 10 10:42:39 2007
@@ -1,0 +1,89 @@
+<?php
+// Autogenerated class file
+
+/**
+ * Data class fileentry.
+ * Class to be used with eZ Components PersistentObject.
+ */
+class fileentry
+{
+    const ROOT = 1;
+    const PARTITION = 2;
+    const DIR = 3;
+    const FILE = 4;
+
+    /**
+     * id
+     *
+     * @var string
+     */
+    public $id;
+
+    /**
+     * name
+     *
+     * @var string
+     */
+    public $name;
+
+    /**
+     * type
+     *
+     * @var int
+     */
+    public $type;
+
+    /**
+     * size
+     *
+     * @var int
+     */
+    public $size;
+
+    /**
+     * extra
+     *
+     * @var string
+     */
+    public $extra;
+
+    public function __construct( $name = null, $type = null, $size = null, 
$extra = null )
+    {
+        $this->id = null;
+        $this->name = $name;
+        $this->type = $type;
+        $this->size = $size;
+        $this->extra = $extra;
+    }
+
+    /**
+     * Set the PersistentObject state.
+     *
+     * @param array(string=>mixed) $state The state to set.
+     * @return void
+     */
+     public function setState( array $state )
+     {
+         foreach ( $state as $attribute => $value )
+         {
+             $this->$attribute = $value;
+         }
+     }
+
+    /**
+     * Get the PersistentObject state.
+     *
+     * @return array(string=>mixed) The state of the object.
+     */
+     public function getState()
+     {
+         return array(
+             'extra' => $this->extra,
+             'id' => $this->id,
+             'name' => $this->name,
+             'size' => $this->size,
+             'type' => $this->type,
+         );
+     }
+}
+?>

Propchange: trunk/TreePersistentObjectTiein/tests/files/classes/fileentry.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/TreePersistentObjectTiein/tests/files/defs/fileentry.php
==============================================================================
--- trunk/TreePersistentObjectTiein/tests/files/defs/fileentry.php (added)
+++ trunk/TreePersistentObjectTiein/tests/files/defs/fileentry.php [iso-8859-1] 
Fri Aug 10 10:42:39 2007
@@ -1,0 +1,39 @@
+<?php
+// Autogenerated PersistentObject definition
+
+$def = new ezcPersistentObjectDefinition();
+$def->table = 'fileentry';
+$def->class = 'FileEntry';
+
+$def->properties['extra']               = new ezcPersistentObjectProperty();
+$def->properties['extra']->columnName   = 'extra';
+$def->properties['extra']->propertyName = 'extra';
+$def->properties['extra']->propertyType = 
ezcPersistentObjectProperty::PHP_TYPE_STRING;
+
+
+$def->idProperty               = new ezcPersistentObjectIdProperty();
+$def->idProperty->columnName   = 'fid';
+$def->idProperty->propertyName = 'id';
+$def->idProperty->generator    = new ezcPersistentGeneratorDefinition( 
'ezcPersistentManualGenerator' );
+
+
+$def->properties['name']               = new ezcPersistentObjectProperty();
+$def->properties['name']->columnName   = 'name';
+$def->properties['name']->propertyName = 'name';
+$def->properties['name']->propertyType = 
ezcPersistentObjectProperty::PHP_TYPE_STRING;
+
+
+$def->properties['size']               = new ezcPersistentObjectProperty();
+$def->properties['size']->columnName   = 'size';
+$def->properties['size']->propertyName = 'size';
+$def->properties['size']->propertyType = 
ezcPersistentObjectProperty::PHP_TYPE_INT;
+
+
+$def->properties['type']               = new ezcPersistentObjectProperty();
+$def->properties['type']->columnName   = 'type';
+$def->properties['type']->propertyName = 'type';
+$def->properties['type']->propertyType = 
ezcPersistentObjectProperty::PHP_TYPE_INT;
+
+return $def;
+
+?>

Propchange: trunk/TreePersistentObjectTiein/tests/files/defs/fileentry.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/TreePersistentObjectTiein/tests/files/persistent_store.dba
==============================================================================
--- trunk/TreePersistentObjectTiein/tests/files/persistent_store.dba (added)
+++ trunk/TreePersistentObjectTiein/tests/files/persistent_store.dba 
[iso-8859-1] Fri Aug 10 10:42:39 2007
@@ -1,0 +1,156 @@
+<?php
+return array (
+  0 => 
+  array (
+    'nested_set' => 
+    ezcDbSchemaTable::__set_state(array(
+       'fields' => 
+      array (
+        'id' => 
+        ezcDbSchemaField::__set_state(array(
+           'type' => 'text',
+           'length' => 128,
+           'notNull' => true,
+           'default' => NULL,
+           'autoIncrement' => false,
+           'unsigned' => false,
+        )),
+        'parent_id' => 
+        ezcDbSchemaField::__set_state(array(
+           'type' => 'text',
+           'length' => 128,
+           'notNull' => false,
+           'default' => NULL,
+           'autoIncrement' => false,
+           'unsigned' => false,
+        )),
+        'lft' => 
+        ezcDbSchemaField::__set_state(array(
+           'type' => 'integer',
+           'length' => 0,
+           'notNull' => true,
+           'default' => NULL,
+           'autoIncrement' => false,
+           'unsigned' => false,
+        )),
+        'rgt' => 
+        ezcDbSchemaField::__set_state(array(
+           'type' => 'integer',
+           'length' => 0,
+           'notNull' => true,
+           'default' => NULL,
+           'autoIncrement' => false,
+           'unsigned' => false,
+        )),
+      ),
+      'indexes' => 
+      array (
+        'primary' => 
+        ezcDbSchemaIndex::__set_state(array(
+          'indexFields' => 
+          array (
+            'id' => 
+            ezcDbSchemaIndexField::__set_state(array(
+               'sorting' => NULL,
+            )),
+          ),
+          'primary' => true,
+          'unique' => true,
+        )),
+        'lft' => 
+        ezcDbSchemaIndex::__set_state(array(
+          'indexFields' => 
+          array (
+            'lft' => 
+            ezcDbSchemaIndexField::__set_state(array(
+               'sorting' => NULL,
+            )),
+          ),
+          'primary' => false,
+          'unique' => false,
+        )),
+        'rgt' => 
+        ezcDbSchemaIndex::__set_state(array(
+          'indexFields' => 
+          array (
+            'rgt' => 
+            ezcDbSchemaIndexField::__set_state(array(
+               'sorting' => NULL,
+            )),
+          ),
+          'primary' => false,
+          'unique' => false,
+        )),
+      ),
+    )),
+    'fileentry' => 
+    ezcDbSchemaTable::__set_state(array(
+       'fields' => 
+      array (
+        'fid' => 
+        ezcDbSchemaField::__set_state(array(
+           'type' => 'text',
+           'length' => 128,
+           'notNull' => true,
+           'default' => NULL,
+           'autoIncrement' => false,
+           'unsigned' => false,
+        )),
+        'name' => 
+        ezcDbSchemaField::__set_state(array(
+           'type' => 'text',
+           'length' => 255,
+           'notNull' => true,
+           'default' => NULL,
+           'autoIncrement' => false,
+           'unsigned' => false,
+        )),
+        'type' => 
+        ezcDbSchemaField::__set_state(array(
+           'type' => 'integer',
+           'length' => 11,
+           'notNull' => true,
+           'default' => NULL,
+           'autoIncrement' => false,
+           'unsigned' => false,
+        )),
+        'size' => 
+        ezcDbSchemaField::__set_state(array(
+           'type' => 'integer',
+           'length' => 11,
+           'notNull' => true,
+           'default' => NULL,
+           'autoIncrement' => false,
+           'unsigned' => false,
+        )),
+        'extra' => 
+        ezcDbSchemaField::__set_state(array(
+           'type' => 'text',
+           'length' => 255,
+           'notNull' => false,
+           'default' => NULL,
+           'autoIncrement' => false,
+           'unsigned' => false,
+        )),
+      ),
+      'indexes' => 
+      array (
+        'primary' => 
+        ezcDbSchemaIndex::__set_state(array(
+          'indexFields' => 
+          array (
+            'fid' => 
+            ezcDbSchemaIndexField::__set_state(array(
+               'sorting' => NULL,
+            )),
+          ),
+          'primary' => true,
+          'unique' => true,
+        )),
+      ),
+    )),
+  ),
+  1 =>
+  array(
+  ),
+); ?>

Added: trunk/TreePersistentObjectTiein/tests/po_store.php
==============================================================================
--- trunk/TreePersistentObjectTiein/tests/po_store.php (added)
+++ trunk/TreePersistentObjectTiein/tests/po_store.php [iso-8859-1] Fri Aug 10 
10:42:39 2007
@@ -1,0 +1,237 @@
+<?php
+/**
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ * @version //autogentag//
+ * @filesource
+ * @package Tree
+ * @subpackage Tests
+ */
+
+require_once 'Tree/tests/tree.php';
+require_once 'files/classes/fileentry.php';
+
+/**
+ * @package Tree
+ * @subpackage Tests
+ */
+class ezcTreePersistentObjectStore extends ezcTestCase
+{
+    private $tempDir;
+
+    protected $tables  = array( 'nested_set', 'fileentry' );
+    protected $schemaName = 'persistent_store.dba';
+
+    private $session;
+
+    protected function setUpEmptyTestTree()
+    {
+        $store = new ezcTreePersistentObjectDataStore( $this->session, 
'FileEntry', 'id' );
+        $tree = ezcTreeDbNestedSet::create(
+            $this->dbh,
+            'nested_set',
+            $store
+        );
+        $this->emptyTables();
+        return $tree;
+    }
+
+    protected function setUpTestTree()
+    {
+        $store = new ezcTreePersistentObjectDataStore( $this->session, 
'FileEntry', 'id' );
+        $tree = new ezcTreeDbNestedSet(
+            $this->dbh,
+            'nested_set',
+            $store
+        );
+        return $tree;
+    }
+
+    protected $dbh;
+
+    protected function setUp()
+    {
+        $this->session = new ezcPersistentSession(
+            ezcDbInstance::get(),
+            new ezcPersistentCacheManager( new ezcPersistentCodeManager( 
dirname( __FILE__ ) . '/files/defs' ) )
+        );
+        try
+        {
+            $this->dbh = ezcDbInstance::get();
+            $this->removeTables();
+            $this->loadSchema();
+        }
+        catch ( Exception $e )
+        {
+            $this->markTestSkipped( $e->getMessage() );
+        }
+    }
+
+    private function loadSchema()
+    {
+        // create the parent_child table
+        $schema = ezcDbSchema::createFromFile(
+            'array',
+            dirname( __FILE__ ) . '/files/' . $this->schemaName
+        );
+        $schema->writeToDb( $this->dbh );
+    }
+
+    protected function emptyTables()
+    {
+        $db = $this->dbh;
+
+        foreach ( $this->tables as $table )
+        {
+            $q = $db->createDeleteQuery();
+            $q->deleteFrom( $table );
+            $s = $q->prepare();
+            $s->execute();
+        }
+    }
+
+    protected function removeTables()
+    {
+        try
+        {
+            foreach ( $this->tables as $table )
+            {
+                $this->dbh->exec( "DROP TABLE $table" );
+            }
+        }
+        catch ( Exception $e )
+        {
+            // ignore
+        }
+    }
+
+    private function addStandardData( $tree )
+    {
+        $entry = new FileEntry( ':root:', FileEntry::ROOT, 60639255 );
+        $node = $tree->createNode( 1, $entry );
+        $tree->setRootNode( $node );
+
+        $entry = new FileEntry( '/', FileEntry::PARTITION, 8385596, 
'/dev/sda6' );
+        $node2 = $tree->createNode( 2, $entry );
+        $node->addChild( $node2 );
+
+        $entry = new FileEntry( '/boot', FileEntry::PARTITION, 124443, 
'/dev/sda3' );
+        $node->addChild( $node3 = $tree->createNode( 3, $entry ) );
+        $entry = new FileEntry( '/boot/grub', FileEntry::DIR, 172 );
+        $node3->addChild( $node4 = $tree->createNode( 'grubby', $entry ) );
+        $entry = new FileEntry( '/boot/grub/stage1', FileEntry::FILE, 1 );
+        $node4->addChild( $tree->createNode( 5, $entry ) );
+        $entry = new FileEntry( '/boot/grub/stage2', FileEntry::FILE, 107 );
+        $node4->addChild( $tree->createNode( 6, $entry ) );
+
+        $entry = new FileEntry( '/home', FileEntry::PARTITION, 43743620, 
'/dev/sda7' );
+        $node->addChild( $node7 = $tree->createNode( 7, $entry ) );
+        $entry = new FileEntry( '/home/httpd', FileEntry::DIR, 652577 );
+        $node7->addChild( $node8 = $tree->createNode( 8, $entry ) );
+        $entry = new FileEntry( '/boot/httpd/pw-admin', FileEntry::FILE, 1 );
+        $node8->addChild( $tree->createNode( 9, $entry ) );
+    }
+
+    public function testCreateDbTree()
+    {
+        $tree = $this->setUpEmptyTestTree();
+
+        self::assertSame( false, $tree->nodeExists( '1' ) );
+        self::assertSame( false, $tree->nodeExists( '3' ) );
+
+        $entry = new FileEntry( ':root:', FileEntry::ROOT, 60639255 );
+        $node = $tree->createNode( 1, $entry );
+        self::assertType( 'ezcTreeNode', $node );
+        self::assertSame( '1', $node->id );
+        $tree->setRootNode( $node );
+        self::assertSame( true, $tree->nodeExists( '1' ) );
+
+        $entry = new FileEntry( '/', FileEntry::PARTITION, 8385596, 
'/dev/sda6' );
+        $node2 = $tree->createNode( 2, $entry );
+        $node->addChild( $node2 );
+        self::assertSame( true, $tree->nodeExists( '2' ) );
+
+        $entry = new FileEntry( '/boot', FileEntry::PARTITION, 124443, 
'/dev/sda3' );
+        $node->addChild( $node3 = $tree->createNode( 3, $entry ) );
+        $entry = new FileEntry( '/boot/grub', FileEntry::DIR, 172 );
+        $node3->addChild( $tree->createNode( 4, $entry ) );
+        self::assertSame( true, $tree->nodeExists( '3' ) );
+        self::assertSame( true, $tree->nodeExists( '4' ) );
+    }
+
+    public function testFetchData()
+    {
+        $tree = $this->setUpEmptyTestTree();
+        $this->addStandardData( $tree );
+
+        // start over
+        $tree = $this->setUpTestTree();
+
+        $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 );
+    }
+
+    public function testFetchMissingData()
+    {
+        $tree = $this->setUpEmptyTestTree();
+        $this->addStandardData( $tree );
+        $node = $tree->fetchNodeById( '9' );
+        $data = $node->data;
+        $this->session->delete( $data );
+
+        // start over
+        $tree = $this->setUpTestTree();
+
+        try
+        {
+            $node = $tree->fetchNodeById( '9' );
+            $data = $node->data;
+            self::fail( "Expected exception not thrown." );
+        }
+        catch ( ezcTreeDataStoreMissingDataException $e )
+        {
+            self::assertSame( "The data store does not have data stored for 
the node with ID '9'.", $e->getMessage() );
+        }
+    }
+
+    public function testFetchDataMultipleNodes()
+    {
+        $tree = $this->setUpEmptyTestTree();
+        $this->addStandardData( $tree );
+
+        // start over
+        $tree = $this->setUpTestTree();
+
+        $list = $tree->fetchSubtree( '1' );
+        $tree->prefetch = true;
+        foreach ( new ezcTreeNodeListIterator( $tree, $list ) as $elem )
+        {
+        }
+        self::assertSame( '/boot/httpd/pw-admin', $elem->name );
+    }
+
+    public function testDeleteData()
+    {
+        $tree = $this->setUpEmptyTestTree();
+        $this->addStandardData( $tree );
+
+        $node = $tree->delete( '3' );
+
+        // start over
+        $tree = $this->setUpTestTree();
+        $list = $tree->fetchSubtree( '1' );
+        self::assertSame( 5, $list->size );
+    }
+
+    public static function suite()
+    {
+         return new PHPUnit_Framework_TestSuite( 
"ezcTreePersistentObjectStore" );
+    }
+}
+
+?>

Propchange: trunk/TreePersistentObjectTiein/tests/po_store.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/TreePersistentObjectTiein/tests/suite.php
==============================================================================
--- trunk/TreePersistentObjectTiein/tests/suite.php (added)
+++ trunk/TreePersistentObjectTiein/tests/suite.php [iso-8859-1] Fri Aug 10 
10:42:39 2007
@@ -1,0 +1,37 @@
+<?php
+/**
+ * @copyright Copyright (C) 2005-2007 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ * @version //autogentag//
+ * @filesource
+ * @package Tree
+ * @subpackage Tests
+ */
+
+/**
+ * Require the tests
+ */
+require_once 'Tree/tests/tree.php';
+require_once 'po_store.php';
+
+/**
+ * @package Tree
+ * @subpackage Tests
+ */
+class ezcTreePersistentObjectTieinSuite extends PHPUnit_Framework_TestSuite
+{
+    public function __construct()
+    {
+        parent::__construct();
+        $this->setName("TreePersistentObjectTiein");
+
+        $this->addTest( ezcTreePersistentObjectStore::suite() );
+    }
+
+    public static function suite()
+    {
+        return new ezcTreePersistentObjectTieinSuite();
+    }
+}
+
+?>

Propchange: trunk/TreePersistentObjectTiein/tests/suite.php
------------------------------------------------------------------------------
    svn:eol-style = native


-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to