MINOR: updated and extended Tests

This commit is contained in:
Zauberfisch 2013-04-22 18:17:31 +00:00
parent 034f575003
commit 809e0e547a
9 changed files with 112 additions and 34 deletions

View File

@ -0,0 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head></head>
<body></body>
</html>

View File

@ -0,0 +1,7 @@
<!doctype html>
<!--[if lte IE 8]> <html class='old-ie'> <![endif]-->
<!--[if gt IE 8]> <html class='new-ie'> <![endif]-->
<!--[if !IE]><!--> <html class='no-ie'> <!--<![endif]-->
<head></head>
<body></body>
</html>

View File

@ -0,0 +1,6 @@
<!--[if lte IE 8]> <html class='old-ie'> <![endif]-->
<!--[if gt IE 8]> <html class='new-ie'> <![endif]-->
<!--[if !IE]><!--> <html class='no-ie'> <!--<![endif]-->
<head></head>
<body></body>
</html>

View File

@ -0,0 +1,4 @@
<html>
<head></head>
<body></body>
</html>

View File

@ -1062,43 +1062,98 @@ after')
$origEnv = Config::inst()->get('Director', 'environment_type');
Config::inst()->update('Director', 'environment_type', 'dev');
Config::inst()->update('SSViewer', 'source_file_comments', true);
$view = new SSViewer(array('SSViewerTestCommentsFullSource'));
$data = new ArrayData(array());
$result = $view->process($data);
$expected = '<!doctype html>
<!-- template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsFullSource.ss --><html>
<head></head>
<body></body>
</html><!-- end template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsFullSource.ss -->
';
$this->assertEquals($result, $expected);
$view = new SSViewer(array('SSViewerTestCommentsPartialSource'));
$data = new ArrayData(array());
$result = $view->process($data);
$expected = '<!-- template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsPartialSource.ss -->'
. '<div class=\'typography\'></div><!-- end template ' . FRAMEWORK_PATH
. '/tests/templates/SSViewerTestCommentsPartialSource.ss -->';
$this->assertEquals($result, $expected);
$view = new SSViewer(array('SSViewerTestCommentsWithInclude'));
$data = new ArrayData(array());
$result = $view->process($data);
$expected = '<!-- template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsWithInclude.ss -->'
. '<div class=\'typography\'><!-- include \'SSViewerTestCommentsInclude\' --><!-- template '
. FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsInclude.ss -->Included<!-- end template '
. FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsInclude.ss -->'
. '<!-- end include \'SSViewerTestCommentsInclude\' --></div><!-- end template ' . FRAMEWORK_PATH
. '/tests/templates/SSViewerTestCommentsWithInclude.ss -->';
$this->assertEquals($result, $expected);
$f = FRAMEWORK_PATH . '/tests/templates/SSViewerTestComments';
$templates = array(
array(
'name' => 'SSViewerTestCommentsFullSource',
'expected' => ""
. "<!doctype html>"
. "<!-- template $f/SSViewerTestCommentsFullSource.ss -->"
. "<html>"
. "\t<head></head>"
. "\t<body></body>"
. "</html>"
. "<!-- end template $f/SSViewerTestCommentsFullSource.ss -->",
),
array(
'name' => 'SSViewerTestCommentsFullSourceHTML4Doctype',
'expected' => ""
. "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\t\t\"http://www.w3.org/TR/html4/strict.dtd\">"
. "<!-- template $f/SSViewerTestCommentsFullSourceHTML4Doctype.ss -->"
. "<html>"
. "\t<head></head>"
. "\t<body></body>"
. "</html>"
. "<!-- end template $f/SSViewerTestCommentsFullSourceHTML4Doctype.ss -->",
),
array(
'name' => 'SSViewerTestCommentsFullSourceNoDoctype',
'expected' => ""
. "<html><!-- template $f/SSViewerTestCommentsFullSourceNoDoctype.ss -->"
. "\t<head></head>"
. "\t<body></body>"
. "<!-- end template $f/SSViewerTestCommentsFullSourceNoDoctype.ss --></html>",
),
array(
'name' => 'SSViewerTestCommentsFullSourceIfIE',
'expected' => ""
. "<!doctype html>"
. "<!-- template $f/SSViewerTestCommentsFullSourceIfIE.ss -->"
. "<!--[if lte IE 8]> <html class='old-ie'> <![endif]-->"
. "<!--[if gt IE 8]> <html class='new-ie'> <![endif]-->"
. "<!--[if !IE]><!--> <html class='no-ie'> <!--<![endif]-->"
. "\t<head></head>"
. "\t<body></body>"
. "</html>"
. "<!-- end template $f/SSViewerTestCommentsFullSourceIfIE.ss -->",
),
array(
'name' => 'SSViewerTestCommentsFullSourceIfIENoDoctype',
'expected' => ""
. "<!--[if lte IE 8]> <html class='old-ie'> <![endif]-->"
. "<!--[if gt IE 8]> <html class='new-ie'> <![endif]-->"
. "<!--[if !IE]><!--> <html class='no-ie'>"
. "<!-- template $f/SSViewerTestCommentsFullSourceIfIENoDoctype.ss -->"
. " <!--<![endif]-->"
. "\t<head></head>"
. "\t<body></body>"
. "<!-- end template $f/SSViewerTestCommentsFullSourceIfIENoDoctype.ss --></html>",
),
array(
'name' => 'SSViewerTestCommentsPartialSource',
'expected' =>
"<!-- template $f/SSViewerTestCommentsPartialSource.ss -->"
. "<div class='typography'></div>"
. "<!-- end template $f/SSViewerTestCommentsPartialSource.ss -->",
),
array(
'name' => 'SSViewerTestCommentsWithInclude',
'expected' =>
"<!-- template $f/SSViewerTestCommentsWithInclude.ss -->"
. "<div class='typography'>"
. "<!-- include 'SSViewerTestCommentsInclude' -->"
. "<!-- template $f/SSViewerTestCommentsInclude.ss -->"
. "Included"
. "<!-- end template $f/SSViewerTestCommentsInclude.ss -->"
. "<!-- end include 'SSViewerTestCommentsInclude' -->"
. "</div>"
. "<!-- end template $f/SSViewerTestCommentsWithInclude.ss -->",
),
);
foreach ($templates as $template) {
$this->_renderWithSourceFileComments($template['name'], $template['expected']);
}
Config::inst()->update('SSViewer', 'source_file_comments', false);
Config::inst()->update('Director', 'environment_type', $origEnv);
}
private function _renderWithSourceFileComments($name, $expected) {
$viewer = new SSViewer(array($name));
$data = new ArrayData(array());
$result = $viewer->process($data);
$expected = str_replace(array("\r", "\n"), '', $expected);
$result = str_replace(array("\r", "\n"), '', $result);
$this->assertEquals($result, $expected);
}
public function testLoopIteratorIterator() {
$list = new PaginatedList(new ArrayList());