Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Helper/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function findHelper($proxy, $strict = true)

$helper = $plugins->get($proxy);
$container = $this->getContainer();
$hash = spl_object_hash($container);
$hash = spl_object_hash($container) . spl_object_hash($helper);

if (!isset($this->injected[$hash])) {
$helper->setContainer();
Expand Down
16 changes: 8 additions & 8 deletions src/Renderer/PhpRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@
* Convenience methods for build in helpers (@see __call):
*
* @method \Zend\View\Helper\BasePath basePath($file = null)
* @method \Zend\View\Helper\Cycle cycle(array $data = array(), $name = self::DEFAULT_NAME)
* @method \Zend\View\Helper\Cycle cycle(array $data = array(), $name = \Zend\View\Helper\Cycle::DEFAULT_NAME)
* @method \Zend\View\Helper\DeclareVars declareVars()
* @method \Zend\View\Helper\Doctype doctype($doctype = null)
* @method mixed escapeCss($value, $recurse = self::RECURSE_NONE)
* @method mixed escapeHtml($value, $recurse = self::RECURSE_NONE)
* @method mixed escapeHtmlAttr($value, $recurse = self::RECURSE_NONE)
* @method mixed escapeJs($value, $recurse = self::RECURSE_NONE)
* @method mixed escapeUrl($value, $recurse = self::RECURSE_NONE)
* @method mixed escapeCss($value, $recurse = \Zend\View\Helper\Escaper\AbstractHelper::RECURSE_NONE)
* @method mixed escapeHtml($value, $recurse = \Zend\View\Helper\Escaper\AbstractHelper::RECURSE_NONE)
* @method mixed escapeHtmlAttr($value, $recurse = \Zend\View\Helper\Escaper\AbstractHelper::RECURSE_NONE)
* @method mixed escapeJs($value, $recurse = \Zend\View\Helper\Escaper\AbstractHelper::RECURSE_NONE)
* @method mixed escapeUrl($value, $recurse = \Zend\View\Helper\Escaper\AbstractHelper::RECURSE_NONE)
* @method \Zend\View\Helper\FlashMessenger flashMessenger($namespace = null)
* @method \Zend\View\Helper\Gravatar gravatar($email = "", $options = array(), $attribs = array())
* @method \Zend\View\Helper\HeadLink headLink(array $attributes = null, $placement = \Zend\View\Helper\Placeholder\Container\AbstractContainer::APPEND)
* @method \Zend\View\Helper\HeadMeta headMeta($content = null, $keyValue = null, $keyType = 'name', $modifiers = array(), $placement = \Zend\View\Helper\Placeholder\Container\AbstractContainer::APPEND)
* @method \Zend\View\Helper\HeadScript headScript($mode = HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript')
* @method \Zend\View\Helper\HeadScript headScript($mode = \Zend\View\Helper\HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript')
* @method \Zend\View\Helper\HeadStyle headStyle($content = null, $placement = 'APPEND', $attributes = array())
* @method \Zend\View\Helper\HeadTitle headTitle($title = null, $setType = null)
* @method string htmlFlash($data, array $attribs = array(), array $params = array(), $content = null)
Expand All @@ -52,7 +52,7 @@
* @method string htmlPage($data, array $attribs = array(), array $params = array(), $content = null)
* @method string htmlQuicktime($data, array $attribs = array(), array $params = array(), $content = null)
* @method mixed|null identity()
* @method \Zend\View\Helper\InlineScript inlineScript($mode = HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript')
* @method \Zend\View\Helper\InlineScript inlineScript($mode = \Zend\View\Helper\HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript')
* @method string|void json($data, array $jsonOptions = array())
* @method \Zend\View\Helper\Layout layout($template = null)
* @method \Zend\View\Helper\Navigation navigation($container = null)
Expand Down
12 changes: 12 additions & 0 deletions src/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class Stream

/**
* Opens the script file and converts markup.
*
* @return bool
*/
public function stream_open($path, $mode, $options, &$opened_path)
{
Expand Down Expand Up @@ -92,6 +94,8 @@ public function url_stat()

/**
* Reads from the stream.
*
* @return string|false
*/
public function stream_read($count)
{
Expand All @@ -103,6 +107,8 @@ public function stream_read($count)

/**
* Tells the current position in the stream.
*
* @return int
*/
public function stream_tell()
{
Expand All @@ -112,6 +118,8 @@ public function stream_tell()

/**
* Tells if we are at the end of the stream.
*
* @return bool
*/
public function stream_eof()
{
Expand All @@ -121,6 +129,8 @@ public function stream_eof()

/**
* Stream statistics.
*
* @return array
*/
public function stream_stat()
{
Expand All @@ -130,6 +140,8 @@ public function stream_stat()

/**
* Seek to a specific point in the stream.
*
* @return bool
*/
public function stream_seek($offset, $whence)
{
Expand Down
83 changes: 83 additions & 0 deletions test/Helper/Navigation/NavigationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,89 @@ public function testMultipleNavigations()
$this->assertEquals($expected, $actual);
}

/**
* @group #3859
*/
public function testMultipleNavigationsWithDifferentHelpersAndDifferentContainers()
{
$sm = new ServiceManager();
$nav1 = new Container();
$nav2 = new Container();
$sm->setService('nav1', $nav1);
$sm->setService('nav2', $nav2);

$helper = new Navigation();
$helper->setServiceLocator($sm);

$menu = $helper('nav1')->menu();
$actual = spl_object_hash($nav1);
$expected = spl_object_hash($menu->getContainer());
$this->assertEquals($expected, $actual);

$breadcrumbs = $helper('nav2')->breadcrumbs();
$actual = spl_object_hash($nav2);
$expected = spl_object_hash($breadcrumbs->getContainer());
$this->assertEquals($expected, $actual);

$links = $helper()->links();
$expected = spl_object_hash($links->getContainer());
$this->assertEquals($expected, $actual);
}

/**
* @group #3859
*/
public function testMultipleNavigationsWithDifferentHelpersAndSameContainer()
{
$sm = new ServiceManager();
$nav1 = new Container();
$sm->setService('nav1', $nav1);

$helper = new Navigation();
$helper->setServiceLocator($sm);

// Tests
$menu = $helper('nav1')->menu();
$actual = spl_object_hash($nav1);
$expected = spl_object_hash($menu->getContainer());
$this->assertEquals($expected, $actual);

$breadcrumbs = $helper('nav1')->breadcrumbs();
$expected = spl_object_hash($breadcrumbs->getContainer());
$this->assertEquals($expected, $actual);

$links = $helper()->links();
$expected = spl_object_hash($links->getContainer());
$this->assertEquals($expected, $actual);
}

/**
* @group #3859
*/
public function testMultipleNavigationsWithSameHelperAndSameContainer()
{
$sm = new ServiceManager();
$nav1 = new Container();
$sm->setService('nav1', $nav1);

$helper = new Navigation();
$helper->setServiceLocator($sm);

// Test
$menu = $helper('nav1')->menu();
$actual = spl_object_hash($nav1);
$expected = spl_object_hash($menu->getContainer());
$this->assertEquals($expected, $actual);

$menu = $helper('nav1')->menu();
$expected = spl_object_hash($menu->getContainer());
$this->assertEquals($expected, $actual);

$menu = $helper()->menu();
$expected = spl_object_hash($menu->getContainer());
$this->assertEquals($expected, $actual);
}

/**
* Returns the contens of the expected $file, normalizes newlines
* @param string $file
Expand Down

0 comments on commit 85e6bbd

Please sign in to comment.