public function testAsA() { $anothercomponent = new NewComponent(); // ensure the component does not have the FooClassBehavior $this->assertNull($this->component->asa('FooClassBehavior')); $this->assertNull($this->component->asa('FooFooClassBehavior')); $this->assertNull($this->component->asa('BarClassBehavior')); $this->assertNull($this->component->asa('NonExistantClassBehavior')); $this->assertNull($anothercomponent->asa('FooClassBehavior')); $this->assertNull($anothercomponent->asa('FooFooClassBehavior')); $this->assertNull($anothercomponent->asa('BarClassBehavior')); $this->assertNull($anothercomponent->asa('NonExistantClassBehavior')); // add the class behavior $this->component->attachClassBehavior('FooClassBehavior', new FooClassBehavior()); //Check that the component has only the class behavior assigned $this->assertNotNull($this->component->asa('FooClassBehavior')); $this->assertNull($this->component->asa('FooFooClassBehavior')); $this->assertNull($this->component->asa('BarClassBehavior')); $this->assertNull($this->component->asa('NonExistantClassBehavior')); //Check that the component has only the class behavior assigned $this->assertNotNull($anothercomponent->asa('FooClassBehavior')); $this->assertNull($anothercomponent->asa('FooFooClassBehavior')); $this->assertNull($anothercomponent->asa('BarClassBehavior')); $this->assertNull($anothercomponent->asa('NonExistantClassBehavior')); // remove the class behavior $this->component->detachClassBehavior('FooClassBehavior'); // Check the function doesn't have the behavior any more $this->assertNull($this->component->asa('FooClassBehavior')); $this->assertNull($this->component->asa('FooFooClassBehavior')); $this->assertNull($this->component->asa('BarClassBehavior')); $this->assertNull($this->component->asa('NonExistantClassBehavior')); $this->assertNull($anothercomponent->asa('FooClassBehavior')); $this->assertNull($anothercomponent->asa('FooFooClassBehavior')); $this->assertNull($anothercomponent->asa('BarClassBehavior')); $this->assertNull($anothercomponent->asa('NonExistantClassBehavior')); $this->component->attachBehavior('BarBehavior', new BarBehavior()); //Check that the component has only the object behavior assigned $this->assertNull($this->component->asa('FooBehavior')); $this->assertNull($this->component->asa('FooFooBehavior')); $this->assertNotNull($this->component->asa('BarBehavior')); $this->assertNull($this->component->asa('NonExistantBehavior')); //Check that the component has the behavior assigned $this->assertNull($anothercomponent->asa('FooBehavior')); $this->assertNull($anothercomponent->asa('FooFooBehavior')); $this->assertNull($anothercomponent->asa('BarBehavior')); $this->assertNull($anothercomponent->asa('NonExistantBehavior')); $this->component->detachBehavior('BarBehavior'); //Check that the component has no object behaviors assigned $this->assertNull($this->component->asa('FooBehavior')); $this->assertNull($this->component->asa('FooFooBehavior')); $this->assertNull($this->component->asa('BarBehavior')); $this->assertNull($this->component->asa('NonExistantBehavior')); //Check that the component has no behavior assigned $this->assertNull($anothercomponent->asa('FooBehavior')); $this->assertNull($anothercomponent->asa('FooFooBehavior')); $this->assertNull($anothercomponent->asa('BarBehavior')); $this->assertNull($anothercomponent->asa('NonExistantBehavior')); $anothercomponent->unlisten(); }
public function testAsa() { $component = new NewComponent(); $behavior = new NewBehavior(); $component->attachBehavior('a', $behavior); $this->assertSame($behavior, $component->asa('a')); }
public function testAsa() { $behavior = new NewBehavior(); $this->component->attachBehavior('newBehavior', $behavior); $this->assertSame($behavior, $this->component->asa('newBehavior')); }