Ejemplo n.º 1
0
 /**
  * @group ZF-3350
  * @group ZF-3352
  */
 public function testShouldNotCastToArrayIfObjectIsTraversable()
 {
     $data = array(new IteratorWithToArrayTestContainer(array('message' => 'foo')), new IteratorWithToArrayTestContainer(array('message' => 'bar')), new IteratorWithToArrayTestContainer(array('message' => 'baz')), new IteratorWithToArrayTestContainer(array('message' => 'bat')));
     $o = new IteratorWithToArrayTest($data);
     $view = new View();
     $view->resolver()->addPath($this->basePath . '/application/views/scripts');
     $this->helper->setView($view);
     $this->helper->setObjectKey('obj');
     $result = $this->helper->__invoke('partialLoopObject.phtml', $o);
     foreach ($data as $item) {
         $string = 'This is an iteration: ' . $item->message;
         $this->assertContains($string, $result, $result);
     }
 }
Ejemplo n.º 2
0
 public function testShouldNotConvertToArrayRecursivelyIfModelIsTraversable()
 {
     $rIterator = new RecursiveIteratorTest();
     for ($i = 0; $i < 5; ++$i) {
         $data = array('message' => 'foo' . $i);
         $rIterator->addItem(new IteratorTest($data));
     }
     $view = new View();
     $view->resolver()->addPath($this->basePath . '/application/views/scripts');
     $this->helper->setView($view);
     $this->helper->setObjectKey('obj');
     $result = $this->helper->__invoke('partialLoopShouldNotConvertToArrayRecursively.phtml', $rIterator);
     foreach ($rIterator as $item) {
         foreach ($item as $key => $value) {
             $this->assertContains('This is an iteration: ' . $value, $result, var_export($value, 1));
         }
     }
 }