Files
yii2/tests/unit/framework/base/BehaviorTest.php
Qiang Xue d991f42cbd Use namespace in unit tests.
Fixed BehaviorTest.php
2011-12-03 15:04:17 -05:00

33 lines
738 B
PHP

<?php
namespace yiiunit\framework\base;
class BarClass extends \yii\base\Component
{
}
class BarBehavior extends \yii\base\Behavior
{
public $behaviorProperty = 'behavior property';
public function behaviorMethod()
{
return 'behavior method';
}
}
class BehaviorTest extends \yiiunit\TestCase
{
public function testAttachAndAccessing()
{
$bar = BarClass::create();
$behavior = new BarBehavior();
$bar->attachBehavior('bar', $behavior);
$this->assertEquals('behavior property', $bar->behaviorProperty);
$this->assertEquals('behavior method', $bar->behaviorMethod());
$this->assertEquals('behavior property', $bar->bar->behaviorProperty);
$this->assertEquals('behavior method', $bar->bar->behaviorMethod());
}
}