/** * false を返すことを確認します. * @covers Peach\Markup\MinimalBreakControl::breaks */ public function testBreaks() { $node = new ContainerElement("span"); $node->append("first text"); $node->append("second test"); $this->assertFalse($this->object->breaks($node)); }
/** * ラップ対象のオブジェクトと同じ結果を返すことを確認します. * @covers Peach\Markup\BreakControlWrapper::breaks */ public function testBreaks() { $obj = $this->object; $e5 = new ContainerElement("span"); $e5->append("some text"); $this->assertFalse($obj->breaks($e5)); $e6 = new ContainerElement("span"); $e6->append("first text"); $e6->append("second test"); $this->assertTrue($obj->breaks($e6)); }
/** * 自分自身を含むノードを append しようとした場合に例外をスローすることを確認します. * * @covers Peach\Markup\NodeList::append * @covers Peach\Markup\NodeList::checkOwner * @expectedException \InvalidArgumentException */ public function testAppendFail() { $a = new ContainerElement("a"); $b = new ContainerElement("b"); $c = new ContainerElement("c"); $nodeList = new NodeList(array($a, $b, $c)); $c->append($nodeList); }
/** * breaks() をテストします. * 以下を確認します. * * - 子ノードを持たない要素の場合は false * - 子要素を一つだけ含み, それが整形済テキストの場合は true * - 子要素を一つだけ含み, それがコンテナ要素の場合, 再帰的にチェックした結果 * - 子要素を一つだけ含み, 上記以外のノードの場合は false * - 子要素が二つ以上の場合は true * * @covers Peach\Markup\DefaultBreakControl::breaks */ public function testBreaks() { $obj = $this->object; $e1 = new ContainerElement("empty"); $this->assertFalse($obj->breaks($e1)); $e2 = new ContainerElement("pre"); $e2->append(new Code("some script")); $this->assertTrue($obj->breaks($e2)); $e3 = new ContainerElement("container"); $e3->append($e1); $this->assertFalse($obj->breaks($e3)); $e4 = new ContainerElement("container"); $e4->append($e2); $this->assertTrue($obj->breaks($e4)); $e5 = new ContainerElement("span"); $e5->append("some text"); $this->assertFalse($obj->breaks($e5)); $e6 = new ContainerElement("span"); $e6->append("first text"); $e6->append("second test"); $this->assertTrue($obj->breaks($e6)); }
/** * @return ContainerElement */ private static function createForm() { $text = new EmptyElement("input"); $text->setAttributes(array("type" => "text", "name" => "param1", "value" => "")); $br = new EmptyElement("br"); $check = new EmptyElement("input"); $check->setAttributes(array("type" => "checkbox", "name" => "flag1", "value" => "1")); $check->setAttribute("checked"); $submit = new EmptyElement("input"); $submit->setAttributes(array("type" => "submit", "name" => "submit", "value" => "Send")); $form = new ContainerElement("form"); $form->setAttributes(array("method" => "post", "action" => "sample.php")); $form->append("Name"); $form->append($text); $form->append($br); $form->append($check); $form->append("Enable something"); $form->append($br); $form->append($submit); return $form; }
/** * @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; }
/** * NodeList に含まれる各子ノードを handle することを確認します. * * @covers Peach\Markup\DefaultContext::handleNodeList * @covers Peach\Markup\DefaultContext::formatChildNodes * @covers Peach\Markup\DefaultContext::breakCode */ public function testHandleNodeList() { $node1 = new EmptyElement("empty"); $node2 = new Text("Sample Text"); $node3 = new ContainerElement("container"); $node3->append("TEST"); $nodeList = new NodeList(); $nodeList->append($node1); $nodeList->append($node2); $nodeList->append($node3); $expected = implode("\r\n", array('<empty />', 'Sample Text', '<container>TEST</container>')); $this->object->handleNodeList($nodeList); $this->assertSame($expected, $this->object->getResult()); }
/** * handleContainerElement() のテストです. * * @covers Peach\Markup\DebugContext::handleContainerElement * @covers Peach\Markup\DebugContext::startNode * @covers Peach\Markup\DebugContext::handleContainer * @covers Peach\Markup\DebugContext::endNode */ public function testHandleContainerElement() { $expected = implode("\r\n", array("ContainerElement(div) {", " Text", "}")) . "\r\n"; $context = $this->object; $container = new ContainerElement("div"); $container->append("This is test"); $this->expectOutputString($expected); $context->handleContainerElement($container); $this->assertSame($expected, $context->getResult()); }