Beispiel #1
0
 public function testAttachAndAccessing()
 {
     $bar = new BarClass();
     $behavior = new BarBehavior();
     $bar->attachBehavior('bar', $behavior);
     $this->assertEquals('behavior property', $bar->behaviorProperty);
     $this->assertEquals('behavior method', $bar->behaviorMethod());
     $this->assertEquals('behavior property', $bar->getBehavior('bar')->behaviorProperty);
     $this->assertEquals('behavior method', $bar->getBehavior('bar')->behaviorMethod());
     $behavior = new BarBehavior(['behaviorProperty' => 'reattached']);
     $bar->attachBehavior('bar', $behavior);
     $this->assertEquals('reattached', $bar->behaviorProperty);
 }