From 4311966880d5c3cfa0b136b2d4ecbdbdbf121c4d Mon Sep 17 00:00:00 2001 From: Luke Hudson Date: Tue, 10 Aug 2010 23:56:24 +0000 Subject: [PATCH] Revert "MINOR: Applied patch from walec51 for <% control %> on empty set (#5579) Also added unit tests by ischommer" This was not supposed to be pushed out yet. This reverts commit 9c2aafa414948314236674e31fd756797d695139. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@109177 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/SSViewer.php | 12 ++++---- tests/SSViewerTest.php | 65 ------------------------------------------ 2 files changed, 6 insertions(+), 71 deletions(-) diff --git a/core/SSViewer.php b/core/SSViewer.php index 69ba7d819..d29c8a576 100755 --- a/core/SSViewer.php +++ b/core/SSViewer.php @@ -513,17 +513,17 @@ class SSViewer { $content = ereg_replace('', '<' . '% end_control %' . '>', $content); // < % control Foo % > - $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+) +%' . '>', 'obj("\\1", null, false)) foreach($loop as $key => $item) { ?>', $content); + $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+) +%' . '>', 'obj("\\1")) foreach($loop as $key => $item) { ?>', $content); // < % control Foo.Bar % > - $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\.([A-Za-z0-9_]+) +%' . '>', 'obj("\\1", null, false)) && ($loop = $loop->obj("\\2"))) foreach($loop as $key => $item) { ?>', $content); + $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\.([A-Za-z0-9_]+) +%' . '>', 'obj("\\1")) && ($loop = $loop->obj("\\2"))) foreach($loop as $key => $item) { ?>', $content); // < % control Foo.Bar(Baz) % > - $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\.([A-Za-z0-9_]+)\\(([^),]+)\\) +%' . '>', 'obj("\\1", null, false)) && ($loop = $loop->obj("\\2", array("\\3")))) foreach($loop as $key => $item) { ?>', $content); + $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\.([A-Za-z0-9_]+)\\(([^),]+)\\) +%' . '>', 'obj("\\1")) && ($loop = $loop->obj("\\2", array("\\3")))) foreach($loop as $key => $item) { ?>', $content); // < % control Foo(Bar) % > - $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\(([^),]+)\\) +%' . '>', 'obj("\\1", array("\\2"), false)) foreach($loop as $key => $item) { ?>', $content); + $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\(([^),]+)\\) +%' . '>', 'obj("\\1", array("\\2"))) foreach($loop as $key => $item) { ?>', $content); // < % control Foo(Bar, Baz) % > - $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\(([^),]+), *([^),]+)\\) +%' . '>', 'obj("\\1", array("\\2","\\3"), false)) foreach($loop as $key => $item) { ?>', $content); + $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\(([^),]+), *([^),]+)\\) +%' . '>', 'obj("\\1", array("\\2","\\3"))) foreach($loop as $key => $item) { ?>', $content); // < % control Foo(Bar, Baz, Buz) % > - $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\(([^),]+), *([^),]+), *([^),]+)\\) +%' . '>', 'obj("\\1", array("\\2", "\\3", "\\4"), false)) foreach($loop as $key => $item) { ?>', $content); + $content = ereg_replace('<' . '% +control +([A-Za-z0-9_]+)\\(([^),]+), *([^),]+), *([^),]+)\\) +%' . '>', 'obj("\\1", array("\\2", "\\3", "\\4"))) foreach($loop as $key => $item) { ?>', $content); $content = ereg_replace('<' . '% +end_control +%' . '>', '', $content); $content = ereg_replace('<' . '% +debug +%' . '>', '', $content); $content = ereg_replace('<' . '% +debug +([A-Za-z0-9_]+) +%' . '>', 'cachedCall("\\1")) ?>', $content); diff --git a/tests/SSViewerTest.php b/tests/SSViewerTest.php index 69affccf6..c0811c4fb 100644 --- a/tests/SSViewerTest.php +++ b/tests/SSViewerTest.php @@ -2,67 +2,6 @@ class SSViewerTest extends SapphireTest { - function testControlBlockDataObjectSet() { - $viewer = SSViewer::fromString(<< - Test: \$TestValue - <% end_control %> -SS -); - $data = new ArrayData(array( - 'TestSet' => new DataObjectSet(array( - new ArrayData(array( - 'TestValue' => '1' - )), - new ArrayData(array( - 'TestValue' => '2' - )), - )) - )); - $out = $viewer->process($data); - $this->assertEquals('Test:1Test:2', str_replace(array(' ', "\t", PHP_EOL), '', $out)); - } - - function testControlBlockNullValueDoesntLoop() { - $viewer = SSViewer::fromString(<< - notdisplayed - <% end_control %> -SS -); - $data = new ArrayData(array( - 'NullValue' => null - )); - $out = $viewer->process($data); - $this->assertNotContains('notdisplayed', str_replace(array(' ', "\t", PHP_EOL), '', $out)); - } - - function testControlBlockFalseValueDoesntLoop() { - $viewer = SSViewer::fromString(<< - notdisplayed - <% end_control %> -SS -); - $data = new ArrayData(array( - 'FalseValue' => null - )); - $out = $viewer->process($data); - $this->assertNotContains('notdisplayed', str_replace(array(' ', "\t", PHP_EOL), '', $out)); - } - - function testControlBlockMethodReturningNullDoesntLoop() { - $viewer = SSViewer::fromString(<< - notdisplayed - <% end_control %> -SS -); - $data = new SSViewerTest_ViewableData(); - $out = $viewer->process($data); - $this->assertNotContains('notdisplayed', str_replace(array(' ', "\t", PHP_EOL), '', $out)); - } - /** * Tests for {@link SSViewer::current_theme()} for different behaviour * of user defined themes via {@link SiteConfig} and default theme @@ -207,8 +146,4 @@ class SSViewerTest_ViewableData extends ViewableData implements TestOnly { function methodWithTwoArguments($arg1, $arg2) { return "arg1:{$arg1},arg2:{$arg2}"; } - - function methodNull() { - return null; - } } \ No newline at end of file