Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/view_doctype' of https://github.com/sasezaki/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanDotPro committed Jun 1, 2012
6 parents d157fcb + f0162d1 + 6f01416 + a2b3753 + 1786961 + 1de08e4 commit 4444c37
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/Helper/Doctype.php
Expand Up @@ -117,8 +117,8 @@ public function __invoke($doctype = null)
case self::XHTML1_STRICT:
case self::XHTML1_TRANSITIONAL:
case self::XHTML1_FRAMESET:
case self::XHTML1_RDFA:
case self::XHTML_BASIC1:
case self::XHTML1_RDFA:
case self::XHTML5:
case self::HTML4_STRICT:
case self::HTML4_LOOSE:
Expand Down
72 changes: 39 additions & 33 deletions test/Helper/DoctypeTest.php
Expand Up @@ -134,9 +134,9 @@ public function testIsXhtmlReturnsFalseForNonXhtmlDoctypes()
$this->assertFalse($doctype->isXhtml());
}

public function testIsHtml5()
public function testIsHtml5()
{
foreach (array(Helper\Doctype::HTML5, Helper\Doctype::XHTML5) as $type) {
foreach (array(Helper\Doctype::HTML5, Helper\Doctype::XHTML5) as $type) {
$doctype = $this->helper->__invoke($type);
$this->assertEquals($type, $doctype->getDoctype());
$this->assertTrue($doctype->isHtml5());
Expand All @@ -152,18 +152,48 @@ public function testIsHtml5()
);


foreach ($types as $type) {
$doctype = $this->helper->__invoke($type);
foreach ($types as $type) {
$doctype = $this->helper->__invoke($type);
$this->assertEquals($type, $doctype->getDoctype());
$this->assertFalse($doctype->isHtml5());
}
}
}
}

public function testIsRdfa()
{
// ensure default registerd Doctype is false
$this->assertFalse($this->helper->isRdfa());

public function testCanRegisterCustomHtml5Doctype() {
$doctype = $this->helper->__invoke('<!DOCTYPE html>');
$this->assertTrue($this->helper->__invoke(Helper\Doctype::XHTML1_RDFA)->isRdfa());

// build-in doctypes
$doctypes = array(
Helper\Doctype::XHTML11,
Helper\Doctype::XHTML1_STRICT,
Helper\Doctype::XHTML1_TRANSITIONAL,
Helper\Doctype::XHTML1_FRAMESET,
Helper\Doctype::XHTML_BASIC1,
Helper\Doctype::XHTML5,
Helper\Doctype::HTML4_STRICT,
Helper\Doctype::HTML4_LOOSE,
Helper\Doctype::HTML4_FRAMESET,
Helper\Doctype::HTML5,
);

foreach ($doctypes as $type) {
$this->assertFalse($this->helper->__invoke($type)->isRdfa());
}

// custom doctype
$doctype = $this->helper->__invoke('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 10.0 Strict//EN" "http://framework.zend.com/foo/DTD/html10-custom.dtd">');
$this->assertFalse($doctype->isRdfa());
}

public function testCanRegisterCustomHtml5Doctype() {
$doctype = $this->helper->__invoke('<!DOCTYPE html>');
$this->assertEquals('CUSTOM', $doctype->getDoctype());
$this->assertTrue($doctype->isHtml5());
}
}

public function testCanRegisterCustomXhtmlDoctype()
{
Expand Down Expand Up @@ -195,29 +225,5 @@ public function testStringificationReturnsDoctypeString()
$registry = \Zend\Registry::get('Zend_View_Helper_Doctype');
$this->assertEquals($registry['doctypes'][Helper\Doctype::XHTML1_STRICT], $string);
}

public function testIsRdfaReturnsTrueForRdfaDoctype()
{
$this->assertFalse($this->helper->isRdfa());

$doctypes = array(
Helper\Doctype::XHTML11,
Helper\Doctype::XHTML1_STRICT,
Helper\Doctype::XHTML1_TRANSITIONAL,
Helper\Doctype::XHTML1_FRAMESET,
Helper\Doctype::XHTML_BASIC1,
Helper\Doctype::XHTML5,
Helper\Doctype::HTML4_STRICT,
Helper\Doctype::HTML4_LOOSE,
Helper\Doctype::HTML4_FRAMESET,
Helper\Doctype::HTML5,
);

foreach ($doctypes as $type) {
$this->assertFalse($this->helper->__invoke($type)->isRdfa());
}

$this->assertTrue($this->helper->__invoke(Helper\Doctype::XHTML1_RDFA)->isRdfa());
}
}

0 comments on commit 4444c37

Please sign in to comment.