Hi here!
I’m doing unit test with PHP about an extension, all functions are very simple, but when I try to test the principal function I’ve obtained an error, the function is follows:
public function run()
{
if (is_null($this->body)) {
$this->body = ob_get_contents();
ob_end_clean();
}
else {
ob_end_flush();
}
[color="#800080"]$baseUrl = Yii::app()->getAssetManager()->publish(dirname(__FILE__).DIRECTORY_SEPARATOR.'jquery');[/color]
$cs = Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
$cs->registerScriptFile($baseUrl.'/jquery.message-center.js');
if ($this->useBundledStyleSheet) {
$cs->registerCssFile($baseUrl.'/jquery.message-center.css');
}
$options = $this->makeOptions();
$script =<<<EOP
$().message_center({$options});
EOP;
$cs->registerScript('Yii.'.get_class($this), $script, CClientScript::POS_READY);
$this->closeImage = ($this->closeImage==='') ? $baseUrl.'/images/close.png' : $this->closeImage;
$image = CHtml::tag('img', array('id'=>$this->id.'_close', 'src'=>$this->closeImage, 'alt'=>$this->closeLabel));
$html = CHtml::tag('div', array('id'=>$this->id), $this->body.$image, true);
//echo $html;
return $html;
}
I use the next assertion:
$this->assertTag( $matcher, $objeto->run() );
[size="1"]$objeto = new EMessageCenter;
$matcher = array(
'id'=>$this->id;
'body'=>$this->body;
'x'=>$this->closeLabel, ) ; [/size]
but these throws an error; the error is the next:
PHPUnit 3.5.5 by Sebastian Bergmann.
…PHP Fatal error: Call to a member function getAssetManager() on a non-object in /var/www/testdrive/protected/tests/unit/EMessageCenter.php on line 268
note: the purple line is the line 268.
someone can help me please?