From 809e0e547a1457abfdfcb9ec73c41c4de74035f5 Mon Sep 17 00:00:00 2001 From: Zauberfisch Date: Mon, 22 Apr 2013 18:17:31 +0000 Subject: [PATCH] MINOR: updated and extended Tests --- .../SSViewerTestCommentsFullSource.ss | 0 ...iewerTestCommentsFullSourceHTML4Doctype.ss | 6 + .../SSViewerTestCommentsFullSourceIfIE.ss | 7 + ...ewerTestCommentsFullSourceIfIENoDoctype.ss | 6 + ...SSViewerTestCommentsFullSourceNoDoctype.ss | 4 + .../SSViewerTestCommentsInclude.ss | 0 .../SSViewerTestCommentsPartialSource.ss | 0 .../SSViewerTestCommentsWithInclude.ss | 0 tests/view/SSViewerTest.php | 123 +++++++++++++----- 9 files changed, 112 insertions(+), 34 deletions(-) rename tests/templates/{ => SSViewerTestComments}/SSViewerTestCommentsFullSource.ss (100%) create mode 100644 tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceHTML4Doctype.ss create mode 100644 tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceIfIE.ss create mode 100644 tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceIfIENoDoctype.ss create mode 100644 tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceNoDoctype.ss rename tests/templates/{ => SSViewerTestComments}/SSViewerTestCommentsInclude.ss (100%) rename tests/templates/{ => SSViewerTestComments}/SSViewerTestCommentsPartialSource.ss (100%) rename tests/templates/{ => SSViewerTestComments}/SSViewerTestCommentsWithInclude.ss (100%) diff --git a/tests/templates/SSViewerTestCommentsFullSource.ss b/tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSource.ss similarity index 100% rename from tests/templates/SSViewerTestCommentsFullSource.ss rename to tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSource.ss diff --git a/tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceHTML4Doctype.ss b/tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceHTML4Doctype.ss new file mode 100644 index 000000000..ec38777ce --- /dev/null +++ b/tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceHTML4Doctype.ss @@ -0,0 +1,6 @@ + + + + + diff --git a/tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceIfIE.ss b/tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceIfIE.ss new file mode 100644 index 000000000..676405f4a --- /dev/null +++ b/tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceIfIE.ss @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceIfIENoDoctype.ss b/tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceIfIENoDoctype.ss new file mode 100644 index 000000000..a34df2c3e --- /dev/null +++ b/tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceIfIENoDoctype.ss @@ -0,0 +1,6 @@ + + + + + + diff --git a/tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceNoDoctype.ss b/tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceNoDoctype.ss new file mode 100644 index 000000000..2cb856a7f --- /dev/null +++ b/tests/templates/SSViewerTestComments/SSViewerTestCommentsFullSourceNoDoctype.ss @@ -0,0 +1,4 @@ + + + + diff --git a/tests/templates/SSViewerTestCommentsInclude.ss b/tests/templates/SSViewerTestComments/SSViewerTestCommentsInclude.ss similarity index 100% rename from tests/templates/SSViewerTestCommentsInclude.ss rename to tests/templates/SSViewerTestComments/SSViewerTestCommentsInclude.ss diff --git a/tests/templates/SSViewerTestCommentsPartialSource.ss b/tests/templates/SSViewerTestComments/SSViewerTestCommentsPartialSource.ss similarity index 100% rename from tests/templates/SSViewerTestCommentsPartialSource.ss rename to tests/templates/SSViewerTestComments/SSViewerTestCommentsPartialSource.ss diff --git a/tests/templates/SSViewerTestCommentsWithInclude.ss b/tests/templates/SSViewerTestComments/SSViewerTestCommentsWithInclude.ss similarity index 100% rename from tests/templates/SSViewerTestCommentsWithInclude.ss rename to tests/templates/SSViewerTestComments/SSViewerTestCommentsWithInclude.ss diff --git a/tests/view/SSViewerTest.php b/tests/view/SSViewerTest.php index a82ecee21..92b181b28 100644 --- a/tests/view/SSViewerTest.php +++ b/tests/view/SSViewerTest.php @@ -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 = ' - - - - -'; - $this->assertEquals($result, $expected); - - $view = new SSViewer(array('SSViewerTestCommentsPartialSource')); - $data = new ArrayData(array()); - - $result = $view->process($data); - $expected = '' - . '
'; - $this->assertEquals($result, $expected); - - $view = new SSViewer(array('SSViewerTestCommentsWithInclude')); - $data = new ArrayData(array()); - - $result = $view->process($data); - $expected = '' - . '
Included' - . '
'; - $this->assertEquals($result, $expected); - + $f = FRAMEWORK_PATH . '/tests/templates/SSViewerTestComments'; + $templates = array( + array( + 'name' => 'SSViewerTestCommentsFullSource', + 'expected' => "" + . "" + . "" + . "" + . "\t" + . "\t" + . "" + . "", + ), + array( + 'name' => 'SSViewerTestCommentsFullSourceHTML4Doctype', + 'expected' => "" + . "" + . "" + . "" + . "\t" + . "\t" + . "" + . "", + ), + array( + 'name' => 'SSViewerTestCommentsFullSourceNoDoctype', + 'expected' => "" + . "" + . "\t" + . "\t" + . "", + ), + array( + 'name' => 'SSViewerTestCommentsFullSourceIfIE', + 'expected' => "" + . "" + . "" + . "" + . "" + . " " + . "\t" + . "\t" + . "" + . "", + ), + array( + 'name' => 'SSViewerTestCommentsFullSourceIfIENoDoctype', + 'expected' => "" + . "" + . "" + . " " + . "" + . " " + . "\t" + . "\t" + . "", + ), + array( + 'name' => 'SSViewerTestCommentsPartialSource', + 'expected' => + "" + . "
" + . "", + ), + array( + 'name' => 'SSViewerTestCommentsWithInclude', + 'expected' => + "" + . "
" + . "" + . "" + . "Included" + . "" + . "" + . "
" + . "", + ), + ); + 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());