/** * Applies to scaffold all build instructions * that have specified build phase. * * @param Scaffold $scaffold * @param int $phase */ protected function applyInstructions(Scaffold $scaffold, $phase) { $instructions = $this->blueprint->getInstructions($phase); foreach ($instructions as $instruction) { $instruction->apply($scaffold); } }
public function test() { # test class inialization $this->assertEquals('SomeClass', $this->bp->class); # test getting instructions $this->assertTrue(in_array($this->instr1, $this->bp->getInstructions(Instruction::PHASE_FINAL))); $this->assertEmpty($this->bp->getInstructions(Instruction::PHASE_PRE_INST)); # test adding instruction $this->bp->add($this->instr2); $this->assertTrue(in_array($this->instr2, $this->bp->getInstructions(Instruction::PHASE_PRE_INST))); $this->assertEmpty($this->bp->getInstructions(Instruction::PHASE_POST_INST)); # test adding closure $fn = function () { }; $this->bp->add($fn); $list = $this->bp->getInstructions(Instruction::PHASE_POST_INST); $instr = array_pop($list); $this->assertTrue($instr instanceof CustomInstruction); }