protected function processPhixSwitchesAfterCommandLoad(Context $context, ParsedSwitches $ParsedSwitches) { // what switches do we have? $parsedSwitches = $ParsedSwitches->getSwitches(); // let's deal with them foreach ($parsedSwitches as $parsedSwitch) { $switchName = $parsedSwitch->name; $className = '\\Phix_Project\\PhixSwitches\\' . ucfirst($switchName) . 'Switch'; $errCode = $className::processAfterCommandLoad($context, $ParsedSwitches->getArgsForSwitch($switchName)); if ($errCode !== null) { return $errCode; } } // all done - return NULL to signify that we're not yet // ready to terminate phix return null; }
public function testCanValidateAllSwitchValuesInOneGo() { // define the options we are expecting $expectedOptions = new DefinedSwitches(); $switch1 = $expectedOptions->addSwitch('fred', 'desc 1')->setWithOptionalArg("<fish>", 'the fish that fred likes most')->setArgValidator(new MustBeString()); $switch2 = $expectedOptions->addSwitch('harry', 'desc 2')->setWithOptionalArg('<sauce>', 'the sauce that harry likes most')->setArgValidator(new MustBeInteger()); // add the parsed results $ParsedSwitches = new ParsedSwitches(); $ParsedSwitches->addSwitch($expectedOptions, 'fred', 'trout'); $ParsedSwitches->addSwitch($expectedOptions, 'harry', 'salmon'); // now, can we validate or not? $results = $ParsedSwitches->validateSwitchValues(); // what happened? $this->assertTrue(is_array($results)); $this->assertEquals(1, count($results)); }