Browse Source

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

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
39254a806b
  1. 13
      tests/unit/framework/base/ComponentTest.php

13
tests/unit/framework/base/ComponentTest.php

@ -105,9 +105,12 @@ class ComponentTest extends \yiiunit\TestCase
$this->assertEquals(1, $this->component->getEventHandlers('click')->getCount()); $this->assertEquals(1, $this->component->getEventHandlers('click')->getCount());
$this->component->on('click', 'bar'); $this->component->on('click', 'bar');
$this->assertEquals(2, $this->component->getEventHandlers('click')->getCount()); $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->component->getEventHandlers('click')->add('test');
$this->assertEquals(3, $this->component->getEventHandlers('click')->getCount()); $this->assertEquals(4, $this->component->getEventHandlers('click')->getCount());
} }
public function testOff() public function testOff()
@ -181,6 +184,14 @@ class ComponentTest extends \yiiunit\TestCase
$this->assertFalse($component->hasProperty('p')); $this->assertFalse($component->hasProperty('p'));
$this->setExpectedException('yii\base\BadMethodException'); $this->setExpectedException('yii\base\BadMethodException');
$component->test(); $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);
} }
} }

Loading…
Cancel
Save