mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX: Fixing tests
ENHANCEMENT: Add <%-- --%> comments git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@66946 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
3d5600c597
commit
c7a4afee52
@ -373,6 +373,7 @@ class SSViewer extends Object {
|
|||||||
|
|
||||||
// $val, $val.property, $val(param), etc.
|
// $val, $val.property, $val(param), etc.
|
||||||
$replacements = array(
|
$replacements = array(
|
||||||
|
'/<%--.*--%>/U' => '',
|
||||||
'/\$Iteration/' => '<?= {dlr}key ?>',
|
'/\$Iteration/' => '<?= {dlr}key ?>',
|
||||||
'/{\\$([A-Za-z_][A-Za-z0-9_]*)\\(([^),]+), *([^),]+)\\)\\.([A-Za-z0-9_]+)\\.([A-Za-z0-9_]+)}/' => '<?= {dlr}item->obj("\\1",array("\\2","\\3"),true)->obj("\\4",null,true)->XML_val("\\5",null,true) ?>',
|
'/{\\$([A-Za-z_][A-Za-z0-9_]*)\\(([^),]+), *([^),]+)\\)\\.([A-Za-z0-9_]+)\\.([A-Za-z0-9_]+)}/' => '<?= {dlr}item->obj("\\1",array("\\2","\\3"),true)->obj("\\4",null,true)->XML_val("\\5",null,true) ?>',
|
||||||
'/{\\$([A-Za-z_][A-Za-z0-9_]*)\\(([^),]+), *([^),]+)\\)\\.([A-Za-z0-9_]+)}/' => '<?= {dlr}item->obj("\\1",array("\\2","\\3"),true)->XML_val("\\4",null,true) ?>',
|
'/{\\$([A-Za-z_][A-Za-z0-9_]*)\\(([^),]+), *([^),]+)\\)\\.([A-Za-z0-9_]+)}/' => '<?= {dlr}item->obj("\\1",array("\\2","\\3"),true)->XML_val("\\4",null,true) ?>',
|
||||||
|
@ -96,9 +96,7 @@ class ComponentSet extends DataObjectSet {
|
|||||||
|
|
||||||
$item = DataObject::get_by_id($this->childClass, $item);
|
$item = DataObject::get_by_id($this->childClass, $item);
|
||||||
|
|
||||||
if(!isset($item)) {
|
if(!$item) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we've already got a database object, then update the database
|
// If we've already got a database object, then update the database
|
||||||
|
@ -6,24 +6,24 @@ class ControllerTest extends SapphireTest {
|
|||||||
function testDefaultAction() {
|
function testDefaultAction() {
|
||||||
/* For a controller with a template, the default action will simple run that template. */
|
/* For a controller with a template, the default action will simple run that template. */
|
||||||
$response = Director::test("ControllerTest_Controller/");
|
$response = Director::test("ControllerTest_Controller/");
|
||||||
$this->assertEquals("This is the main template. Content is 'default content'.", $response->getBody());
|
$this->assertRegExp("/This is the main template. Content is 'default content'/", $response->getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testMethodActions() {
|
function testMethodActions() {
|
||||||
/* The Action can refer to a method that is called on the object. If a method returns an array, then it will be
|
/* The Action can refer to a method that is called on the object. If a method returns an array, then it will be
|
||||||
used to customise the template data */
|
used to customise the template data */
|
||||||
$response = Director::test("ControllerTest_Controller/methodaction");
|
$response = Director::test("ControllerTest_Controller/methodaction");
|
||||||
$this->assertEquals("This is the main template. Content is 'methodaction content'.", $response->getBody());
|
$this->assertRegExp("/This is the main template. Content is 'methodaction content'./", $response->getBody());
|
||||||
|
|
||||||
/* If the method just returns a string, then that will be used as the response */
|
/* If the method just returns a string, then that will be used as the response */
|
||||||
$response = Director::test("ControllerTest_Controller/stringaction");
|
$response = Director::test("ControllerTest_Controller/stringaction");
|
||||||
$this->assertEquals("stringaction was called.", $response->getBody());
|
$this->assertRegExp("/stringaction was called./", $response->getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testTemplateActions() {
|
function testTemplateActions() {
|
||||||
/* If there is no method, it can be used to point to an alternative template. */
|
/* If there is no method, it can be used to point to an alternative template. */
|
||||||
$response = Director::test("ControllerTest_Controller/templateaction");
|
$response = Director::test("ControllerTest_Controller/templateaction");
|
||||||
$this->assertEquals("This is the template for templateaction. Content is 'default content'.", $response->getBody());
|
$this->assertRegExp("/This is the template for templateaction. Content is 'default content'./", $response->getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testAllowedActions() {
|
function testAllowedActions() {
|
||||||
|
@ -10,7 +10,7 @@ class SSViewerTest extends SapphireTest {
|
|||||||
));
|
));
|
||||||
|
|
||||||
$result = $data->renderWith("SSViewerTestPartialTemplate");
|
$result = $data->renderWith("SSViewerTestPartialTemplate");
|
||||||
$this->assertEquals('Test partial template: var value', $result);
|
$this->assertEquals('Test partial template: var value', trim(preg_replace("/<!--.*-->/U",'',$result)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testRequirements() {
|
function testRequirements() {
|
||||||
@ -33,4 +33,14 @@ SS
|
|||||||
$template = $viewer->process($data);
|
$template = $viewer->process($data);
|
||||||
$this->assertFalse((bool)trim($template), "Should be no content in this return.");
|
$this->assertFalse((bool)trim($template), "Should be no content in this return.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
function testComments() {
|
||||||
|
$viewer = SSViewer::fromString(<<<SS
|
||||||
|
This is my template<%-- this is a comment --%>This is some content<%-- this is another comment --%>This is the final content
|
||||||
|
SS
|
||||||
|
);
|
||||||
|
$output = $viewer->process(new ArrayData(array()));
|
||||||
|
|
||||||
|
$this->assertEquals("This is my templateThis is some contentThis is the final content", preg_replace("/\n?<!--.*-->\n?/U",'',$output));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user