/** * Builds a modifier, expects a key called "name" to exist in the $data array * * @param array $data * * @return Modifier */ public function buildModifier(array $data) { $modifier = $this->modifierLibrary->getInstance($data['name']); if (isset($data['value'])) { $modifier->setTargetValue($data['value']); } return $modifier; }
function it_should_allow_to_build_an_modifier(Library $modifierLibrary, Modifier $modifier) { $data = ['name' => 'test', 'value' => 1]; $modifier->implement('Indigo\\Ruler\\Builder\\HasTargetValue'); $modifier->beADoubleOf('Indigo\\Ruler\\Stub\\Builder\\TargetValueAware'); $modifierLibrary->getInstance('test')->willReturn($modifier); $this->setModifierLibrary($modifierLibrary); $modifier = $this->buildModifier($data); $modifier->shouldHaveType('Indigo\\Ruler\\Modifier'); }