Author: dr
Date: Mon Dec 10 17:18:22 2007
New Revision: 6955

Log:
- Added the xmlId parameter to the YUI visitor constructor, as it is a
  required argument it does not belong in the options class.
- Removed the xmlId option from the ezcTreeVisitorYUIOptions class.

Modified:
    trunk/Tree/ChangeLog
    trunk/Tree/src/options/visitor_yui.php
    trunk/Tree/src/visitors/yui.php
    trunk/Tree/tests/visitor_yui.php
    trunk/Tree/tests/visitor_yui_options.php

Modified: trunk/Tree/ChangeLog
==============================================================================
--- trunk/Tree/ChangeLog [iso-8859-1] (original)
+++ trunk/Tree/ChangeLog [iso-8859-1] Mon Dec 10 17:18:22 2007
@@ -1,3 +1,11 @@
+1.0 - [RELEASEDATE]
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- Added the xmlId parameter to the YUI visitor constructor, as it is a
+  required argument it does not belong in the options class. 
+- Removed the xmlId option from the ezcTreeVisitorYUIOptions class.
+
+
 1.0beta1 - Wednesday 28 November 2007
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

Modified: trunk/Tree/src/options/visitor_yui.php
==============================================================================
--- trunk/Tree/src/options/visitor_yui.php [iso-8859-1] (original)
+++ trunk/Tree/src/options/visitor_yui.php [iso-8859-1] Mon Dec 10 17:18:22 2007
@@ -18,8 +18,6 @@
  *           Whether the root node should be displayed. The root node will
  *           still be disabled from the links that the visitor create when
  *           $selectedNodeLink is set to true.
- * @property string $xmlId
- *           The ID that should be set on the top level <ul> tag.
  * @property array(string) $highlightNodeIds
  *           Which IDs should have the 'highlight' CSS class added.
  * @property bool $selectedNodeLink
@@ -43,7 +41,6 @@
     {
         $this->basePath = '';
         $this->displayRootNode = false;
-        $this->xmlId = null;
         $this->highlightNodeIds = array();
         $this->selectedNodeLink = false;
 
@@ -90,14 +87,6 @@
                 $this->properties[$name] = $value;
                 break;
 
-            case 'xmlId':
-                if ( !is_null( $value ) && !is_string( $value ) )
-                {
-                    throw new ezcBaseValueException( $name, $value, 'null or 
string' );
-                }
-                $this->properties[$name] = $value;
-                break;
-
             default:
                 throw new ezcBasePropertyNotFoundException( $name );
         }

Modified: trunk/Tree/src/visitors/yui.php
==============================================================================
--- trunk/Tree/src/visitors/yui.php [iso-8859-1] (original)
+++ trunk/Tree/src/visitors/yui.php [iso-8859-1] Mon Dec 10 17:18:22 2007
@@ -12,7 +12,7 @@
 /**
  * An implementation of the ezcTreeVisitor interface that generates
  * an XHTML representatation of a tree structure, as YUI wants.
- * See {link http://developer.yahoo.com/yui/menu}.
+ * See [EMAIL PROTECTED] http://developer.yahoo.com/yui/menu}.
  *
  * <code>
  * <?php
@@ -46,7 +46,7 @@
      *
      * @var string
      */
-    protected $id;
+    protected $xmlId;
 
     /**
      * Holds the XHTML class.
@@ -67,8 +67,13 @@
      *
      * @param ezcTreeVisitorYUIOptions $options
      */
-    public function __construct( ezcTreeVisitorYUIOptions $options = null )
-    {
+    public function __construct( $xmlId, ezcTreeVisitorYUIOptions $options = 
null )
+    {
+        if ( !is_string( $xmlId ) || strlen( $xmlId ) === 0 )
+        {
+            throw new ezcBaseValueException( 'xmlId', $xmlId, 'non-empty 
string' );
+        }
+        $this->xmlId = $xmlId;
         if ( $options === null )
         {
             $this->options = new ezcTreeVisitorYUIOptions;
@@ -224,7 +229,7 @@
         $tree = '';
         $this->treeIdSet = false;
 
-        $idPart = $this->options->xmlId ? " id=\"{$this->options->xmlId}\"" : 
'';
+        $idPart = " id=\"{$this->xmlId}\"";
         $tree .= "<div{$idPart} class='yuimenubar yuimenubarnav'>\n";
         if ( $this->options->displayRootNode )
         {

Modified: trunk/Tree/tests/visitor_yui.php
==============================================================================
--- trunk/Tree/tests/visitor_yui.php [iso-8859-1] (original)
+++ trunk/Tree/tests/visitor_yui.php [iso-8859-1] Mon Dec 10 17:18:22 2007
@@ -17,15 +17,41 @@
  */
 class ezcTreeVisitorYUITest extends ezcTreeVisitorTest
 {
+    public function testBrokenXmlId()
+    {
+        try
+        {
+            $visitor = new ezcTreeVisitorYUI( 42 );
+            self::fail( 'Expected exception not thrown.' );
+        }
+        catch ( ezcBaseValueException $e )
+        {
+            self::assertSame( "The value '42' that you were trying to assign 
to setting 'xmlId' is invalid. Allowed values are: non-empty string.", 
$e->getMessage() );
+        }
+    }
+
+    public function testEmptyXmlId()
+    {
+        try
+        {
+            $visitor = new ezcTreeVisitorYUI( '' );
+            self::fail( 'Expected exception not thrown.' );
+        }
+        catch ( ezcBaseValueException $e )
+        {
+            self::assertSame( "The value '' that you were trying to assign to 
setting 'xmlId' is invalid. Allowed values are: non-empty string.", 
$e->getMessage() );
+        }
+    }
+
     public function testVisitorYUIDefault()
     {
         $tree = ezcTreeMemory::create( new ezcTreeMemoryDataStore() );
         $this->addTestData( $tree );
 
-        $visitor = new ezcTreeVisitorYUI();
+        $visitor = new ezcTreeVisitorYUI( 'productsandservices' );
         $tree->accept( $visitor );
         $expected = <<<END
-<div class='yuimenubar yuimenubarnav'>
+<div id="productsandservices" class='yuimenubar yuimenubarnav'>
       <div class='bd'>
       <ul>
         <li class='yuimenubaritem'><a class='yuimenubaritemlabel' 
href='/Hylobatidae'>Hylobatidae</a>
@@ -160,12 +186,12 @@
         $tree = ezcTreeMemory::create( new ezcTreeMemoryDataStore() );
         $this->addTestData( $tree );
 
-        $visitor = new ezcTreeVisitorYUI();
+        $visitor = new ezcTreeVisitorYUI( 'productsandservices' );
         $visitor->options->displayRootNode = true;
 
         $tree->accept( $visitor );
         $expected = <<<END
-<div class='yuimenubar yuimenubarnav'>
+<div id="productsandservices" class='yuimenubar yuimenubarnav'>
   <div class='bd'>
     <ul>
       <li class='yuimenubaritem'><a class='yuimenubaritemlabel' 
href='/Hominoidea/Hylobatidae'>Hominoidea</a>
@@ -308,12 +334,12 @@
         $tree = ezcTreeMemory::create( new ezcTreeMemoryDataStore() );
         $this->addTestData( $tree );
 
-        $visitor = new ezcTreeVisitorYUI();
+        $visitor = new ezcTreeVisitorYUI( 'productsandservices' );
         $visitor->options->selectedNodeLink = true;
 
         $tree->accept( $visitor );
         $expected = <<<END
-<div class='yuimenubar yuimenubarnav'>
+<div id="productsandservices" class='yuimenubar yuimenubarnav'>
       <div class='bd'>
       <ul>
         <li class='yuimenubaritem'><a class='yuimenubaritemlabel' 
href='/Hylobatidae'>Hylobatidae</a>
@@ -448,13 +474,13 @@
         $tree = ezcTreeMemory::create( new ezcTreeMemoryDataStore() );
         $this->addTestData( $tree );
 
-        $visitor = new ezcTreeVisitorYUI();
+        $visitor = new ezcTreeVisitorYUI( 'productsandservices' );
         $visitor->options->displayRootNode = true;
         $visitor->options->selectedNodeLink = true;
 
         $tree->accept( $visitor );
         $expected = <<<END
-<div class='yuimenubar yuimenubarnav'>
+<div id="productsandservices" class='yuimenubar yuimenubarnav'>
   <div class='bd'>
     <ul>
       <li class='yuimenubaritem'><a class='yuimenubaritemlabel' 
href='/Hominoidea/Hylobatidae'>Hominoidea</a>
@@ -597,14 +623,14 @@
         $tree = ezcTreeMemory::create( new ezcTreeMemoryDataStore() );
         $this->addTestData( $tree );
 
-        $visitor = new ezcTreeVisitorYUI();
+        $visitor = new ezcTreeVisitorYUI( 'productsandservices' );
         $visitor->options->displayRootNode = true;
         $visitor->options->selectedNodeLink = true;
         $visitor->options->basePath = 'testing';
 
         $tree->accept( $visitor );
         $expected = <<<END
-<div class='yuimenubar yuimenubarnav'>
+<div id="productsandservices" class='yuimenubar yuimenubarnav'>
   <div class='bd'>
     <ul>
       <li class='yuimenubaritem'><a class='yuimenubaritemlabel' 
href='/Hominoidea/Hylobatidae'>Hominoidea</a>
@@ -747,8 +773,7 @@
         $tree = ezcTreeMemory::create( new ezcTreeMemoryDataStore() );
         $this->addTestData( $tree );
 
-        $visitor = new ezcTreeVisitorYUI();
-        $visitor->options->xmlId = 'productsandservices';
+        $visitor = new ezcTreeVisitorYUI( 'productsandservices' );
 
         $tree->fetchNodeById( 'Hylobatidae' )->accept( $visitor );
         $expected = <<<END
@@ -807,11 +832,11 @@
 
         $options = new ezcTreeVisitorYUIOptions;
         $options->highlightNodeIds = array( 'Nomascus', 'Eastern Black Crested 
Gibbon', 'Hoolock' );
-        $visitor = new ezcTreeVisitorYUI( $options );
+        $visitor = new ezcTreeVisitorYUI( 'monkeys', $options );
 
         $tree->fetchNodeById( 'Hylobatidae' )->accept( $visitor );
         $expected = <<<END
-<div class='yuimenubar yuimenubarnav'>
+<div id="monkeys" class='yuimenubar yuimenubarnav'>
       <div class='bd'>
       <ul>
         <li class='yuimenubaritem'><a class='yuimenubaritemlabel' 
href='/Hylobatidae/Hylobates'>Hylobates</a>

Modified: trunk/Tree/tests/visitor_yui_options.php
==============================================================================
--- trunk/Tree/tests/visitor_yui_options.php [iso-8859-1] (original)
+++ trunk/Tree/tests/visitor_yui_options.php [iso-8859-1] Mon Dec 10 17:18:22 
2007
@@ -23,7 +23,6 @@
 
         self::assertSame( '', $options->basePath );
         self::assertSame( false, $options->displayRootNode );
-        self::assertSame( null, $options->xmlId );
         self::assertSame( array(), $options->highlightNodeIds );
         self::assertSame( false, $options->selectedNodeLink );
     }
@@ -48,13 +47,11 @@
 
         $options->basePath = '/view';
         $options->displayRootNode = true;
-        $options->xmlId = 'menu_tree';
         $options->highlightNodeIds = array( 'root' );
         $options->selectedNodeLink = true;
 
         self::assertSame( '/view', $options->basePath );
         self::assertSame( true, $options->displayRootNode );
-        self::assertSame( 'menu_tree', $options->xmlId );
         self::assertSame( array( 'root' ), $options->highlightNodeIds );
         self::assertSame( true, $options->selectedNodeLink );
     }
@@ -64,7 +61,6 @@
         $optionsArray = array();
         $optionsArray['basePath'] = '/view';
         $optionsArray['displayRootNode'] = true;
-        $optionsArray['xmlId'] = 'menu_tree';
         $optionsArray['highlightNodeIds'] = array( 'root' );
         $optionsArray['selectedNodeLink'] = true;
 
@@ -72,7 +68,6 @@
 
         self::assertSame( '/view', $options->basePath );
         self::assertSame( true, $options->displayRootNode );
-        self::assertSame( 'menu_tree', $options->xmlId );
         self::assertSame( array( 'root' ), $options->highlightNodeIds );
         self::assertSame( true, $options->selectedNodeLink );
     }
@@ -119,20 +114,6 @@
         }
     }
 
-    public function testSetInvalidXmlId()
-    {
-        $options = new ezcTreeVisitorYUIOptions;
-        try
-        {
-            $options->xmlId = 42;
-            self::fail( "Expected exception not thrown." );
-        }
-        catch ( ezcBaseValueException $e )
-        {
-            self::assertSame( "The value '42' that you were trying to assign 
to setting 'xmlId' is invalid. Allowed values are: null or string.", 
$e->getMessage() );
-        }
-    }
-
     public function testSetInvalidHighlightNodes()
     {
         $options = new ezcTreeVisitorYUIOptions;


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to