mirror of
https://github.com/yiisoft/yii.git
synced 2026-02-20 01:21:22 +01:00
Add option to omit [CDATA wrapping from contents of <script> and <style> for HTML 5 applications.
This commit is contained in:
@@ -267,6 +267,30 @@ class CHtmlTest extends CTestCase
|
||||
$this->assertEquals($assertion, CHtml::linkTag($relation, $type, $href, $media, $options));
|
||||
}
|
||||
|
||||
public static function providerCssWithoutCdata()
|
||||
{
|
||||
return array(
|
||||
array('h1{font-size:20px;line-height:26px;}', '',
|
||||
"<style type=\"text/css\">\nh1{font-size:20px;line-height:26px;}\n</style>"),
|
||||
array('h2{font-size:16px;line-height:22px;}', 'screen',
|
||||
"<style type=\"text/css\" media=\"screen\">\nh2{font-size:16px;line-height:22px;}\n</style>"),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCssWithoutCdata
|
||||
* @backupStaticAttributes enabled
|
||||
*
|
||||
* @param string $text
|
||||
* @param string $media
|
||||
* @param string $assertion
|
||||
*/
|
||||
public function testCssWithoutCdata($text, $media, $assertion)
|
||||
{
|
||||
CHtml::$cdataScriptAndStyleContents=false;
|
||||
$this->assertEquals($assertion, CHtml::css($text, $media));
|
||||
}
|
||||
|
||||
public static function providerCss()
|
||||
{
|
||||
return array(
|
||||
@@ -329,6 +353,28 @@ class CHtmlTest extends CTestCase
|
||||
$this->assertEquals($assertion, CHtml::script($text));
|
||||
}
|
||||
|
||||
public static function providerScriptWithoutCdata()
|
||||
{
|
||||
return array(
|
||||
array('var a = 10;', "<script type=\"text/javascript\">\nvar a = 10;\n</script>"),
|
||||
array("\t(function() { var x = 100; })();\n\tvar y = 200;",
|
||||
"<script type=\"text/javascript\">\n\t(function() { var x = 100; })();\n\tvar y = 200;\n</script>"),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerScriptWithoutCdata
|
||||
* @backupStaticAttributes enabled
|
||||
*
|
||||
* @param string $text
|
||||
* @param string $assertion
|
||||
*/
|
||||
public function testScriptWithoutCdata($text, $assertion)
|
||||
{
|
||||
CHtml::$cdataScriptAndStyleContents=false;
|
||||
$this->assertEquals($assertion, CHtml::script($text));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerScript
|
||||
* @backupStaticAttributes enabled
|
||||
|
||||
Reference in New Issue
Block a user