예제 #1
0
 /**
  * Generate class using any given references or traits
  *
  * @param string $className
  *
  * @return FileGenerator
  */
 public function build($className)
 {
     $footprint = $this->_footprintRegistry->get($className);
     $parentClass = $footprint->getParent();
     if (!$parentClass) {
         $parentClass = $this->_baseClassRegistry->find($className);
     }
     if ($footprint->isInterface()) {
         $generator = new InterfaceGenerator();
     } else {
         $traits = $this->_traitRegistry->findByClass($className);
         $generator = new ClassGenerator();
         $generator->useTraits($traits);
     }
     $generator->setName($className);
     $generator->setExtendedClass($parentClass);
     $generator->setImplementedInterfaces($footprint->getInterfaces());
     foreach ($footprint->getConstants() as $name => $value) {
         $generator->addConstant($name, $value);
     }
     $file = new FileGenerator();
     $file->setClass($generator);
     return $file;
 }
 /**
  * All base classes must register the BaseMock class
  *
  * @test
  * @expectedException \RuntimeException
  * @expectedExceptionMessage does not extend from BaseMock
  */
 public function shouldFailOnInvalidClass()
 {
     $registry = new BaseClassRegistry();
     $registry->register(BaseClassRegistry::class);
 }