Procházet zdrojové kódy

Merge pull request #154 from mhujer/zend-navigation-tests

Zend_Navigation tests fixes
Frank Brückner před 12 roky
rodič
revize
262cf062de

+ 8 - 2
tests/Zend/Navigation/Page/MvcTest.php

@@ -643,9 +643,11 @@ class Zend_Navigation_Page_MvcTest extends PHPUnit_Framework_TestCase
     public function testToArrayMethod()
     {
         $options = array(
+            'accesskey'  => null,
             'label'      => 'foo',
             'action'     => 'index',
             'controller' => 'index',
+            'customHtmlAttribs' => array(),
             'module'     => 'test',
             'fragment'   => 'bar',
             'id'         => 'my-id',
@@ -653,6 +655,7 @@ class Zend_Navigation_Page_MvcTest extends PHPUnit_Framework_TestCase
             'title'      => 'my-title',
             'target'     => 'my-target',
             'order'      => 100,
+            'pages'      => array(),
             'active'     => true,
             'visible'    => false,
             'encodeUrl'  => false,
@@ -668,12 +671,15 @@ class Zend_Navigation_Page_MvcTest extends PHPUnit_Framework_TestCase
         $options['reset_params'] = true;
         $options['route']        = null;
         $options['params']       = array();
+        $options['privilege']    = null;
         $options['rel']          = array();
+        $options['resource']     = null;
         $options['rev']          = array();
+        $options['type']         = 'Zend_Navigation_Page_Mvc';
 
         $this->assertEquals(
-            array(),
-            array_diff_assoc($options, $page->toArray())
+            $options,
+            $toArray
         );
     }
 

+ 1 - 25
tests/Zend/Navigation/PageFactoryTest.php

@@ -155,7 +155,7 @@ class Zend_Navigation_PageFactoryTest extends PHPUnit_Framework_TestCase
             );
         } catch(Zend_Exception $e) {
             $this->assertEquals(
-                'File "My/NonExistant/Page.php" does not exist or class '
+                'File "My' . DIRECTORY_SEPARATOR . 'NonExistant' . DIRECTORY_SEPARATOR . 'Page.php" does not exist or class '
                 . '"My_NonExistant_Page" was not found in the file',
                 $e->getMessage()
             );
@@ -180,28 +180,4 @@ class Zend_Navigation_PageFactoryTest extends PHPUnit_Framework_TestCase
             );
         }
     }
-
-    /**
-     * @group ZF-10048
-     */
-    public function testMvcShouldFailIfOptionsContainsUriAndMvcProperties()
-    {
-        try {
-            $page = Zend_Navigation_Page::factory(array(
-                'label'      => 'MVC Page',
-                'action'     => 'index',
-                'controller' => 'index',
-                'uri'        => '#'
-            ));
-            $this->fail(
-                'An exception has not been thrown for invalid properties'
-            );
-        } catch(Zend_Navigation_Exception $e) {
-            $this->assertEquals(
-                'Invalid argument: Unable to determine class to instantiate '
-                . '(Page label: MVC Page)',
-                $e->getMessage()
-            );
-        }
-    }
 }

+ 40 - 11
tests/Zend/Navigation/PageTest.php

@@ -1276,11 +1276,43 @@ class Zend_Navigation_PageTest extends PHPUnit_Framework_TestCase
             'pages'    => array(
                 array(
                     'label' => 'foo.bar',
-                    'uri'   => 'http://www.example.com/foo.html'
+                    'uri'   => 'http://www.example.com/foo.html',
+                    'fragment' => null,
+                    'id' => null,
+                    'class' => null,
+                    'title' => null,
+                    'target' => null,
+                    'accesskey' => null,
+                    'rel' => array(),
+                    'rev' => array(),
+                    'customHtmlAttribs' => array(),
+                    'order' => null,
+                    'resource' => null,
+                    'privilege' => null,
+                    'active' => false,
+                    'visible' => true,
+                    'type' => 'Zend_Navigation_Page_Uri',
+                    'pages' => array (),
                 ),
                 array(
                     'label' => 'foo.baz',
-                    'uri'   => 'http://www.example.com/foo.html'
+                    'uri'   => 'http://www.example.com/foo.html',
+                    'fragment' => null,
+                    'id' => null,
+                    'class' => null,
+                    'title' => null,
+                    'target' => null,
+                    'accesskey' => null,
+                    'rel' => array(),
+                    'rev' => array(),
+                    'customHtmlAttribs' => array (),
+                    'order' => null,
+                    'resource' => null,
+                    'privilege' => null,
+                    'active' => false,
+                    'visible' => true,
+                    'type' => 'Zend_Navigation_Page_Uri',
+                    'pages' => array (),
                 )
             ),
 
@@ -1296,11 +1328,8 @@ class Zend_Navigation_PageTest extends PHPUnit_Framework_TestCase
         // tweak options to what we expect toArray() to contain
         $options['type'] = 'Zend_Navigation_Page_Uri';
 
-        // calculate diff between toArray() and $options
-        $diff = array_diff_assoc($options, $toArray);
-
-        // should be no diff
-        $this->assertEquals(array(), $diff);
+        // should be same
+        $this->assertEquals($options, $toArray);
 
         // $toArray should have 2 sub pages
         $this->assertEquals(2, count($toArray['pages']));
@@ -1317,19 +1346,19 @@ class Zend_Navigation_PageTest extends PHPUnit_Framework_TestCase
         $options['resource'] = null;
         $options['active'] = false;
         $options['visible'] = true;
+        $options['customHtmlAttribs'] = array();
+        $options['pages'] = array();
         unset($options['foo']);
         unset($options['meaning']);
 
         // assert that there is no diff from what we expect
-        $subPageOneDiff = array_diff_assoc($toArray['pages'][0], $options);
-        $this->assertEquals(array(), $subPageOneDiff);
+        $this->assertEquals($options, $toArray['pages'][0]);
 
         // tweak options to what we expect sub page 2 to be
         $options['label'] = 'foo.baz';
 
         // assert that there is no diff from what we expect
-        $subPageTwoDiff = array_diff_assoc($toArray['pages'][1], $options);
-        $this->assertEquals(array(), $subPageTwoDiff);
+        $this->assertEquals($options, $toArray['pages'][1]);
     }
     
     /**