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

Commit

Permalink
Merge branch 'hotfix/3991'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Mar 12, 2013
3 parents 5a64780 + e08b166 + 615848f commit 9fccdf3
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 1 deletion.
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
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 9fccdf3

Please sign in to comment.