Index: tests/Zend/Navigation/PageTest.php =================================================================== --- tests/Zend/Navigation/PageTest.php (revision 24182) +++ tests/Zend/Navigation/PageTest.php (working copy) @@ -265,6 +265,35 @@ } } } + + /** + * @group ZF-9746 + */ + public function testSetAndGetAccesskey() + { + $page = Zend_Navigation_Page::factory(array( + 'label' => 'foo', + 'uri' => '#', + )); + + $this->assertEquals(null, $page->getAccesskey()); + $page->setAccesskey('b'); + $this->assertEquals('b', $page->getAccesskey()); + + $invalids = array('bar', 42, true, (object) null); + foreach ($invalids as $invalid) { + try { + $page->setAccesskey($invalid); + $this->fail('An invalid value was set, but a ' . + 'Zend_Navigation_Exception was not thrown'); + } catch (Zend_Navigation_Exception $e) { + $this->assertContains( + 'Invalid argument: $character', + $e->getMessage() + ); + } + } + } public function testConstructingWithRelationsInArray() { @@ -1093,25 +1122,26 @@ public function testToArrayMethod() { $options = array( - 'label' => 'foo', - 'uri' => '#', - 'id' => 'my-id', - 'class' => 'my-class', - 'title' => 'my-title', - 'target' => 'my-target', - 'rel' => array(), - 'rev' => array(), - 'order' => 100, - 'active' => true, - 'visible' => false, + 'label' => 'foo', + 'uri' => '#', + 'id' => 'my-id', + 'class' => 'my-class', + 'title' => 'my-title', + 'target' => 'my-target', + 'accesskey' => 'f', + 'rel' => array(), + 'rev' => array(), + 'order' => 100, + 'active' => true, + 'visible' => false, - 'resource' => 'joker', + 'resource' => 'joker', 'privilege' => null, - 'foo' => 'bar', - 'meaning' => 42, + 'foo' => 'bar', + 'meaning' => 42, - 'pages' => array( + 'pages' => array( array( 'label' => 'foo.bar', 'uri' => '#' @@ -1129,9 +1159,9 @@ // 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($toArray, $options); - + // calculate diff between toArray() and $options + $diff = array_diff_assoc($options, $toArray); + // should be no diff $this->assertEquals(array(), $diff); @@ -1139,15 +1169,16 @@ $this->assertEquals(2, count($toArray['pages'])); // tweak options to what we expect sub page 1 to be - $options['label'] = 'foo.bar'; - $options['order'] = null; - $options['id'] = null; - $options['class'] = null; - $options['title'] = null; - $options['target'] = null; - $options['resource'] = null; - $options['active'] = false; - $options['visible'] = true; + $options['label'] = 'foo.bar'; + $options['order'] = null; + $options['id'] = null; + $options['class'] = null; + $options['title'] = null; + $options['target'] = null; + $options['accesskey'] = null; + $options['resource'] = null; + $options['active'] = false; + $options['visible'] = true; unset($options['foo']); unset($options['meaning']);