/** * @group ZF-5174 */ public function testPartialLoopPartialCounterResets() { $data = array( array('message' => 'foo'), array('message' => 'bar'), array('message' => 'baz'), array('message' => 'bat') ); $view = new View(); $view->resolver()->addPath($this->basePath . '/application/views/scripts'); $this->helper->setView($view); $result = $this->helper->__invoke('partialLoopCouter.phtml', $data); foreach ($data as $key=>$item) { $string = 'This is an iteration: ' . $item['message'] . ', pointer at ' . ($key+1); $this->assertContains($string, $result); } $result = $this->helper->__invoke('partialLoopCouter.phtml', $data); foreach ($data as $key=>$item) { $string = 'This is an iteration: ' . $item['message'] . ', pointer at ' . ($key+1); $this->assertContains($string, $result); } }
/** * @see ZF-7157 */ public function testPartialLoopSetsTotalCount() { $data = array(array('message' => 'foo'), array('message' => 'bar'), array('message' => 'baz'), array('message' => 'bat')); $view = new Zend_View(array('scriptPath' => $this->basePath . '/default/views/scripts')); $this->helper->setView($view); $result = $this->helper->partialLoop('partialLoopCouter.phtml', $data); foreach ($data as $key => $item) { $string = 'Total count: ' . count($data); $this->assertContains($string, $result); } }
/** * @see ZF-3083 */ public function testEmptyArrayPassedToPartialLoopShouldNotThrowException() { $view = new Zend_View(array('scriptPath' => $this->basePath . '/default/views/scripts')); $this->helper->setView($view); try { $result = $this->helper->partialLoop('partialLoop.phtml', array()); } catch (Exception $e) { $this->fail('Empty array should not cause partialLoop to throw exception'); } try { $result = $this->helper->partialLoop('partialLoop.phtml', null, array()); } catch (Exception $e) { $this->fail('Empty array should not cause partialLoop to throw exception'); } }
/** * @see ZF-5174 * @link http://framework.zend.com/issues/browse/ZF-5174 */ public function testPartialLoopPartialCounterResets() { $data = array(array('message' => 'foo'), array('message' => 'bar'), array('message' => 'baz'), array('message' => 'bat')); $view = new Zend_View(array('scriptPath' => $this->basePath . '/default/views/scripts')); $this->helper->setView($view); $result = $this->helper->partialLoop('partialLoopCouter.phtml', $data); foreach ($data as $key => $item) { $string = 'This is an iteration: ' . $item['message'] . ', pointer at ' . ($key + 1); $this->assertContains($string, $result); } $result = $this->helper->partialLoop('partialLoopCouter.phtml', $data); foreach ($data as $key => $item) { $string = 'This is an iteration: ' . $item['message'] . ', pointer at ' . ($key + 1); $this->assertContains($string, $result); } }
public function partial($name, $module, $model) { if (!is_array($model)) { $model = $model->toArray(); } if (!empty($this->arrayExtended)) { foreach ($this->arrayExtended as $k => $v) { if (!isset($model[$k])) { // foolproof! $model[$k] = $v; } } } else { // NB! Try to not be lazy bastard and set arrayExtended! $model['view'] = $this->view; #$model['config'] = $this->config; } return parent::partial($name, $module, $model); }
/** * @return void */ public function testPartialLoopFindsModule() { Zend_Controller_Front::getInstance()->addModuleDirectory($this->basePath); $data = array( array('message' => 'foo'), array('message' => 'bar'), array('message' => 'baz'), array('message' => 'bat') ); $view = new Zend_View(array( 'scriptPath' => $this->basePath . '/default/views/scripts' )); $this->helper->setView($view); $result = $this->helper->partialLoop('partialLoop.phtml', 'foo', $data); foreach ($data as $item) { $string = 'This is an iteration in the foo module: ' . $item['message']; $this->assertContains($string, $result); } }
public function testPassingNoArgsReturnsHelperInstance() { $test = $this->helper->partialLoop(); $this->assertSame($this->helper, $test); }