Commit 39254a80 by Qiang Xue

added test for "on .." and "as .." for Component.

parent 736d3068
......@@ -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);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment