Skip to content

Commit

Permalink
Update after Partial ViewHelper changes
Browse files Browse the repository at this point in the history
Partial no longer supports old module concept. We should refactor some ViewHelpers around that: partial don't need to be an array.
  • Loading branch information
b-durand committed Nov 11, 2011
1 parent 45f9bb3 commit 1852f68
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions library/Zend/View/Helper/Navigation/Breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,11 @@ public function renderPartial(Container $container = null,
}

$partialHelper = $this->view->plugin('partial');
return $partialHelper($partial[0], $partial[1], $model);
return $partialHelper($partial[0], /*$partial[1], */$model);
}

$partialHelper = $this->view->plugin('partial');
return $partialHelper($partial, null, $model);
return $partialHelper($partial, $model);
}

// Zend\View\Helper\Navigation\Helper:
Expand Down
4 changes: 2 additions & 2 deletions library/Zend/View/Helper/Navigation/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,11 @@ public function renderPartial(Container $container = null,
}

$partialHelper = $this->view->plugin('partial');
return $partialHelper($partial[0], $partial[1], $model);
return $partialHelper($partial[0], /*$partial[1], */$model);
}

$partialHelper = $this->view->plugin('partial');
return $partialHelper($partial, null, $model);
return $partialHelper($partial, $model);
}

// Zend\View\Helper\Navigation\Helper:
Expand Down
2 changes: 1 addition & 1 deletion library/Zend/View/Helper/PaginationControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function __invoke(Paginator\Paginator $paginator = null, $scrollingStyle

if ($partial[1] !== null) {
$partialHelper = $this->view->plugin('partial');
return $partialHelper($partial[0], $partial[1], $pages);
return $partialHelper($partial[0], $pages);
}

$partial = $partial[0];
Expand Down
26 changes: 15 additions & 11 deletions tests/Zend/View/Helper/Navigation/BreadcrumbsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
*/
namespace ZendTest\View\Helper\Navigation;

use Zend\Registry,
Zend\Navigation\Navigation,
Zend\View\Exception;

/**
* Tests Zend_View_Helper_Navigation_Breadcrumbs
*
Expand Down Expand Up @@ -77,16 +81,16 @@ public function testNullOutContainer()
public function testAutoloadContainerFromRegistry()
{
$oldReg = null;
if (\Zend\Registry::isRegistered(self::REGISTRY_KEY)) {
$oldReg = \Zend\Registry::get(self::REGISTRY_KEY);
if (Registry::isRegistered(self::REGISTRY_KEY)) {
$oldReg = Registry::get(self::REGISTRY_KEY);
}
\Zend\Registry::set(self::REGISTRY_KEY, $this->_nav1);
Registry::set(self::REGISTRY_KEY, $this->_nav1);

$this->_helper->setContainer();
$expected = $this->_getExpected('bc/default.html');
$actual = $this->_helper->render();

\Zend\Registry::set(self::REGISTRY_KEY, $oldReg);
Registry::set(self::REGISTRY_KEY, $oldReg);

$this->assertEquals($expected, $actual);
}
Expand Down Expand Up @@ -184,17 +188,17 @@ public function testTranslationUsingZendTranslateAdapter()

public function testTranslationFromTranslatorInRegistry()
{
$oldReg = \Zend\Registry::isRegistered('Zend_Translator')
? \Zend\Registry::get('Zend_Translator')
$oldReg = Registry::isRegistered('Zend_Translator')
? Registry::get('Zend_Translator')
: null;

$translator = $this->_getTranslator();
\Zend\Registry::set('Zend_Translator', $translator);
Registry::set('Zend_Translator', $translator);

$expected = $this->_getExpected('bc/translated.html');
$actual = $this->_helper->render();

\Zend\Registry::set('Zend_Translator', $oldReg);
Registry::set('Zend_Translator', $oldReg);

$this->assertEquals($expected, $actual);
}
Expand Down Expand Up @@ -232,14 +236,14 @@ public function testRenderingPartialShouldFailOnInvalidPartialArray()
try {
$this->_helper->render();
$this->fail(
'$partial was invalid, but no Zend_View_Exception was thrown');
} catch (\Zend\View\Exception $e) {
'$partial was invalid, but no Zend\View\Exception was thrown');
} catch (Exception $e) {
}
}

public function testLastBreadcrumbShouldBeEscaped()
{
$container = new \Zend\Navigation\Navigation(array(
$container = new Navigation(array(
array(
'label' => 'Live & Learn',
'uri' => '#',
Expand Down
2 changes: 1 addition & 1 deletion tests/Zend/View/Helper/PaginationControlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function testAcceptsViewPartialInOtherModule()
* make sure it gets to Zend_View_Helper_Partial and it's recognized
* as a module. */
$this->assertInstanceOf('Zend\View\Exception\RuntimeException', $e);
$this->assertEquals('Cannot render partial; module does not exist', $e->getMessage());
$this->assertContains('Script "partial.phtml" not found in path', $e->getMessage());
}
}

Expand Down

0 comments on commit 1852f68

Please sign in to comment.