From 39254a806bb1ca73f1765831be20323b845a2484 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Tue, 15 Jan 2013 19:22:31 -0500 Subject: [PATCH] added test for "on .." and "as .." for Component. --- tests/unit/framework/base/ComponentTest.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/unit/framework/base/ComponentTest.php b/tests/unit/framework/base/ComponentTest.php index 6729af7..2d95778 100644 --- a/tests/unit/framework/base/ComponentTest.php +++ b/tests/unit/framework/base/ComponentTest.php @@ -105,9 +105,12 @@ class ComponentTest extends \yiiunit\TestCase $this->assertEquals(1, $this->component->getEventHandlers('click')->getCount()); $this->component->on('click', 'bar'); $this->assertEquals(2, $this->component->getEventHandlers('click')->getCount()); + $p = 'on click'; + $this->component->$p = 'foo2'; + $this->assertEquals(3, $this->component->getEventHandlers('click')->getCount()); $this->component->getEventHandlers('click')->add('test'); - $this->assertEquals(3, $this->component->getEventHandlers('click')->getCount()); + $this->assertEquals(4, $this->component->getEventHandlers('click')->getCount()); } public function testOff() @@ -181,6 +184,14 @@ class ComponentTest extends \yiiunit\TestCase $this->assertFalse($component->hasProperty('p')); $this->setExpectedException('yii\base\BadMethodException'); $component->test(); + + $p = 'as b'; + $component = new NewComponent; + $component->$p = array('class' => 'NewBehavior'); + $this->assertSame($behavior, $component->getBehavior('a')); + $this->assertTrue($component->hasProperty('p')); + $component->test(); + $this->assertTrue($component->behaviorCalled); } }