/** * Internal routine for parsing the provider options from the command line * * @return null */ protected function _parseProviderOptionsPart() { if (current($this->_argumentsWorking) == '?') { $this->_help = true; return; } $searchParams = array('type' => 'Tool', 'providerName' => $this->_request->getProviderName(), 'actionName' => $this->_request->getActionName(), 'specialtyName' => $this->_request->getSpecialtyName(), 'clientName' => 'console'); $actionableMethodLongParamsMetadata = $this->_manifestRepository->getMetadata(array_merge($searchParams, array('name' => 'actionableMethodLongParams'))); $actionableMethodShortParamsMetadata = $this->_manifestRepository->getMetadata(array_merge($searchParams, array('name' => 'actionableMethodShortParams'))); $paramNameShortValues = $actionableMethodShortParamsMetadata->getValue(); $getoptOptions = array(); $wordArguments = array(); $longParamCanonicalNames = array(); $actionableMethodLongParamsMetadataReference = $actionableMethodLongParamsMetadata->getReference(); foreach ($actionableMethodLongParamsMetadata->getValue() as $parameterNameLong => $consoleParameterNameLong) { $optionConfig = $consoleParameterNameLong . '|'; $parameterInfo = $actionableMethodLongParamsMetadataReference['parameterInfo'][$parameterNameLong]; // process ParameterInfo into array for command line option matching if ($parameterInfo['type'] == 'string' || $parameterInfo['type'] == 'bool') { $optionConfig .= $paramNameShortValues[$parameterNameLong] . ($parameterInfo['optional'] ? '-' : '=') . 's'; } elseif (in_array($parameterInfo['type'], array('int', 'integer', 'float'))) { $optionConfig .= $paramNameShortValues[$parameterNameLong] . ($parameterInfo['optional'] ? '-' : '=') . 'i'; } else { $optionConfig .= $paramNameShortValues[$parameterNameLong] . '-s'; } $getoptOptions[$optionConfig] = $parameterInfo['description'] != '' ? $parameterInfo['description'] : 'No description available.'; // process ParameterInfo into array for command line WORD (argument) matching $wordArguments[$parameterInfo['position']]['parameterName'] = $parameterInfo['name']; $wordArguments[$parameterInfo['position']]['optional'] = $parameterInfo['optional']; $wordArguments[$parameterInfo['position']]['type'] = $parameterInfo['type']; // keep a translation of console to canonical names $longParamCanonicalNames[$consoleParameterNameLong] = $parameterNameLong; } if (!$getoptOptions) { // no options to parse here, return return; } // if non-option arguments exist, attempt to process them before processing options $wordStack = array(); while ($wordOnTop = array_shift($this->_argumentsWorking)) { if (substr($wordOnTop, 0, 1) != '-') { array_push($wordStack, $wordOnTop); } else { // put word back on stack and move on array_unshift($this->_argumentsWorking, $wordOnTop); break; } if (count($wordStack) == count($wordArguments)) { // when we get at most the number of arguments we are expecting // then break out. break; } } if ($wordStack && $wordArguments) { for ($wordIndex = 1; $wordIndex <= count($wordArguments); $wordIndex++) { if (!array_key_exists($wordIndex - 1, $wordStack) || !array_key_exists($wordIndex, $wordArguments)) { break; } $this->_request->setProviderParameter($wordArguments[$wordIndex]['parameterName'], $wordStack[$wordIndex - 1]); unset($wordStack[$wordIndex - 1]); } } $getoptParser = new \Zend\Console\Getopt($getoptOptions, $this->_argumentsWorking, array('parseAll' => false)); $getoptParser->parse(); foreach ($getoptParser->getOptions() as $option) { $value = $getoptParser->getOption($option); $providerParamOption = $longParamCanonicalNames[$option]; $this->_request->setProviderParameter($providerParamOption, $value); } $this->_argumentsWorking = $getoptParser->getRemainingArgs(); return; }
$exitCode = proc_close($handle); if ($exitCode) { printf("\n\nUnit tests for module '%s' failed with status %d. Aborting.\n", $module, $exitCode); exit(1); } else { print "\n"; } } else { print "Could not invoke PHPUnit. Aborting.\n"; exit(1); } } try { $opts = new \Zend\Console\Getopt(array('modules|m=s' => 'comma-separated list of modules to test (case insensitive), test all modules if not set', 'filter|f=s' => 'run only tests whose names match given regex', 'database|d-s' => 'comma-separated list of INI sections with database config (use all sections if empty)', 'coverage|c' => 'generate code coverage report (slow, requires Xdebug extension)')); $opts->parse(); if ($opts->getRemainingArgs()) { throw new \Zend\Console\Exception\RuntimeException('Non-option arguments not allowed', $opts->getUsageMessage()); } } catch (\Zend\Console\Exception\RuntimeException $e) { print $e->getUsageMessage(); exit(1); } // Generate list of available modules. // The following basic modules are tested first. Other modules are added // dynamically. $modulesAvailable = array('Library', 'Database', 'Model'); foreach (new \FilesystemIterator(__DIR__ . '/../module') as $entry) { if ($entry->isDir() and !in_array($entry->getFilename(), $modulesAvailable)) { $modulesAvailable[] = $entry->getFilename(); } }