Author: dr
Date: Tue Aug  7 15:13:23 2007
New Revision: 5834

Log:
- Added test cases for the memory store, just to make sure it doesn't modify
  anything.

Added:
    trunk/Tree/tests/memory_store.php   (with props)
Modified:
    trunk/Tree/tests/suite.php

Added: trunk/Tree/tests/memory_store.php
==============================================================================
--- trunk/Tree/tests/memory_store.php (added)
+++ trunk/Tree/tests/memory_store.php [iso-8859-1] Tue Aug  7 15:13:23 2007
@@ -1,0 +1,101 @@
+<?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
+ */
+
+/**
+ * @package Tree
+ * @subpackage Tests
+ */
+class ezcTreeMemoryStoreTest extends ezcTestCase
+{
+    public function testMemoryStoreFetchDataForNode()
+    {
+        $store = new ezcTreeMemoryDataStore;
+        $tree  = ezcTreeMemory::create( $store );
+
+        $node = new ezcTreeNode( $tree, 'Mercury', '☿' );
+        $ser = serialize( $node );
+        self::assertSame( $node->id, 'Mercury' );
+        self::assertSame( $node->data, '☿' );
+
+        $store->fetchDataForNode( $node );
+        self::assertSame( $node->id, 'Mercury' );
+        self::assertSame( $node->data, '☿' );
+        self::assertSame( $ser, serialize( $node ) );
+    }
+
+    public function testMemoryStoreFetchDataForNodes()
+    {
+        $store = new ezcTreeMemoryDataStore;
+        $tree  = ezcTreeMemory::create( $store );
+
+        $list = new ezcTreeNodeList();
+        $list->addNode( new ezcTreeNode( $tree, 'Venus', '♀' ) );
+        $list->addNode( new ezcTreeNode( $tree, 'Earth', '♁' ) );
+        $ser = serialize( $list );
+
+        $store->fetchDataForNodes( $list );
+
+        self::assertSame( $ser, serialize( $list ) );
+    }
+
+    public function testMemoryStoreDeleteDataForNodes()
+    {
+        $store = new ezcTreeMemoryDataStore;
+        $tree  = ezcTreeMemory::create( $store );
+
+        $list = new ezcTreeNodeList();
+        $list->addNode( new ezcTreeNode( $tree, 'Mars', '♂' ) );
+        $list->addNode( new ezcTreeNode( $tree, 'Jupiter', '♃' ) );
+        $ser = serialize( $list );
+
+        $store->deleteDataForNodes( $list );
+
+        self::assertSame( $ser, serialize( $list ) );
+    }
+
+    public function testMemoryStoreDataForNode()
+    {
+        $store = new ezcTreeMemoryDataStore;
+        $tree  = ezcTreeMemory::create( $store );
+
+        $node = new ezcTreeNode( $tree, 'Saturn', '♄' );
+        $ser = serialize( $node );
+
+        $store->storeDataForNode( $node );
+
+        self::assertSame( $ser, serialize( $node ) );
+    }
+
+    public function testMemoryStoreDeleteDataForAllNodes()
+    {
+        $store = new ezcTreeMemoryDataStore;
+        $tree  = ezcTreeMemory::create( $store );
+
+        $uranus = new ezcTreeNode( $tree, 'Uranus', '♅' );
+        $tree->setRootNode( $uranus );
+        $uranus->addChild( new ezcTreeNode( $tree, 'Miranda', 'Miranda' ) );
+        $uranus->addChild( new ezcTreeNode( $tree, 'Ariel', 'Ariel' ) );
+        $uranus->addChild( new ezcTreeNode( $tree, 'Umbriel', 'Umbriel' ) );
+        $uranus->addChild( new ezcTreeNode( $tree, 'Titania', 'Titania' ) );
+        $uranus->addChild( new ezcTreeNode( $tree, 'Oberon', 'Oberon' ) );
+
+        $store->deleteDataForAllNodes();
+
+        self::assertSame( 'Ariel', $tree->fetchNodeById( 'Ariel' )->id );
+        self::assertSame( 'Titania', $tree->fetchNodeById( 'Titania' )->data );
+    }
+
+    public static function suite()
+    {
+         return new PHPUnit_Framework_TestSuite( "ezcTreeMemoryStoreTest" );
+    }
+}
+
+?>

Propchange: trunk/Tree/tests/memory_store.php
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/Tree/tests/suite.php
==============================================================================
--- trunk/Tree/tests/suite.php [iso-8859-1] (original)
+++ trunk/Tree/tests/suite.php [iso-8859-1] Tue Aug  7 15:13:23 2007
@@ -15,6 +15,7 @@
 require_once 'tree_node.php';
 require_once 'tree_node_list.php';
 require_once 'tree_node_list_iterator.php';
+require_once 'memory_store.php';
 require_once 'visitor.php';
 require_once 'memory_tree.php';
 require_once 'xml_tree.php';
@@ -36,6 +37,7 @@
         $this->addTest( ezcTreeNodeTest::suite() );
         $this->addTest( ezcTreeNodeListTest::suite() );
         $this->addTest( ezcTreeNodeListIteratorTest::suite() );
+        $this->addTest( ezcTreeMemoryStoreTest::suite() );
         $this->addTest( ezcTreeVisitorTest::suite() );
         $this->addTest( ezcTreeMemoryTest::suite() );
         $this->addTest( ezcTreeXmlTest::suite() );


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

Reply via email to