示例#1
0
 function assign($spec, $value = null)
 {
     if (is_array($spec)) {
         $orig = $this->_container->getArrayCopy();
         $merged = array_merge($orig, $spec);
         $this->_container->exchangeArray($merged);
         return $this;
     }
     if (is_string($spec)) {
         $this->_container[$spec] = $value;
         return $this;
     }
     throw new Exception('Invalid values passed to assign()');
 }
 /**
  * @group ZF-12044
  */
 public function testContainerWithoutItemsShouldAlwaysReturnEmptyString()
 {
     $this->assertEquals('', (string) $this->container);
     $this->container->setIndent(4);
     $this->assertEquals('', (string) $this->container);
     $this->container->setPrefix('<ul><li>');
     $this->assertEquals('', (string) $this->container);
     $this->container->setSeparator('</li><li>');
     $this->assertEquals('', (string) $this->container);
     $this->container->setPrefix('</li></ul>');
     $this->assertEquals('', (string) $this->container);
 }
示例#3
0
 public function testIndentationIsHonored()
 {
     $this->container->setIndent(4)->setPrefix("<ul>\n    <li>")->setSeparator("</li>\n    <li>")->setPostfix("</li>\n</ul>");
     $this->container->append('foo');
     $this->container->append('bar');
     $this->container->append('baz');
     $string = $this->container->toString();
     $lis = substr_count($string, "\n        <li>");
     $this->assertEquals(3, $lis);
     $this->assertTrue(strstr($string, "    <ul>\n") ? true : false, $string);
     $this->assertTrue(strstr($string, "\n    </ul>") ? true : false);
 }
 /**
  * Assign one or more layout variables
  * 
  * @param  mixed $spec Assoc array or string key; if assoc array, sets each
  * key as a layout variable
  * @param  mixed $value Value if $spec is a key
  * @return Zend_Layout
  * @throws Zend_Layout_Exception if non-array/string value passed to $spec
  */
 public function assign($spec, $value = null)
 {
     if (is_array($spec)) {
         $orig = $this->_container->getArrayCopy();
         $merged = array_merge($orig, $spec);
         $this->_container->exchangeArray($merged);
         return $this;
     }
     if (is_string($spec)) {
         $this->_container[$spec] = $value;
         return $this;
     }
     require_once 'Zend/Layout/Exception.php';
     throw new Zend_Layout_Exception('Invalid values passed to assign()');
 }