CClientScriptTest has been advanced to expose issue #2770

This commit is contained in:
Klimov Paul
2013-08-14 20:27:29 +03:00
parent 58be961fd4
commit 7111b38399

View File

@@ -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'));
}
}