Author: dr
Date: Fri Oct 5 11:26:34 2007
New Revision: 6365
Log:
- Addressed __isset() and __get_state() comments.
Modified:
trunk/Tree/review.txt
trunk/Tree/src/backends/xml.php
trunk/Tree/src/structs/memory_node.php
trunk/Tree/src/structs/transaction_item.php
trunk/Tree/src/tree.php
trunk/Tree/src/tree_node.php
trunk/Tree/tests/memory_tree.php
trunk/Tree/tests/tree.php
trunk/Tree/tests/tree_node.php
trunk/Tree/tests/xml_tree.php
Modified: trunk/Tree/review.txt
==============================================================================
--- trunk/Tree/review.txt [iso-8859-1] (original)
+++ trunk/Tree/review.txt [iso-8859-1] Fri Oct 5 11:26:34 2007
@@ -20,7 +20,7 @@
- TreeDatabaseTiein/src/backends/db_parent_child.php
- TreeDatabaseTiein/src/backends/db.php
-[ ] Files missing __isset():
+[X] Files missing __isset():
- Tree/src/backends/memory.php
- Tree/src/backends/xml.php
- Tree/src/tree_node.php
@@ -31,8 +31,32 @@
- TreeDatabaseTiein/src/backends/db_parent_child.php
- TreeDatabaseTiein/src/backends/db.php
-[ ] Files missing __set_state():
+ ezcTreeNodeList did indeed not need it (because of ArrayAccess), and all
+ the backends actually inherit ezcTree, which does now implement
__isset().
+
+[X] Files missing __set_state():
- Tree/src/structs/memory_node.php
- Tree/src/structs/transaction_item.php
+ They are not public, so they don't need __set_state(). I marked them as
+ private classes now.
+
+Other points
+------------
+
+[ ] Allow the / char to be changed in the nested set implementation, and add a
check
+ for this char in used IDs when creating a new node.
+
+[ ] Check how we can use node names paths to retrieve items.
+
+[ ] Check XHTML visitor's generation of paths - they are sort of useles as
only the
+ last item is used. Perhaps make this an option.
+
+[ ] Check if the highlighting can be done on the data, and not the <li> nodes -
+ make that an option as well perhaps.
+
+[ ] Check example from Alex, and add them to docs if useful.
+
+[ ] Issue #11444: Clarify the use of '/' for ID naming in Trees
+
Modified: trunk/Tree/src/backends/xml.php
==============================================================================
--- trunk/Tree/src/backends/xml.php [iso-8859-1] (original)
+++ trunk/Tree/src/backends/xml.php [iso-8859-1] Fri Oct 5 11:26:34 2007
@@ -167,6 +167,47 @@
}
/**
+ * Sets the property $name to $value.
+ *
+ * @throws ezcBasePropertyNotFoundException if the property does not exist.
+ * @throws ezcBasePropertyPermissionException if a read-only property is
+ * tried to be modified.
+ * @param string $name
+ * @param mixed $value
+ * @ignore
+ */
+ public function __set( $name, $value )
+ {
+ switch ( $name )
+ {
+ case 'prefix':
+ throw new ezcBasePropertyPermissionException( $name,
ezcBasePropertyPermissionException::READ );
+
+ default:
+ return parent::__set( $name, $value );
+ }
+ }
+
+ /**
+ * Returns true if the property $name is set, otherwise false.
+ *
+ * @param string $name
+ * @return bool
+ * @ignore
+ */
+ public function __isset( $name )
+ {
+ switch ( $name )
+ {
+ case 'prefix':
+ return isset( $this->properties[$name] );
+
+ default:
+ return parent::__isset( $name );
+ }
+ }
+
+ /**
* Creates a new XML tree in the file $xmlFile using $store as data store.
*
* The $prefix option can be used to change the prefix that is used for IDs
Modified: trunk/Tree/src/structs/memory_node.php
==============================================================================
--- trunk/Tree/src/structs/memory_node.php [iso-8859-1] (original)
+++ trunk/Tree/src/structs/memory_node.php [iso-8859-1] Fri Oct 5 11:26:34 2007
@@ -7,6 +7,7 @@
* @version //autogentag//
* @filesource
* @package Tree
+ * @access private
*/
/**
@@ -15,6 +16,7 @@
*
* @package Tree
* @version //autogentag//
+ * @access private
*/
class ezcTreeMemoryNode extends ezcBaseStruct
{
Modified: trunk/Tree/src/structs/transaction_item.php
==============================================================================
--- trunk/Tree/src/structs/transaction_item.php [iso-8859-1] (original)
+++ trunk/Tree/src/structs/transaction_item.php [iso-8859-1] Fri Oct 5
11:26:34 2007
@@ -7,6 +7,7 @@
* @version //autogentag//
* @filesource
* @package Tree
+ * @access private
*/
/**
@@ -14,6 +15,7 @@
*
* @package Tree
* @version //autogentag//
+ * @access private
*/
class ezcTreeTransactionItem extends ezcBaseStruct
{
Modified: trunk/Tree/src/tree.php
==============================================================================
--- trunk/Tree/src/tree.php [iso-8859-1] (original)
+++ trunk/Tree/src/tree.php [iso-8859-1] Fri Oct 5 11:26:34 2007
@@ -146,6 +146,26 @@
}
/**
+ * Returns true if the property $name is set, otherwise false.
+ *
+ * @param string $name
+ * @return bool
+ * @ignore
+ */
+ public function __isset( $name )
+ {
+ switch ( $name )
+ {
+ case 'store':
+ case 'nodeClassName':
+ return isset( $this->properties[$name] );
+
+ default:
+ return false;
+ }
+ }
+
+ /**
* Creates a new tree node with node ID $nodeId and $data.
*
* This method returns by default an object of the ezcTreeNode class,
Modified: trunk/Tree/src/tree_node.php
==============================================================================
--- trunk/Tree/src/tree_node.php [iso-8859-1] (original)
+++ trunk/Tree/src/tree_node.php [iso-8859-1] Fri Oct 5 11:26:34 2007
@@ -152,6 +152,29 @@
}
/**
+ * Returns true if the property $name is set, otherwise false.
+ *
+ * @param string $name
+ * @return bool
+ * @ignore
+ */
+ public function __isset( $name )
+ {
+ switch ( $name )
+ {
+ case 'id':
+ case 'tree':
+ case 'data':
+ case 'dataFetched':
+ case 'dataStored':
+ return isset( $this->properties[$name] );
+
+ default:
+ return false;
+ }
+ }
+
+ /**
* Implements the accept method for visiting.
*
* @param ezcTreeVisitor $visitor
Modified: trunk/Tree/tests/memory_tree.php
==============================================================================
--- trunk/Tree/tests/memory_tree.php [iso-8859-1] (original)
+++ trunk/Tree/tests/memory_tree.php [iso-8859-1] Fri Oct 5 11:26:34 2007
@@ -84,6 +84,10 @@
self::assertSame( true, $tree->nodeExists( '3' ) );
}
+ public function testMemoryNodeSetState()
+ {
+ }
+
public static function suite()
{
return new PHPUnit_Framework_TestSuite( "ezcTreeMemoryTest" );
Modified: trunk/Tree/tests/tree.php
==============================================================================
--- trunk/Tree/tests/tree.php [iso-8859-1] (original)
+++ trunk/Tree/tests/tree.php [iso-8859-1] Fri Oct 5 11:26:34 2007
@@ -68,10 +68,16 @@
}
}
+ public function testIssetStore()
+ {
+ $tree = $this->setUpTestTree();
+ self::assertSame( true, isset( $tree->store ) );
+ }
+
public function testSetStore()
{
$tree = $this->setUpTestTree();
-
+
try
{
$tree->store = new TestTranslateDataStore;
@@ -81,6 +87,12 @@
{
self::assertSame( "The property 'store' is read-only.",
$e->getMessage() );
}
+ }
+
+ public function testIssetNodeClassName()
+ {
+ $tree = $this->setUpTestTree();
+ self::assertSame( true, isset( $tree->nodeClassName ) );
}
public function testSetNodeClassName()
@@ -119,6 +131,13 @@
{
self::assertSame( "Class 'ezcTreeMemoryNode' does not exist, or
does not inherit from the 'ezcTreeNode' class.", $e->getMessage() );
}
+ }
+
+ public function testIssetUnknownProperty()
+ {
+ $tree = $this->setUpTestTree();
+
+ self::assertSame( false, isset( $tree->unknown ) );
}
public function testSetUnknownProperty()
Modified: trunk/Tree/tests/tree_node.php
==============================================================================
--- trunk/Tree/tests/tree_node.php [iso-8859-1] (original)
+++ trunk/Tree/tests/tree_node.php [iso-8859-1] Fri Oct 5 11:26:34 2007
@@ -88,6 +88,17 @@
{
self::assertSame( "No such property name 'unknown'.",
$e->getMessage() );
}
+ }
+
+ public function testIssetProperty()
+ {
+ $node = new ezcTreeNode( $this->tree, 'Pl', 'Plutonium' );
+ self::assertSame( true, isset( $node->id ) );
+ self::assertSame( true, isset( $node->tree ) );
+ self::assertSame( true, isset( $node->data ) );
+ self::assertSame( true, isset( $node->dataFetched ) );
+ self::assertSame( true, isset( $node->dataStored ) );
+ self::assertSame( false, isset( $node->unknown ) );
}
public function testAddChild()
Modified: trunk/Tree/tests/xml_tree.php
==============================================================================
--- trunk/Tree/tests/xml_tree.php [iso-8859-1] (original)
+++ trunk/Tree/tests/xml_tree.php [iso-8859-1] Fri Oct 5 11:26:34 2007
@@ -157,6 +157,37 @@
);
}
+ public function testSetPrefix()
+ {
+ $tree = ezcTreeXml::create(
+ $this->tempDir . '/new-tree.xml',
+ new ezcTreeXmlInternalDataStore(),
+ 'ezc'
+ );
+
+ try
+ {
+ $tree->prefix = 'foo';
+ self::fail( "Expected exception not thrown" );
+ }
+ catch ( ezcBasePropertyPermissionException $e )
+ {
+ self::assertSame( "The property 'prefix' is read-only.",
$e->getMessage() );
+ }
+ }
+
+ public function testIssetAndGetPrefix()
+ {
+ $tree = ezcTreeXml::create(
+ $this->tempDir . '/new-tree.xml',
+ new ezcTreeXmlInternalDataStore(),
+ 'ezc'
+ );
+
+ self::assertSame( true, isset( $tree->prefix ) );
+ self::assertSame( 'ezc', $tree->prefix );
+ }
+
public function testCreateXmlTreeWithTransaction()
{
$tree = ezcTreeXml::create(
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components