diff --git a/src/View/Requirements.php b/src/View/Requirements.php index f95607145..c757f2ba2 100644 --- a/src/View/Requirements.php +++ b/src/View/Requirements.php @@ -142,6 +142,21 @@ class Requirements implements Flushable self::backend()->customScript($script, $uniquenessID); } + /** + * Register the given Javascript code into the list of requirements with optional tag + * attributes. + * + * @param string $script The script content as a string (without enclosing `#s", + $html, + 'customScript is displaying latest write' + ); + + $this->assertDoesNotMatchRegularExpression( + "##s", + $html, + 'customScript is correctly not displaying original write' + ); + + /* customScriptWithAttributes is overwritten by customScript */ + $this->assertMatchesRegularExpression( + "##s", + $html, + 'customScript is displaying latest write and clearing attributes' + ); + + $this->assertDoesNotMatchRegularExpression( + "##s", + $html, + 'customScript is displaying latest write' + ); + + /* customCSS is overwritten */ + $this->assertMatchesRegularExpression( + "##", + $html, + 'customCSS is displaying latest write' + ); + + $this->assertDoesNotMatchRegularExpression( + "##", + $html, + 'customCSS is correctly not displaying original write' + ); + + /* Head Tags is overwritten */ + $this->assertMatchesRegularExpression( + '#Override#', + $html, + 'Head Tag is displaying latest write' + ); + + $this->assertDoesNotMatchRegularExpression( + '#Do Not Display#', + $html, + 'Head Tag is correctly not displaying original write' + ); + } }