Example #1
0
 /**
  * Creates a ready to use trait fixture.
  *
  * @param string $name Optional trait name.
  *
  * @return PHP_Depend_Code_Trait
  * @since 1.0.2
  */
 protected function createTraitFixture($name = null)
 {
     $name = $name ? $name : get_class($this);
     $trait = new PHP_Depend_Code_Trait($name);
     $trait->setCache(new PHP_Depend_Util_Cache_Driver_Memory());
     return $trait;
 }
Example #2
0
 /**
  * This method will persist a trait instance for later reuse.
  *
  * @param string                $traitName   The local trait name.
  * @param string                $packageName The package name
  * @param PHP_Depend_Code_Trait $trait       The context trait.
  *
  * @return void
  * @@since 1.0.0
  */
 protected function storeTrait($traitName, $packageName, PHP_Depend_Code_Trait $trait)
 {
     $traitName = strtolower($traitName);
     if (!isset($this->_traits[$traitName][$packageName])) {
         $this->_traits[$traitName][$packageName] = array();
     }
     $this->_traits[$traitName][$packageName][$trait->getUUID()] = $trait;
     $package = $this->buildPackage($packageName);
     $package->addType($trait);
 }
Example #3
0
 /**
  * testMagicWakeupCallsRegisterTraitOnBuilderContext
  *
  * @return void
  */
 public function testMagicWakeupCallsRegisterTraitOnBuilderContext()
 {
     $context = $this->getMockBuilder(PHP_Depend_Builder_Context::CLAZZ)->disableOriginalClone()->getMock();
     $context->expects($this->once())->method('registerTrait')->with($this->isInstanceOf(PHP_Depend_Code_Trait::CLAZZ));
     $trait = new PHP_Depend_Code_Trait(__FUNCTION__);
     $trait->setContext($context);
     $trait->__wakeup();
 }