mirror of
https://github.com/yiisoft/yii.git
synced 2026-03-03 23:04:04 +01:00
36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* CMultiFileUploadTest
|
|
*/
|
|
class CMultiFileUploadTest extends CTestCase
|
|
{
|
|
public function testCallbackEncoding()
|
|
{
|
|
$expected = "'onFileSelect':function() { /* callback */ }";
|
|
|
|
$out=$this->getWidgetScript('js:function() { /* callback */ }');
|
|
$this->assertTrue(mb_strpos($out,$expected, 0, Yii::app()->charset)!==false, "Unexpected JavaScript (js:): ".$out);
|
|
|
|
$out=$this->getWidgetScript('function() { /* callback */ }');
|
|
$this->assertTrue(mb_strpos($out,$expected, 0, Yii::app()->charset)!==false, "Unexpected JavaScript (w/o js:): ".$out);
|
|
|
|
$out=$this->getWidgetScript(new CJavaScriptExpression('function() { /* callback */ }'));
|
|
$this->assertTrue(mb_strpos($out,$expected, 0, Yii::app()->charset)!==false, "Unexpected JavaScript (wrap): ".$out);
|
|
}
|
|
|
|
private function getWidgetScript($callback)
|
|
{
|
|
Yii::app()->clientScript->scripts = array();
|
|
ob_start();
|
|
$widget = new CMultiFileUpload(null);
|
|
$widget->name = 'test';
|
|
$widget->options['onFileSelect'] = $callback;
|
|
$widget->init();
|
|
$widget->run();
|
|
$out = '';
|
|
Yii::app()->clientScript->render($out);
|
|
ob_end_clean();
|
|
return $out;
|
|
}
|
|
}
|