mirror of
https://github.com/yiisoft/yii.git
synced 2026-03-06 08:14:21 +01:00
CClientScriptTest has been advanced to expose issue #2770
This commit is contained in:
@@ -416,4 +416,64 @@ class CClientScriptTest extends CTestCase
|
||||
$returnedClientScript->render($output);
|
||||
$this->assertContains($assertion, $output);
|
||||
}
|
||||
|
||||
public function providerRenderScriptsBatch()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
array(
|
||||
'id' => 'js_id_1',
|
||||
'script' => "function() {alert('script1')}",
|
||||
'position' => CClientScript::POS_HEAD,
|
||||
'htmlOptions' => array(),
|
||||
),
|
||||
array(
|
||||
'id' => 'js_id_2',
|
||||
'script' => "function() {alert('script2')}",
|
||||
'position' => CClientScript::POS_HEAD,
|
||||
'htmlOptions' => array(),
|
||||
),
|
||||
),
|
||||
1
|
||||
),
|
||||
array(
|
||||
array(
|
||||
array(
|
||||
'id' => 'js_id_1',
|
||||
'script' => "function() {alert('script1')}",
|
||||
'position' => CClientScript::POS_HEAD,
|
||||
'htmlOptions' => array(),
|
||||
),
|
||||
array(
|
||||
'id' => 'js_id_2',
|
||||
'script' => "function() {alert('script2')}",
|
||||
'position' => CClientScript::POS_HEAD,
|
||||
'htmlOptions' => array(
|
||||
'defer' => true
|
||||
),
|
||||
),
|
||||
),
|
||||
2
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testRenderScripts
|
||||
*
|
||||
* @dataProvider providerRenderScriptsBatch
|
||||
*
|
||||
* @param array $scriptBatch
|
||||
* @param integer $expectedScriptTagCount
|
||||
*/
|
||||
public function testRenderScriptsBatch(array $scriptBatch, $expectedScriptTagCount)
|
||||
{
|
||||
$this->_clientScript->reset();
|
||||
foreach($scriptBatch as $scriptParams)
|
||||
$this->_clientScript->registerScript($scriptParams['id'], $scriptParams['script'], $scriptParams['position'], $scriptParams['htmlOptions']);
|
||||
$output = '<head></head>';
|
||||
$this->_clientScript->render($output);
|
||||
$this->assertEquals($expectedScriptTagCount, substr_count($output, '<script'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user