From c4dd7a1a684490673e25aaf4fabec5df138854c4 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Thu, 14 Mar 2013 05:42:27 +0000 Subject: Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2. --- .../exceptions/gtMissingArgumentException.php | 7 ++ .../setup/exceptions/gtMissingOptionsException.php | 7 ++ .../setup/exceptions/gtUnknownOptionException.php | 7 ++ .../setup/exceptions/gtUnknownSectionException.php | 6 ++ .../src/setup/gtCommandLineOptions.php | 98 ++++++++++++++++++++++ .../generate-phpt/src/setup/gtOptionalSections.php | 85 +++++++++++++++++++ .../dev/generate-phpt/src/setup/gtPreCondition.php | 14 ++++ .../generate-phpt/src/setup/gtPreConditionList.php | 33 ++++++++ .../src/setup/preconditions/gtIfClassHasMethod.php | 24 ++++++ .../gtIsSpecifiedFunctionOrMethod.php | 21 +++++ .../setup/preconditions/gtIsSpecifiedTestType.php | 21 +++++ .../src/setup/preconditions/gtIsValidClass.php | 24 ++++++ .../src/setup/preconditions/gtIsValidFunction.php | 25 ++++++ .../src/setup/preconditions/gtIsValidMethod.php | 28 +++++++ 14 files changed, 400 insertions(+) create mode 100644 scripts/dev/generate-phpt/src/setup/exceptions/gtMissingArgumentException.php create mode 100644 scripts/dev/generate-phpt/src/setup/exceptions/gtMissingOptionsException.php create mode 100644 scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownOptionException.php create mode 100644 scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownSectionException.php create mode 100644 scripts/dev/generate-phpt/src/setup/gtCommandLineOptions.php create mode 100644 scripts/dev/generate-phpt/src/setup/gtOptionalSections.php create mode 100644 scripts/dev/generate-phpt/src/setup/gtPreCondition.php create mode 100644 scripts/dev/generate-phpt/src/setup/gtPreConditionList.php create mode 100644 scripts/dev/generate-phpt/src/setup/preconditions/gtIfClassHasMethod.php create mode 100644 scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedFunctionOrMethod.php create mode 100644 scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedTestType.php create mode 100644 scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidClass.php create mode 100644 scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidFunction.php create mode 100644 scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidMethod.php (limited to 'scripts/dev/generate-phpt/src/setup') diff --git a/scripts/dev/generate-phpt/src/setup/exceptions/gtMissingArgumentException.php b/scripts/dev/generate-phpt/src/setup/exceptions/gtMissingArgumentException.php new file mode 100644 index 0000000..91638e5 --- /dev/null +++ b/scripts/dev/generate-phpt/src/setup/exceptions/gtMissingArgumentException.php @@ -0,0 +1,7 @@ + diff --git a/scripts/dev/generate-phpt/src/setup/exceptions/gtMissingOptionsException.php b/scripts/dev/generate-phpt/src/setup/exceptions/gtMissingOptionsException.php new file mode 100644 index 0000000..5bff5e0 --- /dev/null +++ b/scripts/dev/generate-phpt/src/setup/exceptions/gtMissingOptionsException.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownOptionException.php b/scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownOptionException.php new file mode 100644 index 0000000..9b1a820 --- /dev/null +++ b/scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownOptionException.php @@ -0,0 +1,7 @@ + diff --git a/scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownSectionException.php b/scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownSectionException.php new file mode 100644 index 0000000..c484324 --- /dev/null +++ b/scripts/dev/generate-phpt/src/setup/exceptions/gtUnknownSectionException.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/scripts/dev/generate-phpt/src/setup/gtCommandLineOptions.php b/scripts/dev/generate-phpt/src/setup/gtCommandLineOptions.php new file mode 100644 index 0000000..0e4d878 --- /dev/null +++ b/scripts/dev/generate-phpt/src/setup/gtCommandLineOptions.php @@ -0,0 +1,98 @@ +isShortOption($argv[$i])) { + $option = substr($argv[$i], 1); + } else { + throw new gtUnknownOptionException('Unrecognised command line option ' . $argv[$i]); + } + + if (!in_array($option, array_merge($this->shortOptions, $this->shortOptionsWithArgs))) + { + throw new gtUnknownOptionException('Unknown option ' . $argv[$i]); + } + + if (in_array($option, $this->shortOptions)) { + $this->options[$option] = true; + continue; + } + + if (!$this->isValidOptionArg($argv, $i + 1)) + { + throw new gtMissingArgumentException('Missing argument for command line option ' . $argv[$i]); + } + + $i++; + $this->options[$option] = $argv[$i]; + } + } + + /** + * + */ + public function getOption($option) + { + if (!isset($this->options[$option])) { + return false; + } + return $this->options[$option]; + } + + + /** + * Check whether an option exists + */ + public function hasOption($option) + { + return isset($this->options[$option]); + } + + +} +?> \ No newline at end of file diff --git a/scripts/dev/generate-phpt/src/setup/gtOptionalSections.php b/scripts/dev/generate-phpt/src/setup/gtOptionalSections.php new file mode 100644 index 0000000..1d2a163 --- /dev/null +++ b/scripts/dev/generate-phpt/src/setup/gtOptionalSections.php @@ -0,0 +1,85 @@ + false, + 'ini' => false, + 'clean' => false, + 'done' => false, + ); + + private $skipifKey = ''; + private $skipifExt = ''; + + + public function setOptions($commandLineOptions) { + if($commandLineOptions->hasOption('s')) { + $options = explode(':', $commandLineOptions->getOption('s')); + + foreach($options as $option) { + + if(array_key_exists($option, $this->optSections )) { + $this->optSections[$option] = true; + } else { + throw new gtUnknownSectionException('Unrecognised optional section'); + } + } + + if($commandLineOptions->hasOption('k')) { + $this->skipifKey = $commandLineOptions->getOption('k'); + } + + if($commandLineOptions->hasOption('x')) { + $this->skipifExt = $commandLineOptions->getOption('x'); + } + + } + } + + + + public function getOptions() { + return $this->optSections; + } + + + public function getSkipifKey() { + return $this->skipifKey; + } + + public function getSkipifExt() { + return $this->skipifExt; + } + + public function hasSkipif() { + return $this->optSections['skipif']; + } + + public function hasSkipifKey() { + if($this->skipifKey != '') { + return true; + } + return false; + } + + public function hasSkipifExt() { + if($this->skipifExt != '') { + return true; + } + return false; + } + public function hasIni() { + return $this->optSections['ini']; + } + + public function hasClean() { + return $this->optSections['clean']; + } + + public function hasDone() { + return $this->optSections['done']; + } + + +} +?> \ No newline at end of file diff --git a/scripts/dev/generate-phpt/src/setup/gtPreCondition.php b/scripts/dev/generate-phpt/src/setup/gtPreCondition.php new file mode 100644 index 0000000..858395b --- /dev/null +++ b/scripts/dev/generate-phpt/src/setup/gtPreCondition.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/scripts/dev/generate-phpt/src/setup/gtPreConditionList.php b/scripts/dev/generate-phpt/src/setup/gtPreConditionList.php new file mode 100644 index 0000000..06c1752 --- /dev/null +++ b/scripts/dev/generate-phpt/src/setup/gtPreConditionList.php @@ -0,0 +1,33 @@ +preConditions as $preCon) { + $checkThis = new $preCon; + if(!$checkThis->check($clo)) { + echo $checkThis->getMessage(); + die(gtText::get('help')); + } + } + } +} +?> \ No newline at end of file diff --git a/scripts/dev/generate-phpt/src/setup/preconditions/gtIfClassHasMethod.php b/scripts/dev/generate-phpt/src/setup/preconditions/gtIfClassHasMethod.php new file mode 100644 index 0000000..c91b210 --- /dev/null +++ b/scripts/dev/generate-phpt/src/setup/preconditions/gtIfClassHasMethod.php @@ -0,0 +1,24 @@ +hasOption('c')) { + if(!$clo->hasOption('m')) { + return false; + } + return true; + } + return true; + } + + public function getMessage() { + return gtText::get('methodNotSpecified'); + } + +} +?> \ No newline at end of file diff --git a/scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedFunctionOrMethod.php b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedFunctionOrMethod.php new file mode 100644 index 0000000..7495c73 --- /dev/null +++ b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedFunctionOrMethod.php @@ -0,0 +1,21 @@ +hasOption('f') || $clo->hasOption('m')) { + + return true; + } + return false; + } + + public function getMessage() { + return gtText::get('functionOrMethodNotSpecified'); + } +} +?> \ No newline at end of file diff --git a/scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedTestType.php b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedTestType.php new file mode 100644 index 0000000..40530f3 --- /dev/null +++ b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsSpecifiedTestType.php @@ -0,0 +1,21 @@ +hasOption('b') || $clo->hasOption('e') || $clo->hasOption('v') ) { + + return true; + } + return false; + } + + public function getMessage() { + return gtText::get('testTypeNotSpecified'); + } +} +?> \ No newline at end of file diff --git a/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidClass.php b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidClass.php new file mode 100644 index 0000000..a39bab4 --- /dev/null +++ b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidClass.php @@ -0,0 +1,24 @@ +hasOption('c') ) { + $className = $clo->getOption('c'); + if( in_array( $className, get_declared_classes() ) ) { + return true; + } + return false; + } + return true; + } + + public function getMessage() { + return gtText::get('unknownClass'); + } +} +?> \ No newline at end of file diff --git a/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidFunction.php b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidFunction.php new file mode 100644 index 0000000..ed91c2c --- /dev/null +++ b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidFunction.php @@ -0,0 +1,25 @@ +hasOption('f') ) { + $function = $clo->getOption('f'); + $functions = get_defined_functions(); + if( in_array( $function, $functions['internal'] ) ) { + return true; + } + return false; + } + return true; + } + + public function getMessage() { + return gtText::get('unknownFunction'); + } +} +?> \ No newline at end of file diff --git a/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidMethod.php b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidMethod.php new file mode 100644 index 0000000..a52988a --- /dev/null +++ b/scripts/dev/generate-phpt/src/setup/preconditions/gtIsValidMethod.php @@ -0,0 +1,28 @@ +hasOption('m') ) { + $className = $clo->getOption('c'); + $class = new ReflectionClass($className); + $methods = $class->getMethods(); + foreach($methods as $method) { + if($clo->getOption('m') == $method->getName()) { + return true; + } + } + return false; + } + return true; + } + + public function getMessage() { + return gtText::get('unknownMethod'); + } +} +?> -- cgit v1.2.1