/**
  * testMagicWakeupCallsRegisterTraitOnBuilderContext
  *
  * @return void
  */
 public function testMagicWakeupCallsRegisterTraitOnBuilderContext()
 {
     $context = $this->getMockBuilder('PDepend\\Source\\Builder\\BuilderContext')->disableOriginalClone()->getMock();
     $context->expects($this->once())->method('registerTrait')->with($this->isInstanceOf('PDepend\\Source\\AST\\ASTTrait'));
     $trait = new ASTTrait(__FUNCTION__);
     $trait->setContext($context);
     $trait->__wakeup();
 }
Exemplo n.º 2
0
 /**
  * This method will persist a trait instance for later reuse.
  *
  * @param  string                       $traitName
  * @param  string                       $namespaceName
  * @param  \PDepend\Source\AST\ASTTrait $trait
  * @return void
  * @@since 1.0.0
  */
 protected function storeTrait($traitName, $namespaceName, ASTTrait $trait)
 {
     $traitName = strtolower($traitName);
     if (!isset($this->traits[$traitName][$namespaceName])) {
         $this->traits[$traitName][$namespaceName] = array();
     }
     $this->traits[$traitName][$namespaceName][$trait->getId()] = $trait;
     $namespace = $this->buildNamespace($namespaceName);
     $namespace->addType($trait);
 }
 /**
  * Creates a ready to use trait fixture.
  *
  * @param string $name Optional trait name.
  * @return \PDepend\Source\AST\ASTTrait
  * @since 1.0.2
  */
 protected function createTraitFixture($name = null)
 {
     $name = $name ? $name : get_class($this);
     $trait = new ASTTrait($name);
     $trait->setCache(new MemoryCacheDriver());
     return $trait;
 }