Skip to content

Commit

Permalink
Test for issue zendframework#3758
Browse files Browse the repository at this point in the history
  • Loading branch information
larsnystrom committed Jan 2, 2015
1 parent 79864cb commit 55716c0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/ZendTest/View/Helper/PartialLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,33 @@ public function testShouldNotConvertToArrayRecursivelyIfModelIsTraversable()
}
}
}

public function testNestedCallsShouldNotOverrideObjectKey()
{
$data = array();
for ($i = 0; $i < 3; $i++) {
$obj = new \stdClass();
$obj->helper = $this->helper;
$obj->objectKey = "foo" . $i;
$obj->message = "bar";
$obj->data = array(
$obj
);
$data[] = $obj;
}

$view = new View();
$view->resolver()->addPath($this->basePath . '/application/views/scripts');
$this->helper->setView($view);

$this->helper->setObjectKey('obj');
$result = $this->helper->__invoke('partialLoopParentObject.phtml', $data);

foreach ($data as $item) {
$string = 'This is an iteration with objectKey: ' . $item->objectKey;
$this->assertContains($string, $result, $result);
}
}
}

class IteratorTest implements Iterator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php if (empty($this->vars())): ?>
No object model passed
<?php else:
$objKey = current($this->vars())->helper->getObjectKey();
echo 'This is an iteration with objectKey: ' . $objKey;
endif;

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php if (!isset($this->vars()->obj)): ?>
No object model passed
<?php else:
echo $this->obj->message;
$this->obj->helper->setObjectKey($this->vars()->obj->objectKey);
echo $this->obj->helper->__invoke('partialLoopChildObject.phtml', $obj->data);
endif;

0 comments on commit 55716c0

Please sign in to comment.