diff options
Diffstat (limited to 'scripts/dev/generate-phpt/src/setup/preconditions')
6 files changed, 143 insertions, 0 deletions
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 @@ +<?php + +/** + * If use has requested a class check that method is specified + * + */ +class gtIfClassHasMethod extends gtPreCondition { + + public function check( $clo) { + if($clo->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 @@ +<?php + +/** + * Check that either a method or a function is specified + * + */ +class gtIsSpecifiedFunctionOrMethod extends gtPreCondition { + + public function check( $clo) { + if($clo->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 @@ +<?php + +/** + * Check that b|c|v is specified + * + */ +class gtIsSpecifiedTestType extends gtPreCondition { + + public function check( $clo) { + if($clo->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 @@ +<?php + +/** + * Check that the class name is valid + * + */ +class gtIsValidClass extends gtPreCondition { + + public function check( $clo) { + if($clo->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 @@ +<?php + +/** + * Check that the function name is valid + * + */ +class gtIsValidFunction extends gtPreCondition { + + public function check( $clo) { + if($clo->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 @@ +<?php + +/** + * Check that the method name is valid + * + */ +class gtIsValidMethod extends gtPreCondition { + + public function check( $clo) { + if($clo->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'); + } +} +?> |