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.
32 lines
718 B
32 lines
718 B
<?php |
|
class BarClass extends \yii\base\Component |
|
{ |
|
|
|
} |
|
|
|
class BarBehavior extends \yii\base\Behavior |
|
{ |
|
public $behaviorProperty = 'behavior property'; |
|
|
|
public function behaviorMethod() |
|
{ |
|
return 'behavior method'; |
|
} |
|
} |
|
|
|
/** |
|
* BehaviorTest |
|
*/ |
|
class BehaviorTest extends \yii\test\TestCase |
|
{ |
|
public function testAttachAndAccessing() |
|
{ |
|
$bar = BarClass::create(); |
|
$behavior = new BarBehavior(); |
|
$bar->attachBehavior('bar', $bar); |
|
$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); |
|
} |
|
}
|
|
|