Exemple #1
0
 /**
  * @return ContainerElement
  */
 public static function getTestNode()
 {
     static $html = null;
     if ($html === null) {
         $html = new ContainerElement("html");
         $html->setAttribute("lang", "ja");
         $html->append(self::createHead());
         $html->append(self::createBody());
     }
     return $html;
 }
Exemple #2
0
 /**
  * 開始タグの出力をテストします.
  * 
  * @covers Peach\Markup\SgmlRenderer::formatStartTag
  * @covers Peach\Markup\SgmlRenderer::formatAttribute
  * @covers Peach\Markup\SgmlRenderer::formatBooleanAttribute
  */
 public function testFormatStartTag()
 {
     $obj = $this->object;
     $e1 = new ContainerElement("testTag");
     $this->assertSame("<testTag>", $obj->formatStartTag($e1));
     $e2 = new ContainerElement("test1");
     $e2->setAttributes(array("name" => "hoge", "value" => "123"));
     $e2->setAttribute("option");
     $this->assertSame('<test1 name="hoge" value="123" option>', $obj->formatStartTag($e2));
     $e3 = new ContainerElement("test2");
     $e3->setAttributes(array("name" => "fuga", "option1" => null, "option2" => null, "value" => 234));
     $this->assertSame('<test2 name="fuga" option1 option2 value="234">', $obj->formatStartTag($e3));
 }
Exemple #3
0
 /**
  * @return ContainerElement
  */
 private function createSampleSelectNode2()
 {
     $select = new ContainerElement("select");
     $grp1 = new ContainerElement("optgroup");
     $grp1->setAttribute("label", "Fruit");
     $select->append($grp1);
     $grp2 = new ContainerElement("optgroup");
     $grp2->setAttribute("label", "Dessert");
     $select->append($grp2);
     $other = new ContainerElement("option");
     $other->setAttribute("value", "8");
     $other->append("Others");
     $select->append($other);
     $opt1 = new ContainerElement("option");
     $opt1->setAttribute("value", "1");
     $opt1->append("Apple");
     $grp1->append($opt1);
     $opt2 = new ContainerElement("option");
     $opt2->setAttribute("value", "2");
     $opt2->append("Orange");
     $grp1->append($opt2);
     $opt3 = new ContainerElement("option");
     $opt3->setAttribute("value", "3");
     $opt3->append("Pear");
     $grp1->append($opt3);
     $opt4 = new ContainerElement("option");
     $opt4->setAttribute("value", "4");
     $opt4->append("Peach");
     $grp1->append($opt4);
     $opt5 = new ContainerElement("option");
     $opt5->setAttribute("value", "5");
     $opt5->append("Chocolate");
     $grp2->append($opt5);
     $opt6 = new ContainerElement("option");
     $opt6->setAttribute("value", "6");
     $opt6->setAttribute("selected");
     $opt6->append("Doughnut");
     $grp2->append($opt6);
     $opt7 = new ContainerElement("option");
     $opt7->setAttribute("value", "7");
     $opt7->append("Ice cream");
     $grp2->append($opt7);
     return $select;
 }
    /**
     * 指定されたコードがインデントされた状態でマークアップされることを確認します.
     * 
     * @covers Peach\Markup\DefaultContext::handleCode
     * @covers Peach\Markup\DefaultContext::indent
     * @covers Peach\Markup\DefaultContext::breakCode
     */
    public function testHandleCode()
    {
        $text = <<<EOS
body {
    color            : #000;
    background-color : #fff;
    width            : 750px;
}
@media(min-width : 1024px) {
    body {
        width : 1000px;
    }
}
EOS;
        $code = new Code($text);
        $style = new ContainerElement("style");
        $style->setAttribute("type", "text/css");
        $style->append($code);
        $head = new ContainerElement("head");
        $head->append($style);
        $expected = implode("\r\n", array('<head>', '    <style type="text/css">', '        body {', '            color            : #000;', '            background-color : #fff;', '            width            : 750px;', '        }', '        @media(min-width : 1024px) {', '            body {', '                width : 1000px;', '            }', '        }', '    </style>', '</head>'));
        $this->object->handle($head);
        $this->assertSame($expected, $this->object->getResult());
    }