/** * Set up class mocker * * @return void */ public function setUp() { BaseMock::setDefaultCallBehavior(BaseMock::DEFAULT_BEHAVIOUR_RETURN_NULL); $this->classMocker = new ClassMocker(); //$this->classMocker->setGenerationDir('./var/generation'); $this->classMocker->mock('Foobar\\*'); $this->classMocker->registerTrait(TraitA::class); $this->classMocker->registerTrait(TraitB::class); $this->classMocker->registerTrait(TraitC::class); $this->classMocker->registerTrait(DummyTrait::class, 'Foobar\\*', 1000); // test footprints $footprintA = new ClassFootprint(); $footprintA->addInterface(Readable::class); $footprintA->addInterface(Talkable::class); $footprintB = new ClassFootprint(); $footprintB->setParent('Foobar\\BaseClass'); $this->classMocker->registerFootprint('Foobar\\BaseClass', $footprintA); $this->classMocker->registerFootprint('Foobar\\TestClass', $footprintB); $this->classMocker->enable(); }
/** * Retrieve class footprint from class scanner * * @param ClassScanner $class * * @return ClassFootprint */ protected function getClassFootprint(ClassScanner $class) { $footprint = new ClassFootprint(); if ($class->isInterface()) { $footprint->setType(ClassFootprint::TYPE_INTERFACE); } elseif ($class->isTrait()) { $footprint->setType(ClassFootprint::TYPE_TRAIT); } $footprint->setParent($class->getParentClass()); foreach ($class->getConstants(false) as $constant) { $footprint->addConstant($constant->getName(), $constant->getValue()); } foreach ($class->getInterfaces() as $interface) { $footprint->addInterface($interface); } return $footprint; }