Ejemplo n.º 1
0
 public function testReturnsNullIfNoClassesForMethod()
 {
     // entry conditions
     $mixins = MF_Obj_MixinsManager::getMixinsFor('Test_ObjExt');
     // try and get a method that does not exist
     $this->assertNull($mixins->getClassnamesForMethod('doesNotExist'));
 }
Ejemplo n.º 2
0
 public function testCanExtendAClass()
 {
     // entry conditions
     $this->assertEquals(0, MF_Obj_MixinsManager::$mixinAutoInc);
     $this->assertNull(MF_Obj_MixinsManager::getMixinsFor('Test_ObjExt'));
     // make the changes
     __mf_extend('Test_ObjExt', 'Test_Obj_ExtMixin');
     // retest
     $mixins = MF_Obj_MixinsManager::getMixinsFor('Test_ObjExt');
     $this->assertEquals(1, MF_Obj_MixinsManager::$mixinAutoInc);
     $this->assertTrue($mixins instanceof MF_Obj_MixinsList);
 }
Ejemplo n.º 3
0
 public function updateMixinsCountFromMixins($extensionClass)
 {
     $classHierarchy = MF_Obj_MixinsManager::getBaseclassesForClass($extensionClass);
     foreach ($classHierarchy as $classname) {
         // var_dump($this->name . ": Looking at the mixins count for $classname; current mixins count is " . $this->mixinsCount);
         $mixins = MF_Obj_MixinsManager::getMixinsFor($classname);
         if ($mixins == null) {
             continue;
         }
         $this->mixinsCount += $mixins->getMixinsCount();
         // var_dump($this->name . ": Mixins count now increased to " . $this->mixinsCount);
         // the mixin will include how many mixins its
         // baseclasses have defined ... we need go no further
         break;
     }
 }
Ejemplo n.º 4
0
 protected function findObjsForMethod($methodName)
 {
     // we are specifically looking for all of the objects
     // that provide the same method
     $return = array();
     // check the mixins first
     $mixins = MF_Obj_MixinsManager::getMixinsFor($this->extensibleName);
     if ($mixins !== null) {
         // var_dump($mixins);
         $classes = $mixins->getClassnamesForMethod($methodName);
         if ($classes !== null) {
             foreach ($classes as $class) {
                 $return[] = $this->getMixinObject($class);
             }
         }
     }
     // now, what about our decorators too?
     if (isset($this->decorators['objs'])) {
         foreach ($this->decorators['objs'] as $decorator) {
             if (method_exists($decorator, $methodName)) {
                 $return[] = $decorator;
             }
         }
     }
     return $return;
 }