diff --git a/tests/forms/RequirementsTest.php b/tests/forms/RequirementsTest.php index 75d3e8018..604bb06a6 100644 --- a/tests/forms/RequirementsTest.php +++ b/tests/forms/RequirementsTest.php @@ -350,6 +350,55 @@ class RequirementsTest extends SapphireTest { $this->assertContains('', $html); } + public function testForceJsToBottom() { + $backend = new Requirements_Backend(); + $backend->javascript('http://www.mydomain.com/test.js'); + + // Test matching with HTML5
tags as well + $template = '
My header

Body

'; + + // The expected outputs + $JsInHead = "\n
My header

Body

"; + $JsInBody = "
My header

Body

"; + $JsAtEnd = "
My header

Body

"; + + + // Test if the script is before the head tag, not before the body. + // Expected: $JsInHead + $backend->set_write_js_to_body(false); + $backend->set_force_js_to_bottom(false); + $html = $backend->includeInHTML(false, $template); + $this->assertNotEquals($JsInBody, $html); + $this->assertNotEquals($JsAtEnd, $html); + $this->assertEquals($JsInHead, $html); + + // Test if the script is before the first