mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Removed the generated-tests library, this is a left Zöe's phpruntests repository it seems and never fully implemented. The only times this part of the code has been touched throughout the years has been minor PRs and entire php-src grep commits.
If anything this belongs to the phpruntests.git repository.
This commit is contained in:
parent
b1864b0178
commit
ba138a3746
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<project name="generate" default="test" basedir=".">
|
||||
|
||||
<property name="build.dir" value="_build" />
|
||||
|
||||
<target name="docs" description="Create API documentation.">
|
||||
<exec command="doxygen doxygen.conf" />
|
||||
</target>
|
||||
|
||||
<target name="test" description="Run all unit tests.">
|
||||
<exec command="phpunit --coverage-html coverage tests" passthru="true" />
|
||||
</target>
|
||||
|
||||
</project>
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This creates a standalone phar file with all of the PHP source included. To run the
|
||||
* phar just type 'php generate-phpt.phar <options>' at the command line.
|
||||
*/
|
||||
|
||||
if (Phar::canWrite()) {
|
||||
echo "Writing phar archive\n";
|
||||
} else {
|
||||
echo "Unable to write archive, check that phar.readonly is 0 in your php.ini\n";
|
||||
exit();
|
||||
}
|
||||
$thisDir = dirname(__FILE__);
|
||||
$pharPath = substr($thisDir, 0, -strlen('/generate-phpt'));
|
||||
|
||||
$phar = new Phar($pharPath.'/generate-phpt.phar');
|
||||
|
||||
$phar->buildFromDirectory($thisDir.'/src');
|
||||
|
||||
$stub = <<<ENDSTUB
|
||||
<?php
|
||||
Phar::mapPhar('generate-phpt.phar');
|
||||
require 'phar://generate-phpt.phar/generate-phpt.php';
|
||||
__HALT_COMPILER();
|
||||
ENDSTUB;
|
||||
|
||||
$phar->setStub($stub);
|
||||
|
||||
?>
|
@ -1,9 +0,0 @@
|
||||
$index_array = array(1, 2, 3);
|
||||
$assoc_array = array(1 => 'one', 2 => 'two');
|
||||
|
||||
$variation_array = array(
|
||||
'empty array' => array(),
|
||||
'int indexed array' => $index_array,
|
||||
'associative array' => $assoc_array,
|
||||
'nested arrays' => array('foo', $index_array, $assoc_array),
|
||||
);
|
@ -1,6 +0,0 @@
|
||||
$variation_array = array(
|
||||
'lowercase true' => true,
|
||||
'lowercase false' =>false,
|
||||
'uppercase TRUE' =>TRUE,
|
||||
'uppercase FALSE' =>FALSE,
|
||||
);
|
@ -1,2 +0,0 @@
|
||||
*
|
||||
*/
|
@ -1,2 +0,0 @@
|
||||
/**
|
||||
*
|
@ -1,11 +0,0 @@
|
||||
$unset_var = 10;
|
||||
unset($unset_var);
|
||||
|
||||
$variation_array = array(
|
||||
'unset var' => @$unset_var,
|
||||
'undefined var' => @$undefined_var,
|
||||
'empty string DQ' => "",
|
||||
'empty string SQ' => '',
|
||||
'uppercase NULL' => NULL,
|
||||
'lowercase null' => null,
|
||||
);
|
@ -1,7 +0,0 @@
|
||||
$variation_array = array(
|
||||
'float 10.5' => 10.5,
|
||||
'float -10.5' => -10.5,
|
||||
'float 12.3456789000e10' => 12.3456789000e10,
|
||||
'float -12.3456789000e10' => -12.3456789000e10,
|
||||
'float .5' => .5,
|
||||
);
|
@ -1,6 +0,0 @@
|
||||
$variation_array = array (
|
||||
'int 0' => 0,
|
||||
'int 1' => 1,
|
||||
'int 12345' => 12345,
|
||||
'int -12345' => -2345,
|
||||
);
|
@ -1 +0,0 @@
|
||||
}
|
@ -1 +0,0 @@
|
||||
foreach ( $variation_array as $var ) {
|
@ -1,25 +0,0 @@
|
||||
function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
|
||||
if (error_reporting() != 0) {
|
||||
// report non-silenced errors
|
||||
echo "Error: $err_no - $err_msg, $filename($linenum)\n";
|
||||
}
|
||||
}
|
||||
set_error_handler('test_error_handler');
|
||||
|
||||
|
||||
|
||||
class classWithToString
|
||||
{
|
||||
public function __toString() {
|
||||
return "Class A object";
|
||||
}
|
||||
}
|
||||
|
||||
class classWithoutToString
|
||||
{
|
||||
}
|
||||
|
||||
$variation_array = array(
|
||||
'instance of classWithToString' => new classWithToString(),
|
||||
'instance of classWithoutToString' => new classWithoutToString(),
|
||||
);
|
@ -1 +0,0 @@
|
||||
if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platforms only");
|
@ -1 +0,0 @@
|
||||
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only");
|
@ -1 +0,0 @@
|
||||
if (substr(PHP_OS, 0, 3) != 'WIN') die("skip this test is for Windows platforms only");
|
@ -1 +0,0 @@
|
||||
if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test is not for Windows platforms");
|
@ -1,10 +0,0 @@
|
||||
$heredoc = <<<EOT
|
||||
hello world
|
||||
EOT;
|
||||
|
||||
$variation_array = array(
|
||||
'string DQ' => "string",
|
||||
'string SQ' => 'string',
|
||||
'mixed case string' => "sTrInG",
|
||||
'heredoc' => $heredoc,
|
||||
);
|
@ -1,115 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Main code for test case generation
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/gtAutoload.php';
|
||||
|
||||
//Version check. Will not run on less than PHP53;
|
||||
|
||||
list($major, $minor, $bug) = explode(".", phpversion(), 3);
|
||||
if($major == 5) {
|
||||
if($minor < 3) { die("Sorry, you need PHP version 5.3 or greater to run this.\n"); }
|
||||
}
|
||||
if ($major < 5) { die ("Seriously, you need to upgrade you PHP level\n"); }
|
||||
|
||||
|
||||
$options = new gtCommandLineOptions();
|
||||
$optionalSections = new gtOptionalSections();
|
||||
|
||||
try{
|
||||
$options->parse($argv);
|
||||
} catch (exception $e) {
|
||||
echo $e->getMessage()."\n";
|
||||
die();
|
||||
}
|
||||
|
||||
if($options->hasOption('h')) {
|
||||
die(gtText::get('help'));
|
||||
}
|
||||
|
||||
try {
|
||||
$preConditions = new gtPreConditionList();
|
||||
$preConditions->check($options);
|
||||
} catch (exception $e) {
|
||||
echo $e->getMessage()."\n";
|
||||
die();
|
||||
}
|
||||
|
||||
if($options->hasOption('s')) {
|
||||
$optionalSections->setOptions($options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($options->hasOption('c')) {
|
||||
$name = $options->getOption('c')."_".$options->getOption('m');
|
||||
$method = new gtMethod($options->getOption('c'), $options->getOption('m'));
|
||||
|
||||
$method->setArgumentNames();
|
||||
$method->setArgumentLists();
|
||||
$method->setInitialisationStatements();
|
||||
|
||||
$method->setConstructorArgumentNames();
|
||||
$method->setConstructorInitStatements();
|
||||
$method->setConstructorArgumentList();
|
||||
}
|
||||
|
||||
if($options->hasOption('f')) {
|
||||
$name = $options->getOption('f');
|
||||
$function = new gtFunction($name);
|
||||
$function->setArgumentNames();
|
||||
$function->setArgumentLists();
|
||||
$function->setInitialisationStatements();
|
||||
}
|
||||
|
||||
|
||||
if($options->hasOption('b')) {
|
||||
if($options->hasOption('c')) {
|
||||
$testCase = gtBasicTestCase::getInstance($optionalSections, 'method');
|
||||
$testCase->setMethod($method);
|
||||
} else {
|
||||
$testCase = gtBasicTestCase::getInstance($optionalSections);
|
||||
$testCase->setFunction($function);
|
||||
}
|
||||
|
||||
$testCase->constructTestCase();
|
||||
gtTestCaseWriter::write($name, $testCase->toString(), 'b');
|
||||
}
|
||||
|
||||
if($options->hasOption('e')) {
|
||||
if($options->hasOption('c')) {
|
||||
$testCase = gtErrorTestCase::getInstance($optionalSections, 'method');
|
||||
$testCase->setMethod($method);
|
||||
} else {
|
||||
$testCase = gtErrorTestCase::getInstance($optionalSections);
|
||||
$testCase->setFunction($function);
|
||||
}
|
||||
|
||||
$testCase->constructTestCase();
|
||||
gtTestCaseWriter::write($name, $testCase->toString(), 'e');
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($options->hasOption('v')) {
|
||||
if($options->hasOption('c')) {
|
||||
$testCaseContainer = gtVariationContainer::getInstance($optionalSections, 'method');
|
||||
$testCaseContainer->setMethod($method);
|
||||
} else {
|
||||
$testCaseContainer = gtVariationContainer::getInstance ($optionalSections);
|
||||
$testCaseContainer->setFunction($function);
|
||||
}
|
||||
|
||||
$testCaseContainer->constructAll();
|
||||
|
||||
$tests = $testCaseContainer->getVariationTests();
|
||||
|
||||
$count = 1;
|
||||
foreach($tests as $test) {
|
||||
gtTestCaseWriter::write($name, $test, 'v', $count);
|
||||
$count++;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
|
||||
gtAutoload::init();
|
||||
|
||||
/**
|
||||
* Autoloader using a map file (gtClassMap.php)
|
||||
* defining the file to load each class from.
|
||||
*/
|
||||
class gtAutoload
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $classMap;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected static $classPath;
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the autoloader
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public static function init()
|
||||
{
|
||||
self::$classPath = dirname(__FILE__);
|
||||
|
||||
if (substr(self::$classPath, -1) != '/') {
|
||||
self::$classPath .= '/';
|
||||
}
|
||||
|
||||
if (file_exists(self::$classPath . 'gtClassMap.php')) {
|
||||
include self::$classPath . 'gtClassMap.php';
|
||||
self::$classMap = $gtClassMap;
|
||||
}
|
||||
|
||||
if (function_exists('__autoload')) {
|
||||
spl_autoload_register('__autoload');
|
||||
}
|
||||
|
||||
spl_autoload_register(array('gtAutoload', 'autoload'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Autoload method
|
||||
*
|
||||
* @param string $class Class name to autoload
|
||||
* @return null
|
||||
*/
|
||||
public static function autoload($class)
|
||||
{
|
||||
if (isset(self::$classMap[$class])) {
|
||||
include self::$classPath . self::$classMap[$class];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
$gtClassMap = array(
|
||||
|
||||
'gtCodeSnippet' => 'gtCodeSnippet.php',
|
||||
'gtTestSubject' => 'gtTestSubject.php',
|
||||
'gtFunction' => 'gtFunction.php',
|
||||
'gtMethod' => 'gtMethod.php',
|
||||
'gtTestCaseWriter' => 'gtTestCaseWriter.php',
|
||||
'gtText' => 'gtText.php',
|
||||
|
||||
|
||||
|
||||
'gtCommandLineOptions' => 'setup/gtCommandLineOptions.php',
|
||||
'gtOptionalSections' => 'setup/gtOptionalSections.php',
|
||||
'gtMissingArgumentException' => 'setup/exceptions/gtMissingArgumentException.php',
|
||||
'gtUnknownOptionException' => 'setup/exceptions/gtUnknownOptionException.php',
|
||||
'gtUnknownSectionException' => 'setup/exceptions/gtUnknownSectionException.php',
|
||||
'gtMissingOptionsException' => 'setup/exceptions/gtMissingOptionsException.php',
|
||||
|
||||
'gtPreCondition' => 'setup/gtPreCondition.php',
|
||||
'gtPreConditionList' => 'setup/gtPreConditionList.php',
|
||||
'gtIsSpecifiedTestType' => 'setup/preconditions/gtIsSpecifiedTestType.php',
|
||||
'gtIfClassHasMethod' => 'setup/preconditions/gtIfClassHasMethod.php',
|
||||
'gtIsSpecifiedFunctionOrMethod' => 'setup/preconditions/gtIsSpecifiedFunctionOrMethod.php',
|
||||
'gtIsValidClass' => 'setup/preconditions/gtIsValidClass.php',
|
||||
'gtIsValidMethod' => 'setup/preconditions/gtIsValidMethod.php',
|
||||
'gtIsValidFunction' => 'setup/preconditions/gtIsValidFunction.php',
|
||||
|
||||
|
||||
'gtTestCase' => 'testcase/gtTestCase.php',
|
||||
'gtVariationTestCase' => 'testcase/gtVariationTestCase.php',
|
||||
'gtVariationTestCaseFunction' => 'testcase/gtVariationTestCaseFunction.php',
|
||||
'gtVariationTestCaseMethod' => 'testcase/gtVariationTestCaseMethod.php',
|
||||
|
||||
'gtBasicTestCase' => 'testcase/gtBasicTestCase.php',
|
||||
'gtBasicTestCaseFunction' => 'testcase/gtBasicTestCaseFunction.php',
|
||||
'gtBasicTestCaseMethod' => 'testcase/gtBasicTestCaseMethod.php',
|
||||
|
||||
'gtErrorTestCase' => 'testcase/gtErrorTestCase.php',
|
||||
'gtErrorTestCaseFunction' => 'testcase/gtErrorTestCaseFunction.php',
|
||||
'gtErrorTestCaseMethod' => 'testcase/gtErrorTestCaseMethod.php',
|
||||
|
||||
'gtVariationContainer' => 'testcase/gtVariationContainer.php',
|
||||
'gtVariationContainerMethod' => 'testcase/gtVariationContainerMethod.php',
|
||||
'gtVariationContainerFunction' => 'testcase/gtVariationContainerFunction.php',
|
||||
);
|
||||
?>
|
@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Retrieves code snippets for adding to test cases
|
||||
*
|
||||
*/
|
||||
class gtCodeSnippet
|
||||
{
|
||||
|
||||
/**
|
||||
* get the code snippet and initialise an array with it
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public static function get($name) {
|
||||
|
||||
$filename = dirname(__FILE__) . '/codeSnippets/' . $name . '.txt';
|
||||
|
||||
if (!file_exists($filename)) {
|
||||
throw new LogicException('The code snippet ' . $name . ' does not exist');
|
||||
}
|
||||
|
||||
$lines = file($filename);
|
||||
foreach($lines as $l) {
|
||||
$array[] = rtrim($l);
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Append the code snippet on to an existing array
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $array
|
||||
* @return array
|
||||
*/
|
||||
public static function append($name, $array) {
|
||||
$filename = dirname(__FILE__) . '/codeSnippets/' . $name . '.txt';
|
||||
|
||||
if (!file_exists($filename)) {
|
||||
throw new LogicException('The code snippet ' . $name . ' does not exist');
|
||||
}
|
||||
|
||||
$text = file($filename);
|
||||
foreach ($text as $t) {
|
||||
$array[] = rtrim($t);
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Appends blank entries on to an array
|
||||
*
|
||||
* @param int $numberOfLines
|
||||
* @param array $array
|
||||
* @return array
|
||||
*/
|
||||
public static function appendBlankLines($numberOfLines, $array) {
|
||||
|
||||
for ($i=0; $i< $numberOfLines; $i++) {
|
||||
$array[] = "";
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class reperesents a single PHP function.
|
||||
*
|
||||
*/
|
||||
class gtFunction extends gtTestSubject {
|
||||
|
||||
private $functionName;
|
||||
|
||||
/**
|
||||
* Set the name of the name of the function
|
||||
*
|
||||
* @param string $functionName
|
||||
*/
|
||||
public function __construct($functionName) {
|
||||
$this->functionName = $functionName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the names of function arguments and initialise mandatory and optional argument arrays
|
||||
*
|
||||
*/
|
||||
public function setArgumentNames() {
|
||||
$function= new ReflectionFunction($this->functionName);
|
||||
|
||||
foreach ($function->getParameters() as $i => $param) {
|
||||
if($param->isOptional()) {
|
||||
$this->optionalArgumentNames[] = $param->getName();
|
||||
} else {
|
||||
$this->mandatoryArgumentNames[] = $param->getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the function
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->functionName;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,139 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class for method under test (see gtFunction for non-OO tests)
|
||||
*/
|
||||
class gtMethod extends gtTestSubject {
|
||||
|
||||
private $className;
|
||||
private $methodName;
|
||||
private $constructorArgumentNames;
|
||||
private $constructorArgumentList = '';
|
||||
private $constructorInitialisationStatements;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Construct gtMethod object from the class and method names
|
||||
*
|
||||
* @param string $className
|
||||
* @param string $methodName
|
||||
*/
|
||||
public function __construct($className, $methodName) {
|
||||
$this->className = $className;
|
||||
$this->methodName = $methodName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the names of the class constructor arguments. Take only mandatory argument names.
|
||||
*
|
||||
*/
|
||||
public function setConstructorArgumentNames() {
|
||||
$reflectionClass = new ReflectionClass($this->className);
|
||||
$constructor = $reflectionClass->getConstructor();
|
||||
foreach($constructor->getParameters() as $i => $param) {
|
||||
//if(!$param->isOptional()) {
|
||||
$this->constructorArgumentNames[] = $param->getName();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the names of the mandatory and optional arguments to the method
|
||||
*
|
||||
*/
|
||||
public function setArgumentNames() {
|
||||
|
||||
$methodClass = new reflectionMethod($this->className, $this->methodName);
|
||||
$parameters = $methodClass->getParameters();
|
||||
|
||||
foreach ($methodClass->getParameters() as $i => $param) {
|
||||
if($param->isOptional()) {
|
||||
$this->optionalArgumentNames[] = $param->getName();
|
||||
} else {
|
||||
$this->mandatoryArgumentNames[] = $param->getName();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the list of constructor argument names
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getConstructorArgumentNames() {
|
||||
return $this->constructorArgumentNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the method
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->methodName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the name of the class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName() {
|
||||
return $this->className;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of arguments to be passed to the constructor
|
||||
*
|
||||
*/
|
||||
public function setConstructorArgumentList() {
|
||||
if(count ($this->constructorArgumentNames) > 0) {
|
||||
|
||||
for( $i = 0; $i < count( $this->constructorArgumentNames ); $i++) {
|
||||
$this->constructorArgumentList .= "\$".$this->constructorArgumentNames[$i].", ";
|
||||
}
|
||||
$this->constructorArgumentList = substr($this->constructorArgumentList, 0, -2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the list of the arguments to be passed to the constructor
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getConstructorArgumentList() {
|
||||
return $this->constructorArgumentList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set up the source statements that initialise constructor arguments;
|
||||
*
|
||||
*/
|
||||
public function setConstructorInitStatements() {
|
||||
if(count ($this->constructorArgumentNames) > 0) {
|
||||
foreach( $this->constructorArgumentNames as $name) {
|
||||
$this->constructorInitialisationStatements[] = "\$".$name." = ";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the constructor initialisation statements
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getConstructorInitStatements() {
|
||||
return $this->constructorInitialisationStatements;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Writes a single test case to a file
|
||||
*
|
||||
*/
|
||||
class gtTestCaseWriter {
|
||||
|
||||
public static function write($name, $string, $type, $count = 0) {
|
||||
if ($type == 'b') {
|
||||
$fileName = $name."_basic.phpt";
|
||||
}
|
||||
|
||||
if ($type == 'e') {
|
||||
$fileName = $name."_error.phpt";
|
||||
}
|
||||
|
||||
if ($type == 'v') {
|
||||
$fileName = $name."_variation".$count.".phpt";
|
||||
}
|
||||
|
||||
$fh = fopen($fileName, 'w');
|
||||
fwrite ($fh, $string);
|
||||
fclose($fh);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,166 +0,0 @@
|
||||
<?php
|
||||
abstract class gtTestSubject {
|
||||
|
||||
protected $optionalArgumentNames = [];
|
||||
protected $mandatoryArgumentNames = [];
|
||||
|
||||
protected $extraArgumentList = '';
|
||||
protected $shortArgumentList = '';
|
||||
|
||||
protected $allowedArgumentLists;
|
||||
|
||||
protected $maximumArgumentList;
|
||||
|
||||
protected $initialisationStatements;
|
||||
|
||||
|
||||
/** Return the list of all mandatory argument names
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMandatoryArgumentNames() {
|
||||
return $this->mandatoryArgumentNames;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the list of all optional argument names
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptionalArgumentNames() {
|
||||
return $this->optionalArgumentNames;
|
||||
}
|
||||
|
||||
public function setArgumentLists() {
|
||||
$this->setValidArgumentLists();
|
||||
$this->setExtraArgumentList();
|
||||
$this->setShortArgumentList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the argument list to call the subject with. Adds one extra argument.
|
||||
*
|
||||
*/
|
||||
public function setExtraArgumentList() {
|
||||
if(count ($this->mandatoryArgumentNames) > 0) {
|
||||
for( $i = 0; $i < count( $this->mandatoryArgumentNames ); $i++) {
|
||||
$this->extraArgumentList .= "\$".$this->mandatoryArgumentNames[$i].", ";
|
||||
}
|
||||
}
|
||||
|
||||
if(count ($this->optionalArgumentNames) > 0) {
|
||||
for( $i = 0; $i < count( $this->optionalArgumentNames ); $i++) {
|
||||
$this->extraArgumentList .= "\$".$this->optionalArgumentNames[$i].", ";
|
||||
}
|
||||
}
|
||||
|
||||
$this->extraArgumentList= $this->extraArgumentList. "\$extra_arg";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the list of arguments as it appears in the function call
|
||||
*
|
||||
* @return string - list of arguments
|
||||
*/
|
||||
public function getExtraArgumentList() {
|
||||
return $this->extraArgumentList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the list of function arguments to be one less that the number of mandatory arguments
|
||||
*
|
||||
*/
|
||||
public function setShortArgumentList() {
|
||||
|
||||
if(count ($this->mandatoryArgumentNames) > 0) {
|
||||
for( $i = 0; $i < count( $this->mandatoryArgumentNames ) - 1; $i++) {
|
||||
$this->shortArgumentList .= "\$".$this->mandatoryArgumentNames[$i].", ";
|
||||
}
|
||||
$this->shortArgumentList = substr($this->shortArgumentList, 0, -2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the short list of arguments
|
||||
*
|
||||
* @return string - list of arguments
|
||||
*/
|
||||
public function getShortArgumentList() {
|
||||
return $this->shortArgumentList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct the list of all possible ways to call the subject (function or method)
|
||||
*
|
||||
*/
|
||||
public function setValidArgumentLists() {
|
||||
$this->allowedArgumentLists[0] = '';
|
||||
if(count ($this->mandatoryArgumentNames) > 0) {
|
||||
for( $i = 0; $i < count( $this->mandatoryArgumentNames ); $i++) {
|
||||
$this->allowedArgumentLists[0] .= "\$".$this->mandatoryArgumentNames[$i].", ";
|
||||
}
|
||||
}
|
||||
|
||||
if(count ($this->optionalArgumentNames) > 0) {
|
||||
for( $i = 0; $i < count( $this->optionalArgumentNames ); $i++) {
|
||||
$this->allowedArgumentLists[] = $this->allowedArgumentLists[$i]."\$".$this->optionalArgumentNames[$i].", ";
|
||||
$this->allowedArgumentLists[$i] = substr ($this->allowedArgumentLists[$i], 0, -2);
|
||||
}
|
||||
}
|
||||
|
||||
$this->allowedArgumentLists[count($this->allowedArgumentLists) -1 ] = substr($this->allowedArgumentLists[count($this->allowedArgumentLists) -1 ], 0, -2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the array of all possible sets of method/function arguments
|
||||
*
|
||||
* @return unknown
|
||||
*/
|
||||
public function getValidArgumentLists() {
|
||||
return $this->allowedArgumentLists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the argument list with the greatest possible number of arguments.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMaximumArgumentList() {
|
||||
return end($this->allowedArgumentLists);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write initialisation statemenst for all the variables that might be used
|
||||
*
|
||||
*/
|
||||
public function setInitialisationStatements() {
|
||||
if(count ($this->mandatoryArgumentNames) > 0) {
|
||||
foreach( $this->mandatoryArgumentNames as $name) {
|
||||
$this->initialisationStatements[] = "\$".$name." = ";
|
||||
}
|
||||
}
|
||||
if(count ($this->optionalArgumentNames) > 0) {
|
||||
foreach( $this->optionalArgumentNames as $name) {
|
||||
$this->initialisationStatements[] = "\$".$name." = ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the initialisation statements
|
||||
*
|
||||
* @return unknown
|
||||
*/
|
||||
public function getInitialisationStatements() {
|
||||
return $this->initialisationStatements;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Get a text message
|
||||
*
|
||||
*/
|
||||
class gtText
|
||||
{
|
||||
|
||||
/**
|
||||
* Get the text message and return it
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public static function get($name) {
|
||||
$filename = dirname(__FILE__) . '/texts/' . $name . '.txt';
|
||||
|
||||
if (!file_exists($filename)) {
|
||||
throw new LogicException('The text ' . $name . ' does not exist');
|
||||
}
|
||||
|
||||
return file_get_contents($filename);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
class gtMissingArgumentException extends RuntimeException
|
||||
{
|
||||
}
|
||||
|
||||
?>
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
class gtMissingOptionsException extends RuntimeException
|
||||
{
|
||||
}
|
||||
|
||||
?>
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
|
||||
class gtUnknownOptionException extends RuntimeException
|
||||
{
|
||||
}
|
||||
|
||||
?>
|
@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class gtUnknownSectionException extends RuntimeException
|
||||
{
|
||||
}
|
||||
?>
|
@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Parse command line options
|
||||
*
|
||||
*/
|
||||
class gtCommandLineOptions {
|
||||
|
||||
protected $shortOptions = array(
|
||||
'b',
|
||||
'e',
|
||||
'v',
|
||||
'h',
|
||||
);
|
||||
|
||||
protected $shortOptionsWithArgs = array(
|
||||
'c',
|
||||
'm',
|
||||
'f',
|
||||
'i',
|
||||
's',
|
||||
'x',
|
||||
'k',
|
||||
);
|
||||
|
||||
protected $options;
|
||||
|
||||
protected function isShortOption($arg)
|
||||
{
|
||||
return (substr($arg, 0, 1) == '-') && (substr($arg, 1, 1) != '-');
|
||||
}
|
||||
|
||||
public function isValidOptionArg($array, $index) {
|
||||
if (!isset($array[$index]))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return substr($array[$index], 0, 1) != '-';
|
||||
}
|
||||
|
||||
|
||||
public function parse($argv)
|
||||
{
|
||||
if(count($argv) < 2) {
|
||||
throw new gtMissingOptionsException('Command line options are required');
|
||||
}
|
||||
|
||||
for ($i=1; $i<count($argv); $i++) {
|
||||
|
||||
if ($this->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]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
@ -1,79 +0,0 @@
|
||||
<?php
|
||||
class gtOptionalSections {
|
||||
|
||||
private $optSections = array(
|
||||
'skipif' => 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() {
|
||||
return $this->skipifKey != '';
|
||||
}
|
||||
|
||||
public function hasSkipifExt() {
|
||||
return $this->skipifExt != '';
|
||||
}
|
||||
public function hasIni() {
|
||||
return $this->optSections['ini'];
|
||||
}
|
||||
|
||||
public function hasClean() {
|
||||
return $this->optSections['clean'];
|
||||
}
|
||||
|
||||
public function hasDone() {
|
||||
return $this->optSections['done'];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* parent class for preconditions
|
||||
*
|
||||
*/
|
||||
abstract class gtPreCondition {
|
||||
|
||||
abstract public function check($clo);
|
||||
|
||||
abstract public function getMessage();
|
||||
|
||||
}
|
||||
?>
|
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* List of preconditions.
|
||||
*
|
||||
*/
|
||||
class gtPreConditionList {
|
||||
|
||||
private $preConditions = array(
|
||||
'gtIsSpecifiedTestType',
|
||||
'gtIsSpecifiedFunctionOrMethod',
|
||||
'gtIfClassHasMethod',
|
||||
'gtIsValidClass',
|
||||
'gtIsValidFunction',
|
||||
'gtIsValidMethod',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Create an instance of each pre-condition and run their check methods
|
||||
*
|
||||
*/
|
||||
public function check($clo) {
|
||||
foreach ($this->preConditions as $preCon) {
|
||||
$checkThis = new $preCon;
|
||||
if(!$checkThis->check($clo)) {
|
||||
echo $checkThis->getMessage();
|
||||
die(gtText::get('help'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* If use has requested a class check that method is specified
|
||||
*
|
||||
*/
|
||||
class gtIfClassHasMethod extends gtPreCondition {
|
||||
|
||||
public function check( $clo) {
|
||||
return !$clo->hasOption('c') || $clo->hasOption('m');
|
||||
}
|
||||
|
||||
public function getMessage() {
|
||||
return gtText::get('methodNotSpecified');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Check that either a method or a function is specified
|
||||
*
|
||||
*/
|
||||
class gtIsSpecifiedFunctionOrMethod extends gtPreCondition {
|
||||
|
||||
public function check( $clo) {
|
||||
return $clo->hasOption('f') || $clo->hasOption('m');
|
||||
}
|
||||
|
||||
public function getMessage() {
|
||||
return gtText::get('functionOrMethodNotSpecified');
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Check that b|c|v is specified
|
||||
*
|
||||
*/
|
||||
class gtIsSpecifiedTestType extends gtPreCondition {
|
||||
|
||||
public function check( $clo) {
|
||||
return $clo->hasOption('b') || $clo->hasOption('e') || $clo->hasOption('v');
|
||||
}
|
||||
|
||||
public function getMessage() {
|
||||
return gtText::get('testTypeNotSpecified');
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Check that the class name is valid
|
||||
*
|
||||
*/
|
||||
class gtIsValidClass extends gtPreCondition {
|
||||
|
||||
public function check( $clo) {
|
||||
if($clo->hasOption('c') ) {
|
||||
$className = $clo->getOption('c');
|
||||
return in_array( $className, get_declared_classes() );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getMessage() {
|
||||
return gtText::get('unknownClass');
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,22 +0,0 @@
|
||||
<?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();
|
||||
return in_array( $function, $functions['internal'] );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getMessage() {
|
||||
return gtText::get('unknownFunction');
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,28 +0,0 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class for basic test case construction
|
||||
*/
|
||||
|
||||
abstract class gtBasicTestCase extends gtTestCase {
|
||||
|
||||
protected $subject;
|
||||
|
||||
|
||||
/**
|
||||
* Returns an instance of a test case for a method or a function
|
||||
*
|
||||
* @param string $type
|
||||
* @return test case object
|
||||
*/
|
||||
public static function getInstance($optionalSections, $type = 'function') {
|
||||
if($type == 'function') {
|
||||
return new gtBasicTestCaseFunction($optionalSections);
|
||||
}
|
||||
if($type =='method') {
|
||||
return new gtBasicTestCaseMethod($optionalSections);
|
||||
}
|
||||
}
|
||||
|
||||
public function constructSubjectCalls() {
|
||||
$this->argInit();
|
||||
$this->subjectCalls();
|
||||
}
|
||||
|
||||
public function addBasicEcho() {
|
||||
$this->testCase[] = "echo \"*** Test by calling method or function with its expected arguments ***\\n\";";
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Basic test case for a PHP function
|
||||
*
|
||||
*/
|
||||
class gtBasicTestCaseFunction extends gtBasicTestCase {
|
||||
|
||||
|
||||
public function __construct($opt) {
|
||||
$this->optionalSections = $opt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the function name
|
||||
*
|
||||
* @param gtFunction $function
|
||||
*/
|
||||
public function setFunction($function) {
|
||||
$this->subject = $function;
|
||||
}
|
||||
|
||||
public function constructTestCase() {
|
||||
$this->constructCommonHeaders();
|
||||
|
||||
$this->addBasicEcho();
|
||||
|
||||
$this->constructSubjectCalls();
|
||||
|
||||
$this->constructCommonClosing();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct test case header
|
||||
*
|
||||
*/
|
||||
public function testHeader() {
|
||||
//Opening section and start of test case array.
|
||||
$this->testCase[] = "--TEST--";
|
||||
$this->testCase[] = "Test function ".$this->subject->getName()."() by calling it with its expected arguments";
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the test section to call the function
|
||||
*
|
||||
*/
|
||||
public function subjectCalls() {
|
||||
// Construct the argument list to pass to the function being tested
|
||||
$lists = $this->subject->getValidArgumentLists();
|
||||
|
||||
foreach($lists as $list){
|
||||
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
|
||||
$this->testCase[] = "var_dump(".$this->subject->getName()."( ".$list." ) );";
|
||||
}
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class for basic test case construction for class methods
|
||||
*/
|
||||
class gtBasicTestCaseMethod extends gtBasicTestCase {
|
||||
|
||||
public function __construct($opt) {
|
||||
$this->optionalSections = $opt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the method
|
||||
*
|
||||
* @param gtMethod $method
|
||||
*/
|
||||
public function setMethod($method) {
|
||||
$this->subject = $method;
|
||||
}
|
||||
|
||||
public function constructTestCase() {
|
||||
$this->constructCommonHeaders();
|
||||
|
||||
$this->addBasicEcho();
|
||||
|
||||
$this->constructorArgInit();
|
||||
$this->constructorCreateInstance();
|
||||
|
||||
$this->constructSubjectCalls();
|
||||
|
||||
$this->constructCommonClosing();
|
||||
|
||||
}
|
||||
|
||||
public function testHeader() {
|
||||
$this->testCase[] = "--TEST--";
|
||||
$this->testCase[] = "Test class ".$this->subject->getClassName()." method ".$this->subject->getName()."() by calling it with its expected arguments";
|
||||
|
||||
}
|
||||
|
||||
public function subjectCalls() {
|
||||
$lists = $this->subject->getValidArgumentLists();
|
||||
|
||||
foreach($lists as $list){
|
||||
$this->testCase[] = "var_dump( \$class->".$this->subject->getName()."( ".$list." ) );";
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
|
||||
}
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class for simple errors - one too many args and one too few
|
||||
*/
|
||||
|
||||
abstract class gtErrorTestCase extends gtTestCase {
|
||||
|
||||
protected $shortArgumentList = '';
|
||||
protected $longArgumentList = '';
|
||||
|
||||
|
||||
/**
|
||||
* Return instance of either method or function error test case
|
||||
*
|
||||
* @param string $type
|
||||
* @return test case object
|
||||
*/
|
||||
public static function getInstance($optionalSections, $type = 'function') {
|
||||
|
||||
if($type == 'function') {
|
||||
return new gtErrorTestCaseFunction($optionalSections);
|
||||
}
|
||||
if($type =='method') {
|
||||
return new gtErrorTestCaseMethod($optionalSections);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getShortArgumentList() {
|
||||
return $this->shortArgumentList;
|
||||
}
|
||||
|
||||
public function getLongArgumentList() {
|
||||
return $this->longArgumentList;
|
||||
}
|
||||
|
||||
public function constructSubjectCalls() {
|
||||
$this->argInit();
|
||||
|
||||
//Initialise the additional argument
|
||||
$this->testCase[] = "\$extra_arg = ";
|
||||
|
||||
$this->subjectCalls();
|
||||
}
|
||||
|
||||
public function addErrorEcho() {
|
||||
$this->testCase[] = "echo \"*** Test by calling method or function with incorrect numbers of arguments ***\\n\";";
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Error test case for a PHP function
|
||||
*
|
||||
*/
|
||||
class gtErrorTestCaseFunction extends gtErrorTestCase {
|
||||
|
||||
public function __construct($opt) {
|
||||
$this->optionalSections = $opt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the function name
|
||||
*
|
||||
* @param string $function
|
||||
*/
|
||||
public function setFunction($function) {
|
||||
$this->subject = $function;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct the test case as an array of strings
|
||||
*
|
||||
*/
|
||||
public function constructTestCase() {
|
||||
$this->constructCommonHeaders();
|
||||
|
||||
$this->addErrorEcho();
|
||||
|
||||
$this->constructSubjectCalls();
|
||||
|
||||
$this->constructCommonClosing();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testHeader() {
|
||||
$this->testCase[] = "--TEST--";
|
||||
$this->testCase[] = "Test function ".$this->subject->getName()."() by calling it more than or less than its expected arguments";
|
||||
}
|
||||
|
||||
public function subjectCalls() {
|
||||
// Construct the argument lists to pass to the function being tested
|
||||
$list = $this->subject->getExtraArgumentList();
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
|
||||
$this->testCase[] = "var_dump(".$this->subject->getName()."( ".$list." ) );";
|
||||
|
||||
$list = $this->subject->getShortArgumentList();
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
|
||||
$this->testCase[] = "var_dump(".$this->subject->getName()."( ".$list." ) );";
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Error test case for a PHP method
|
||||
*
|
||||
*/
|
||||
class gtErrorTestCaseMethod extends gtErrorTestCase {
|
||||
|
||||
public function __construct($opt) {
|
||||
$this->optionalSections = $opt;
|
||||
}
|
||||
private $method;
|
||||
|
||||
/**
|
||||
* Set the method name
|
||||
*
|
||||
* @param string $method
|
||||
*/
|
||||
public function setMethod($method) {
|
||||
$this->subject = $method;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct the test case as an array of strings
|
||||
*
|
||||
*/
|
||||
public function constructTestCase() {
|
||||
$this->constructCommonHeaders();
|
||||
|
||||
$this->addErrorEcho();
|
||||
|
||||
$this->constructorArgInit();
|
||||
$this->constructorCreateInstance();
|
||||
|
||||
$this->constructSubjectCalls();
|
||||
|
||||
$this->constructCommonClosing();
|
||||
}
|
||||
|
||||
public function testHeader() {
|
||||
$this->testCase[] = "--TEST--";
|
||||
$this->testCase[] = "Test class ".$this->subject->getClassName()." method ".$this->subject->getName()."() by calling it more than or less than its expected arguments";
|
||||
}
|
||||
|
||||
public function subjectCalls() {
|
||||
|
||||
// Construct the argument list to pass to the method being tested
|
||||
$list = $this->subject->getExtraArgumentList();
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
|
||||
$this->testCase[] = "var_dump(".$this->subject->getName()."( ".$list." ) );";
|
||||
|
||||
$list = $this->subject->getShortArgumentList();
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
|
||||
$this->testCase[] = "var_dump(".$this->subject->getName()."( ".$list." ) );";
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,230 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class for all test cases
|
||||
*/
|
||||
abstract class gtTestCase {
|
||||
|
||||
|
||||
/**
|
||||
* The subject of the test, may be either a function (gtFunction) or a method (gtMethod)
|
||||
*
|
||||
* @var gtMethod or gtFunction
|
||||
*/
|
||||
protected $subject;
|
||||
|
||||
|
||||
/**
|
||||
* Arry of strings containing the test case
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $testCase;
|
||||
|
||||
|
||||
/**
|
||||
* Object containing the optional sections that may be added to the test case
|
||||
*
|
||||
* @var gtOptionalSections
|
||||
*/
|
||||
protected $optionalSections;
|
||||
|
||||
|
||||
/**
|
||||
* Convert test case from array to string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString() {
|
||||
$testCaseString = "";
|
||||
foreach($this->testCase as $line) {
|
||||
$testCaseString .= $line."\n";
|
||||
}
|
||||
return $testCaseString;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns test case as a array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTestCase() {
|
||||
return $this->testCase;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct the common headers (title, file section..) of the test case
|
||||
*
|
||||
*/
|
||||
public function ConstructCommonHeaders() {
|
||||
$this->testHeader();
|
||||
|
||||
if($this->optionalSections->hasSkipif()) {
|
||||
$this->addSkipif();
|
||||
}
|
||||
|
||||
if($this->optionalSections->hasIni()) {
|
||||
$this->addIni();
|
||||
}
|
||||
|
||||
$this->fileOpening();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct the common closing statements (clean, done, EXPECTF...)
|
||||
*
|
||||
*/
|
||||
public function ConstructCommonClosing() {
|
||||
$this->fileClosing();
|
||||
|
||||
if ($this->optionalSections->hasDone()) {
|
||||
$this->addDone();
|
||||
}
|
||||
|
||||
if ($this->optionalSections->hasClean()) {
|
||||
$this->addClean();
|
||||
}
|
||||
|
||||
$this->addExpectf();
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the FILE section of the test
|
||||
*
|
||||
*/
|
||||
public function fileOpening() {
|
||||
$this->testCase[] = "--FILE--";
|
||||
$this->testCase[] = "<?php";
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add constructor argument initialisation to test case
|
||||
*
|
||||
*/
|
||||
public function constructorArgInit() {
|
||||
$conStatements = $this->subject->getConstructorInitStatements();
|
||||
foreach($conStatements as $statement) {
|
||||
$this->testCase[] = $statement;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create instance of class in the test case
|
||||
*
|
||||
*/
|
||||
public function constructorCreateInstance() {
|
||||
$constructorList = $this->subject->getConstructorArgumentList();
|
||||
$this->testCase[] = "\$class = new ".$this->subject->getClassName()."( ".$constructorList." );";
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add function or method initilaisation statements to the test case
|
||||
*
|
||||
*/
|
||||
public function argInit() {
|
||||
$statements = $this->subject->getInitialisationStatements();
|
||||
foreach($statements as $statement) {
|
||||
$this->testCase[] = $statement;
|
||||
}
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add FILE section closing tag to the test case
|
||||
*
|
||||
*/
|
||||
public function fileClosing() {
|
||||
$this->testCase[] = "?>";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a skipif section to the test case
|
||||
*
|
||||
*/
|
||||
public function addSkipif() {
|
||||
$this->testCase[] = "--SKIPIF--";
|
||||
$this->testCase[] = "<?php";
|
||||
if($this->optionalSections->hasSkipifKey()) {
|
||||
$key = $this->optionalSections->getSkipifKey();
|
||||
//test standard skipif sections
|
||||
if($key == 'win') {
|
||||
$this->testCase = gtCodeSnippet::append('skipifwin', $this->testCase);
|
||||
}
|
||||
if($key == 'notwin' ) {
|
||||
$this->testCase = gtCodeSnippet::append('skipifnotwin', $this->testCase);
|
||||
}
|
||||
|
||||
if($key == '64b' ) {
|
||||
$this->testCase = gtCodeSnippet::append('skipif64b', $this->testCase);
|
||||
}
|
||||
|
||||
if($key == 'not64b' ) {
|
||||
$this->testCase = gtCodeSnippet::append('skipifnot64b', $this->testCase);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->optionalSections->hasSkipifExt()) {
|
||||
$ext = $this->optionalSections->getSkipifExt();
|
||||
$this->testCase[] = "if (!extension_loaded('$ext')) die ('skip $ext extension not available in this build');";
|
||||
}
|
||||
$this->testCase[] = "?>";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add an INI section to the test case
|
||||
*
|
||||
*/
|
||||
public function addIni() {
|
||||
$this->testCase[] = "--INI--";
|
||||
$this->testCase[] = "";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a clean section to the test case
|
||||
*
|
||||
*/
|
||||
public function addClean() {
|
||||
$this->testCase[] = "--CLEAN--";
|
||||
$this->testCase[] = "<?php";
|
||||
$this->testCase[] = "?>";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a ===DONE=== statement to the test case
|
||||
*
|
||||
*/
|
||||
public function addDone() {
|
||||
$this->testCase[] = "===DONE===";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add an EXPECTF section
|
||||
*
|
||||
*/
|
||||
public function addExpectf() {
|
||||
$this->testCase[] = "--EXPECTF--";
|
||||
if ($this->optionalSections->hasDone() ){
|
||||
$this->testCase[] = '===DONE===';
|
||||
}
|
||||
}
|
||||
|
||||
public function getOpt() {
|
||||
return $this->optionalSections;
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Container for all possible variation test cases
|
||||
*/
|
||||
abstract class gtVariationContainer {
|
||||
|
||||
protected $variationTests;
|
||||
|
||||
protected $dataTypes = array (
|
||||
'array',
|
||||
'boolean',
|
||||
'emptyUnsetUndefNull',
|
||||
'float',
|
||||
'int',
|
||||
'object',
|
||||
'string',
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return an instance of a containers for either function or method tests
|
||||
*
|
||||
* @param string $type
|
||||
* @return variation test container
|
||||
*/
|
||||
public static function getInstance ($optionalSections, $type = 'function') {
|
||||
|
||||
if($type == 'function') {
|
||||
return new gtVariationContainerFunction($optionalSections);
|
||||
}
|
||||
if($type =='method') {
|
||||
return new gtVariationContainerMethod($optionalSections);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function constructAll() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns all varaition tests as an array of arrays
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVariationTests() {
|
||||
return $this->variationTests;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Container for all possible variation test cases of functions
|
||||
*/
|
||||
class gtVariationContainerFunction extends gtVariationContainer {
|
||||
|
||||
protected $function;
|
||||
protected $optionalSections;
|
||||
|
||||
public function __construct($osl) {
|
||||
$this->optionalSections = $osl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets function being tested
|
||||
*
|
||||
* @param gtFunction $function
|
||||
*/
|
||||
public function setFunction(gtFunction $function) {
|
||||
$this->function = $function;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* constructs all possible variation testcases in array $this->variationTests
|
||||
*
|
||||
*/
|
||||
public function constructAll() {
|
||||
|
||||
|
||||
$numberOfArguments = count($this->function->getMandatoryArgumentNames()) + count($this->function->getOptionalArgumentNames());
|
||||
for($i = 1; $i <= $numberOfArguments; $i++) {
|
||||
foreach ($this->dataTypes as $d) {
|
||||
$testCase = gtVariationTestCase::getInstance($this->optionalSections);
|
||||
$testCase->setUp($this->function, $i, $d);
|
||||
$testCase->constructTestCase();
|
||||
$this->variationTests[] = $testCase->toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Container for all possible variation test cases for a method
|
||||
*/
|
||||
class gtVariationContainerMethod extends gtVariationContainer {
|
||||
|
||||
protected $method;
|
||||
protected $optionalSections;
|
||||
|
||||
public function __construct($osl) {
|
||||
$this->optionalSections = $osl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the method to be tested
|
||||
*
|
||||
* @param gtMethod $method
|
||||
*/
|
||||
public function setMethod(gtMethod $method) {
|
||||
$this->method = $method;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs all variation tests in $this_variationTests
|
||||
*
|
||||
*/
|
||||
public function constructAll() {
|
||||
|
||||
$numberOfArguments = count($this->method->getMandatoryArgumentNames()) + count($this->method->getOptionalArgumentNames());
|
||||
|
||||
for($i = 1; $i <= $numberOfArguments; $i++) {
|
||||
|
||||
foreach ($this->dataTypes as $d) {
|
||||
|
||||
$testCase = gtVariationTestCase::getInstance($this->optionalSections, 'method');
|
||||
$testCase->setUp($this->method, $i, $d);
|
||||
$testCase->constructTestCase();
|
||||
$this->variationTests[] = $testCase->toString();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,55 +0,0 @@
|
||||
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class for extended variations. Needs 'data type' and argument to vary
|
||||
*/
|
||||
|
||||
abstract class gtVariationTestCase extends gtTestCase {
|
||||
|
||||
|
||||
/**
|
||||
* Returns an instance of a test case for a method or a function
|
||||
*
|
||||
* @param string $type
|
||||
* @return test case object
|
||||
*/
|
||||
public static function getInstance($optionalSections, $type = 'function') {
|
||||
|
||||
if($type == 'function') {
|
||||
return new gtVariationTestCaseFunction($optionalSections);
|
||||
}
|
||||
if($type =='method') {
|
||||
return new gtVariationTestCaseMethod($optionalSections);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function argInitVariation() {
|
||||
$statements = $this->subject->getInitialisationStatements();
|
||||
for($i=0; $i<count($statements); $i++) {
|
||||
if($i != ( $this->argumentNumber -1) ) {
|
||||
$this->testCase[] = $statements[$i];
|
||||
}
|
||||
}
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
|
||||
}
|
||||
|
||||
public function addVariationCode() {
|
||||
$this->testCase = gtCodeSnippet::append($this->variationData, $this->testCase);
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
|
||||
}
|
||||
|
||||
public function constructSubjectCalls() {
|
||||
$this->argInitVariation();
|
||||
$this->addVariationCode();
|
||||
$this->subjectCalls();
|
||||
}
|
||||
|
||||
public function addVariationEcho() {
|
||||
$this->testCase[] = "echo \"*** Test substituting argument ".$this->argumentNumber." with ".$this->variationData." values ***\\n\";";
|
||||
$this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class for variation tests for a PHP function
|
||||
*/
|
||||
class gtVariationTestCaseFunction extends gtVariationTestCase {
|
||||
|
||||
protected $argumentNumber;
|
||||
protected $variationData;
|
||||
protected $testCase;
|
||||
|
||||
public function __construct($opt) {
|
||||
$this->optionalSections = $opt;
|
||||
}
|
||||
/**
|
||||
* Set data neede to construct variation tests
|
||||
*
|
||||
* @param gtfunction $function
|
||||
* @param string $argumentNumber
|
||||
* @param string $variationData
|
||||
*/
|
||||
public function setUp(gtfunction $function, $argumentNumber, $variationData) {
|
||||
$this->subject = $function;
|
||||
$this->argumentNumber = $argumentNumber;
|
||||
$this->variationData = $variationData;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs the test case as a array of strings
|
||||
*
|
||||
*/
|
||||
public function constructTestCase() {
|
||||
$this->constructCommonHeaders();
|
||||
|
||||
$this->addVariationEcho();
|
||||
|
||||
$this->constructSubjectCalls();
|
||||
|
||||
$this->constructCommonClosing();
|
||||
|
||||
}
|
||||
public function testHeader() {
|
||||
$this->testCase[] = "--TEST--";
|
||||
$this->testCase[] = "Test function ".$this->subject->getName()."() by substituting argument ".$this->argumentNumber." with ".$this->variationData." values.";
|
||||
}
|
||||
|
||||
|
||||
public function subjectCalls() {
|
||||
$this->testCase = gtCodeSnippet::append('loopStart', $this->testCase);
|
||||
|
||||
// Construct the argument list to pass to the function being tested
|
||||
$argumentList = explode(",", $this->subject->getMaximumArgumentList());
|
||||
$argumentList[$this->argumentNumber -1 ] = "\$var ";
|
||||
$list = implode(", ", $argumentList);
|
||||
|
||||
|
||||
$this->testCase[] = " var_dump(".$this->subject->getName()."( ".$list." ) );";
|
||||
$this->testCase = gtCodeSnippet::append('loopClose', $this->testCase);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,68 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class for variation tests for a PHP method
|
||||
*/
|
||||
class gtVariationTestCaseMethod extends gtVariationTestCase {
|
||||
|
||||
protected $subject;
|
||||
protected $argumentNumber;
|
||||
protected $variationData;
|
||||
protected $testCase;
|
||||
|
||||
public function __construct($opt) {
|
||||
$this->optionalSections = $opt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set data neede to construct variation tests
|
||||
*
|
||||
* @param gtMethod $method
|
||||
* @param string $argumentNumber
|
||||
* @param string $variationData
|
||||
*/
|
||||
public function setUp(gtMethod $method, $argumentNumber, $variationData) {
|
||||
$this->subject = $method;
|
||||
$this->argumentNumber = $argumentNumber;
|
||||
$this->variationData = $variationData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs the test case as a array of strings
|
||||
*
|
||||
*/
|
||||
public function constructTestCase() {
|
||||
$this->constructCommonHeaders();
|
||||
|
||||
$this->addVariationEcho();
|
||||
|
||||
$this->constructorArgInit();
|
||||
$this->constructorCreateInstance();
|
||||
|
||||
$this->constructSubjectcalls();
|
||||
$this->constructCommonClosing();
|
||||
|
||||
}
|
||||
|
||||
public function testHeader() {
|
||||
$this->testCase[] = "--TEST--";
|
||||
$this->testCase[] = "Test class ".$this->subject->getClassName()." method ".$this->subject->getName()."() by substituting argument ".$this->argumentNumber." with ".$this->variationData." values.";
|
||||
}
|
||||
|
||||
public function subjectCalls() {
|
||||
$this->testCase = gtCodeSnippet::append('loopStart', $this->testCase);
|
||||
// Construct the argument list to pass to the method being tested
|
||||
$argumentList = explode(",", $this->subject->getMaximumArgumentList());
|
||||
$argumentList[$this->argumentNumber -1 ] = "\$var ";
|
||||
$list = implode(", ", $argumentList);
|
||||
|
||||
|
||||
$this->testCase[] = " var_dump(\$class->".$this->subject->getName()."( ".$list." ) );";
|
||||
$this->testCase = gtCodeSnippet::append('loopClose', $this->testCase);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -1,3 +0,0 @@
|
||||
|
||||
Please supply a function or method name to be tested.
|
||||
|
@ -1,14 +0,0 @@
|
||||
Usage:
|
||||
php generate-phpt.php -f <function_name> |-c <class_name> -m <method_name> -b|e|v [-s skipif:ini:clean:done] [-k win|notwin|64b|not64b] [-x ext]
|
||||
|
||||
Where:
|
||||
-f function_name ................. Name of PHP function, eg cos
|
||||
-c class name .....................Name of class, eg DOMDocument
|
||||
-m method name ....................Name of method, eg createAttribute
|
||||
-b ............................... Generate basic tests
|
||||
-e ............................... Generate error tests
|
||||
-v ............................... Generate variation tests
|
||||
-s sections....................... Create optional sections, colon separated list
|
||||
-k skipif key..................... Skipif option, only used if -s skipif is used.
|
||||
-x extension.......................Skipif option, specify extension to check for
|
||||
-h ............................... Print this message
|
@ -1,4 +0,0 @@
|
||||
|
||||
You have given a class name but not supplied a method name to test.
|
||||
The method name is required.
|
||||
|
@ -1,3 +0,0 @@
|
||||
|
||||
Please specify basic, error or variation tests.
|
||||
|
@ -1,4 +0,0 @@
|
||||
|
||||
The class name is not a valid PHP class name.
|
||||
Check that the extension containing the class is loaded.
|
||||
|
@ -1,4 +0,0 @@
|
||||
|
||||
The function name is not a valid PHP function name.
|
||||
Check that the extension containing the function is loaded.
|
||||
|
@ -1,4 +0,0 @@
|
||||
|
||||
The method name is not a valid PHP method name.
|
||||
Check that the extension containing the method is loaded.
|
||||
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
class gtBasicTestCaseFunctionTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
|
||||
public function testTestCase() {
|
||||
|
||||
$f = new gtFunction('cos');
|
||||
$f->setArgumentNames();
|
||||
$f->setArgumentLists();
|
||||
$f->setInitialisationStatements();
|
||||
$optSect = new gtOptionalSections();
|
||||
|
||||
$btc = gtBasicTestCase::getInstance($optSect);
|
||||
$btc->setFunction($f);
|
||||
$btc->constructTestCase();
|
||||
|
||||
$fs = $btc->toString();
|
||||
$this->assertTrue(is_string($fs));
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
class gtBasicTestCaseMethodTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
|
||||
public function testTestCase() {
|
||||
|
||||
$f = new gtMethod('DOMDocument','createAttribute');
|
||||
$f->setArgumentNames();
|
||||
$f->setArgumentLists();
|
||||
$f->setInitialisationStatements();
|
||||
$f->setConstructorArgumentNames();
|
||||
$f->setConstructorInitStatements();
|
||||
|
||||
$optSect = new gtOptionalSections();
|
||||
$btc = gtBasicTestCaseMethod::getInstance($optSect, 'method');
|
||||
$btc->setMethod($f);
|
||||
$btc->constructTestCase();
|
||||
|
||||
|
||||
$fs = $btc->toString();
|
||||
$this->assertTrue(is_string($fs));
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
|
||||
class gtCodeSnippetTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testAppend() {
|
||||
$array = array('something', 'nothing');
|
||||
$array = gtCodeSnippet::append('loopClose', $array);
|
||||
$this->assertEquals($array[2], '}');
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
|
||||
class gtCommandLineOptionsTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testNoOption() {
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php'));
|
||||
}
|
||||
|
||||
public function testShortOption() {
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-h'));
|
||||
$this->assertTrue($clo->hasOption('h'));
|
||||
}
|
||||
|
||||
public function testShortOptionArgument() {
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-f', 'some-function'));
|
||||
$this->assertTrue($clo->hasOption('f'));
|
||||
$this->assertEquals('some-function', $clo->getOption('f'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testInvalidOption() {
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-z'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testMissingArgument() {
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-f'));
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
class gtErrorTestCaseFunctionTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
|
||||
public function testTestCase() {
|
||||
|
||||
$f = new gtFunction('cos');
|
||||
$f->setArgumentNames();
|
||||
$f->setArgumentLists();
|
||||
$f->setInitialisationStatements();
|
||||
|
||||
$optSect = new gtOptionalSections();
|
||||
|
||||
$btc = gtErrorTestCase::getInstance($optSect);
|
||||
$btc->setFunction($f);
|
||||
$btc->constructTestCase();
|
||||
|
||||
|
||||
$fs = $btc->toString();
|
||||
$this->assertTrue(is_string($fs));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
class gtErrorTestCaseMethodTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
|
||||
public function testTestCase() {
|
||||
|
||||
$f = new gtMethod('DOMDocument', 'createAttribute');
|
||||
$f->setArgumentNames();
|
||||
$f->setArgumentLists();
|
||||
|
||||
$f->setInitialisationStatements();
|
||||
|
||||
$f->setConstructorArgumentNames();
|
||||
$f->setConstructorInitStatements();
|
||||
|
||||
$optSect = new gtOptionalSections();
|
||||
|
||||
$btc = gtErrorTestCase::getInstance($optSect,'method');
|
||||
$btc->setMethod($f);
|
||||
$btc->constructTestCase();
|
||||
|
||||
|
||||
$fs = $btc->toString();
|
||||
$this->assertTrue(is_string($fs));
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,71 +0,0 @@
|
||||
cd
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
|
||||
class gtFunctionTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testArguments() {
|
||||
|
||||
$f = new gtFunction('cos');
|
||||
$f->setArgumentNames();
|
||||
$m = $f->getMandatoryArgumentNames();
|
||||
$this->assertEquals($m[0], 'number');
|
||||
}
|
||||
|
||||
public function testArguments2() {
|
||||
|
||||
$f = new gtFunction('version_compare');
|
||||
$f->setArgumentNames();
|
||||
$m = $f->getMandatoryArgumentNames();
|
||||
$o = $f->getOptionalArgumentNames();
|
||||
$this->assertEquals($m[0], 'ver1');
|
||||
$this->assertEquals($m[1], 'ver2');
|
||||
$this->assertEquals($o[0], 'oper');
|
||||
|
||||
}
|
||||
|
||||
public function testExtraArguments() {
|
||||
|
||||
$f = new gtFunction('version_compare');
|
||||
$f->setArgumentNames();
|
||||
$f->setExtraArgumentList();
|
||||
|
||||
$this->assertEquals('$ver1, $ver2, $oper, $extra_arg', $f->getExtraArgumentList());
|
||||
}
|
||||
|
||||
public function testShortArguments() {
|
||||
|
||||
$f = new gtFunction('version_compare');
|
||||
$f->setArgumentNames();
|
||||
$f->setShortArgumentList();
|
||||
|
||||
$this->assertEquals('$ver1', $f->getShortArgumentList());
|
||||
}
|
||||
|
||||
public function testAllArgumentList() {
|
||||
|
||||
$f = new gtFunction('version_compare');
|
||||
$f->setArgumentNames();
|
||||
$f->setValidArgumentLists();
|
||||
$a = $f->getValidArgumentLists();
|
||||
|
||||
$this->assertEquals('$ver1, $ver2', $a[0]);
|
||||
$this->assertEquals('$ver1, $ver2, $oper', $a[1]);
|
||||
}
|
||||
|
||||
public function testInitialisation() {
|
||||
|
||||
$f = new gtFunction('version_compare');
|
||||
$f->setArgumentNames();
|
||||
$f->setInitialisationStatements();
|
||||
$a = $f->getInitialisationStatements();
|
||||
|
||||
$this->assertEquals('$ver1 = ', $a[0]);
|
||||
$this->assertEquals('$ver2 = ', $a[1]);
|
||||
$this->assertEquals('$oper = ', $a[2]);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
|
||||
class gtIfClassHasMethodTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testValid() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-c', 'blah', '-m', 'blah'));
|
||||
$ch = new gtIfClassHasMethod();
|
||||
$this->assertTrue($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testNotValid() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-c', 'blah'));
|
||||
$ch = new gtIfClassHasMethod();
|
||||
$this->assertFalse($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testNotSpecified() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-b'));
|
||||
$ch = new gtIfClassHasMethod();
|
||||
$this->assertTrue($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testMessage() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-c', 'blah'));
|
||||
$ch = new gtIfClassHasMethod();
|
||||
$this->assertEquals($ch->getMessage(), gtText::get('methodNotSpecified'));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
|
||||
class gtIsSpecifiedFunctionOrMethodTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testValid() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-m', 'blah'));
|
||||
$ch = new gtIsSpecifiedFunctionOrMethod();
|
||||
$this->assertTrue($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testValid2() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-f', 'blah'));
|
||||
$ch = new gtIsSpecifiedFunctionOrMethod();
|
||||
$this->assertTrue($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testNotValid() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-b'));
|
||||
$ch = new gtIsSpecifiedFunctionOrMethod();
|
||||
$this->assertFalse($ch->check($clo));
|
||||
|
||||
}
|
||||
|
||||
public function testMessage() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-c', 'blah'));
|
||||
$ch = new gtIsSpecifiedFunctionOrMethod();
|
||||
$this->assertEquals($ch->getMessage(), gtText::get('functionOrMethodNotSpecified'));
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,32 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
|
||||
class gtIsSpecifiedTestTypeTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testValid() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-c', 'DOMDocument','-b'));
|
||||
$ch = new gtIsSpecifiedTestType();
|
||||
$this->assertTrue($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testNotValid() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-c', 'DOMDocument'));
|
||||
$ch = new gtIsSpecifiedTestType();
|
||||
$this->assertFalse($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testMessage() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-c', 'blah'));
|
||||
$ch = new gtIsSpecifiedtestType();
|
||||
$this->assertEquals($ch->getMessage(), gtText::get('testTypeNotSpecified'));
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
|
||||
class gtIsValidClassTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testValid() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-c', 'DOMDocument'));
|
||||
$ch = new gtIsValidClass();
|
||||
$this->assertTrue($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testNotValid() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-c', 'blah'));
|
||||
$ch = new gtIsValidClass();
|
||||
$this->assertFalse($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testNotGiven() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php','-b'));
|
||||
$ch = new gtIsValidClass();
|
||||
$this->assertTrue($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testMessage() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-c', 'blah'));
|
||||
$ch = new gtIsvalidClass();
|
||||
$this->assertEquals($ch->getMessage(), gtText::get('unknownClass'));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
|
||||
class gtIsValidFunctionTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testValid() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-f', 'cos'));
|
||||
$ch = new gtIsValidFunction();
|
||||
$this->assertTrue($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testNotValid() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-f', 'blah'));
|
||||
$ch = new gtIsValidFunction();
|
||||
$this->assertFalse($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testNotSupplied() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php','-b'));
|
||||
$ch = new gtIsValidFunction();
|
||||
$this->assertTrue($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testMessage() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-c', 'blah'));
|
||||
$ch = new gtIsvalidFunction();
|
||||
$this->assertEquals($ch->getMessage(), gtText::get('unknownFunction'));
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,40 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
|
||||
class gtIsValidMethodTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testValid() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-c', 'DOMDocument', '-m', 'createAttribute'));
|
||||
$ch = new gtIsValidMethod();
|
||||
$this->assertTrue($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testNotValid() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-c', 'DOMDocument', '-m', 'blah'));
|
||||
$ch = new gtIsValidMethod();
|
||||
$this->assertFalse($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testNotGiven() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php','-b'));
|
||||
$ch = new gtIsValidMethod();
|
||||
$this->assertTrue($ch->check($clo));
|
||||
}
|
||||
|
||||
public function testMessage() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-c', 'blah'));
|
||||
$ch = new gtIsvalidMethod();
|
||||
$this->assertEquals($ch->getMessage(), gtText::get('unknownMethod'));
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,82 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
|
||||
class gtMethodTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testGetParams() {
|
||||
$m = new gtMethod('DOMDocument', 'createAttribute');
|
||||
$m->setArgumentNames();
|
||||
$a = $m->getMandatoryArgumentNames();
|
||||
$this->assertEquals($a[0], 'name');
|
||||
}
|
||||
|
||||
public function testConstructor() {
|
||||
$m = new gtMethod('DOMDocument', 'createAttribute');
|
||||
$m->setConstructorArgumentNames();
|
||||
$a = $m->getConstructorArgumentNames();
|
||||
$this->assertEquals($a[0], 'version');
|
||||
$this->assertEquals($a[1], 'encoding');
|
||||
}
|
||||
|
||||
public function testExtraParamList() {
|
||||
$m = new gtMethod('DOMDocument', 'createAttribute');
|
||||
$m->setArgumentNames();
|
||||
$m->setExtraArgumentList();
|
||||
$this->assertEquals('$name, $extra_arg',$m->getExtraArgumentList());
|
||||
}
|
||||
|
||||
public function testShortParamList() {
|
||||
$m = new gtMethod('DOMDocument', 'createAttribute');
|
||||
$m->setArgumentNames();
|
||||
$m->setShortArgumentList();
|
||||
$this->assertEquals('',$m->getShortArgumentList());
|
||||
}
|
||||
|
||||
public function testAllParamList() {
|
||||
$m = new gtMethod('DOMDocument', 'createAttribute');
|
||||
$m->setArgumentNames();
|
||||
$m->setValidArgumentLists();
|
||||
$a = $m->getValidArgumentLists();
|
||||
$this->assertEquals('$name',$a[0]);
|
||||
}
|
||||
|
||||
public function testMaxParamList() {
|
||||
$m = new gtMethod('DOMDocument', 'createAttribute');
|
||||
$m->setArgumentNames();
|
||||
$m->setValidArgumentLists();
|
||||
$this->assertEquals('$name',$m->getMaximumArgumentList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testConstructorList() {
|
||||
$m = new gtMethod('Phar', 'buildFromDirectory');
|
||||
$m->setArgumentNames();
|
||||
$m->setConstructorArgumentNames();
|
||||
|
||||
$m->setConstructorArgumentList();
|
||||
$this->assertEquals('$filename, $flags, $alias, $fileformat',$m->getConstructorArgumentList());
|
||||
|
||||
}
|
||||
|
||||
public function testConstructorInit() {
|
||||
$m = new gtMethod('Phar', 'buildFromDirectory');
|
||||
$m->setArgumentNames();
|
||||
$m->setConstructorArgumentNames();
|
||||
|
||||
$m->setConstructorInitStatements();
|
||||
$a = $m->getConstructorInitStatements();
|
||||
$this->assertEquals('$filename = ',$a[0]);
|
||||
$this->assertEquals('$flags = ',$a[1]);
|
||||
$this->assertEquals('$alias = ',$a[2]);
|
||||
$this->assertEquals('$fileformat = ',$a[3]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -1,58 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
|
||||
class gtOptionalSectionsTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testBasic() {
|
||||
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-s', 'skipif:ini'));
|
||||
|
||||
$opt = new gtOptionalSections();
|
||||
$opt->setOptions($clo);
|
||||
$a = $opt->getOptions();
|
||||
$this->assertEquals(true, $a['skipif']);
|
||||
$this->assertEquals(true, $a['ini']);
|
||||
$this->assertEquals(false, $a['clean']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
*/
|
||||
public function testException() {
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-s', 'blah'));
|
||||
$opt = new gtOptionalSections();
|
||||
$opt->setOptions($clo);
|
||||
}
|
||||
|
||||
public function testSkip() {
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-s', 'skipif', '-x', 'standard'));
|
||||
$opt = new gtOptionalSections();
|
||||
$opt->setOptions($clo);
|
||||
|
||||
$opt = new gtOptionalSections();
|
||||
$opt->setOptions($clo);
|
||||
|
||||
$this->assertEquals('standard', $opt->getSkipifExt() );
|
||||
|
||||
}
|
||||
|
||||
public function testSkipKey() {
|
||||
$clo = new gtCommandLineOptions();
|
||||
$clo->parse(array('generate-phpt.php', '-s', 'skipif', '-k', 'win'));
|
||||
$opt = new gtOptionalSections();
|
||||
$opt->setOptions($clo);
|
||||
|
||||
$opt = new gtOptionalSections();
|
||||
$opt->setOptions($clo);
|
||||
|
||||
$this->assertEquals('win', $opt->getSkipifKey() );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -1,59 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
class gtVariationTestCaseFunctionTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testTestCase() {
|
||||
|
||||
$f = new gtFunction('cos');
|
||||
$f->setArgumentNames();
|
||||
$f->setArgumentLists();
|
||||
|
||||
$optSect = new gtOptionalSections();
|
||||
|
||||
$vtc = gtVariationTestCase::getInstance($optSect);
|
||||
$vtc->setUp($f, 1, 'int');
|
||||
$vtc->constructTestCase();
|
||||
|
||||
$fs = $vtc->toString();
|
||||
$this->assertTrue(is_string($fs));
|
||||
|
||||
}
|
||||
|
||||
public function testTestCase2() {
|
||||
|
||||
$f = new gtFunction('date_sunrise');
|
||||
$f->setArgumentNames();
|
||||
$f->setArgumentLists();
|
||||
$a = $f->getMandatoryArgumentNames();
|
||||
|
||||
$optSect = new gtOptionalSections();
|
||||
|
||||
$vtc = gtVariationTestCase::getInstance($optSect);
|
||||
$vtc->setUp($f, 6, 'int');
|
||||
$vtc->constructTestCase();
|
||||
|
||||
$fs = $vtc->toString();
|
||||
$this->assertTrue(is_string($fs));
|
||||
|
||||
}
|
||||
|
||||
public function testTestCase3() {
|
||||
|
||||
$f = new gtFunction('date_sunrise');
|
||||
$f->setArgumentNames();
|
||||
$f->setArgumentLists();
|
||||
|
||||
$optSect = new gtOptionalSections();
|
||||
|
||||
$vtc = gtVariationTestCase::getInstance($optSect);
|
||||
$vtc->setUp($f, 6, 'array');
|
||||
$vtc->constructTestCase();
|
||||
|
||||
$fs = $vtc->toString();
|
||||
$this->assertTrue(is_string($fs));
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
require_once 'PHPUnit/Framework.php';
|
||||
require_once dirname(__FILE__) . '/../src/gtAutoload.php';
|
||||
|
||||
class gtVariationTestCaseMethodTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testTestCase() {
|
||||
|
||||
$f = new gtMethod('DOMDocument','createAttribute');
|
||||
$f->setArgumentNames();
|
||||
$f->setArgumentLists();
|
||||
|
||||
$f->setConstructorArgumentNames();
|
||||
$f->setConstructorInitStatements();
|
||||
|
||||
$optSect = new gtOptionalSections();
|
||||
|
||||
$vtc = gtVariationTestCase::getInstance($optSect, 'method');
|
||||
$vtc->setUp($f, 1, 'int');
|
||||
$vtc->constructTestCase();
|
||||
$fs = $vtc->toString();
|
||||
|
||||
$this->assertTrue(is_string($fs));
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user