You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
743 B

13 years ago
<?php
namespace yiiunit\framework\base;
13 years ago
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
13 years ago
{
public function testAttachAndAccessing()
{
13 years ago
$bar = BarClass::newInstance();
13 years ago
$behavior = new BarBehavior();
$bar->attachBehavior('bar', $behavior);
13 years ago
$this->assertEquals('behavior property', $bar->behaviorProperty);
$this->assertEquals('behavior method', $bar->behaviorMethod());
13 years ago
$this->assertEquals('behavior property', $bar->bar->behaviorProperty);
$this->assertEquals('behavior method', $bar->bar->behaviorMethod());
13 years ago
}
}