Back to index

php5  5.3.10
Public Member Functions | Static Public Member Functions | Protected Attributes
gtVariationTestCaseFunction Class Reference

Class for variation tests for a PHP function. More...

Inheritance diagram for gtVariationTestCaseFunction:
Inheritance graph
[legend]
Collaboration diagram for gtVariationTestCaseFunction:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 __construct ($opt)
 setUp (gtfunction $function, $argumentNumber, $variationData)
 Set data neede to construct variation tests.
 constructTestCase ()
 Constructs the test case as a array of strings.
 testHeader ()
 subjectCalls ()
 argInitVariation ()
 addVariationCode ()
 constructSubjectCalls ()
 addVariationEcho ()
 toString ()
 Convert test case from array to string.
 getTestCase ()
 Returns test case as a array.
 ConstructCommonHeaders ()
 Construct the common headers (title, file section..) of the test case.
 ConstructCommonClosing ()
 Construct the common closing statements (clean, done, EXPECTF...)
 fileOpening ()
 Start the FILE section of the test.
 constructorArgInit ()
 Add contructor argument initialisation to test case.
 constructorCreateInstance ()
 Create instance of class in the test case.
 argInit ()
 Add function or method initilaisation statements to the test case.
 fileClosing ()
 Add FILE section closing tag to the test case.
 addSkipif ()
 Add a skipif section to the test case.
 addIni ()
 Add an INI section to the test case.
 addClean ()
 Add a clean section to the test case.
 addDone ()
 Add a ===DONE=== statement to the test case.
 addExpectf ()
 Add an EXPECTF section.
 getOpt ()

Static Public Member Functions

static getInstance ($optionalSections, $type= 'function')
 Returns an instance of a test case for a method or a function.

Protected Attributes

 $argumentNumber
 $variationData
 $testCase
 $subject
 $optionalSections

Detailed Description

Class for variation tests for a PHP function.

Definition at line 6 of file gtVariationTestCaseFunction.php.


Constructor & Destructor Documentation

Definition at line 12 of file gtVariationTestCaseFunction.php.

                                    {
    $this->optionalSections = $opt;
  }

Member Function Documentation

gtTestCase::addClean ( ) [inherited]

Add a clean section to the test case.

Definition at line 199 of file gtTestCase.php.

                             {
    $this->testCase[] = "--CLEAN--";
    $this->testCase[] = "<?php";
    $this->testCase[] = "?>";
  }

Here is the caller graph for this function:

gtTestCase::addDone ( ) [inherited]

Add a ===DONE=== statement to the test case.

Definition at line 210 of file gtTestCase.php.

                            {
    $this->testCase[] = "===DONE===";
  }

Here is the caller graph for this function:

gtTestCase::addExpectf ( ) [inherited]

Add an EXPECTF section.

Definition at line 219 of file gtTestCase.php.

                               {
    $this->testCase[] = "--EXPECTF--";
    if ($this->optionalSections->hasDone() ){
      $this->testCase[] = '===DONE===';
    }
  }

Here is the caller graph for this function:

gtTestCase::addIni ( ) [inherited]

Add an INI section to the test case.

Definition at line 189 of file gtTestCase.php.

                           {
    $this->testCase[] = "--INI--";
    $this->testCase[] = "";
  }

Here is the caller graph for this function:

gtTestCase::addSkipif ( ) [inherited]

Add a skipif section to the test case.

Definition at line 155 of file gtTestCase.php.

                              {
    $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[] = "?>";
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 38 of file gtVariationTestCase.php.

                                     {
    $this->testCase = gtCodeSnippet::append($this->variationData, $this->testCase);
    $this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 49 of file gtVariationTestCase.php.

                                     {
    $this->testCase[] = "echo \"*** Test substituting argument ".$this->argumentNumber." with ".$this->variationData." values ***\\n\";";
    $this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
  }

Here is the call graph for this function:

Here is the caller graph for this function:

gtTestCase::argInit ( ) [inherited]

Add function or method initilaisation statements to the test case.

Definition at line 133 of file gtTestCase.php.

                            {
    $statements = $this->subject->getInitialisationStatements();
    foreach($statements as $statement) {
      $this->testCase[] = $statement;
    }
    $this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 28 of file gtVariationTestCase.php.

                                     {
    $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 );
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Construct the common closing statements (clean, done, EXPECTF...)

Definition at line 81 of file gtTestCase.php.

                                           {
    $this->fileClosing();
     
    if ($this->optionalSections->hasDone()) {
      $this->addDone();
    }
     
    if ($this->optionalSections->hasClean()) {
      $this->addClean();
    }

    $this->addExpectf();
  }

Here is the call graph for this function:

Construct the common headers (title, file section..) of the test case.

Definition at line 62 of file gtTestCase.php.

                                           {
    $this->testHeader();

    if($this->optionalSections->hasSkipif()) {
      $this->addSkipif();
    }

    if($this->optionalSections->hasIni()) {
      $this->addIni();
    }

    $this->fileOpening();
  }

Here is the call graph for this function:

Add contructor argument initialisation to test case.

Definition at line 110 of file gtTestCase.php.

                                       {
    $conStatements = $this->subject->getConstructorInitStatements();
    foreach($conStatements as $statement) {
      $this->testCase[] = $statement;
    }
  }

Here is the caller graph for this function:

Create instance of class in the test case.

Definition at line 122 of file gtTestCase.php.

                                              {
    $constructorList = $this->subject->getConstructorArgumentList();
    $this->testCase[] = "\$class = new ".$this->subject->getClassName()."( ".$constructorList." );";
    $this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 43 of file gtVariationTestCase.php.

                                          {
    $this->argInitVariation();
    $this->addVariationCode();
    $this->subjectCalls();
  }

Here is the call graph for this function:

Here is the caller graph for this function:

Constructs the test case as a array of strings.

Definition at line 34 of file gtVariationTestCaseFunction.php.

                                      {
    $this->constructCommonHeaders(); 
      
    $this->addVariationEcho();
    
    $this->constructSubjectCalls();
    
    $this->constructCommonClosing();
    
  }

Here is the call graph for this function:

gtTestCase::fileClosing ( ) [inherited]

Add FILE section closing tag to the test case.

Definition at line 146 of file gtTestCase.php.

                                {
    $this->testCase[] = "?>";
  }

Here is the caller graph for this function:

gtTestCase::fileOpening ( ) [inherited]

Start the FILE section of the test.

Definition at line 99 of file gtTestCase.php.

                                {
    $this->testCase[] = "--FILE--";
    $this->testCase[] = "<?php";
    $this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
  }

Here is the call graph for this function:

Here is the caller graph for this function:

static gtVariationTestCase::getInstance ( optionalSections,
type = 'function' 
) [static, inherited]

Returns an instance of a test case for a method or a function.

Parameters:
string$type
Returns:
test case object

Definition at line 17 of file gtVariationTestCase.php.

                                                                            {
     
    if($type == 'function') {
      return new gtVariationTestCaseFunction($optionalSections);
    }
    if($type =='method') {
      return new gtVariationTestCaseMethod($optionalSections);
    }

  }

Here is the caller graph for this function:

gtTestCase::getOpt ( ) [inherited]

Definition at line 226 of file gtTestCase.php.

gtTestCase::getTestCase ( ) [inherited]

Returns test case as a array.

Returns:
array

Definition at line 53 of file gtTestCase.php.

                                {
    return $this->testCase;
  }
gtVariationTestCaseFunction::setUp ( gtfunction $  function,
argumentNumber,
variationData 
)

Set data neede to construct variation tests.

Parameters:
gtfunction$function
string$argumentNumber
string$variationData

Definition at line 22 of file gtVariationTestCaseFunction.php.

                                                                               {
    $this->subject = $function;
    $this->argumentNumber = $argumentNumber;
    $this->variationData = $variationData;

  }

Definition at line 50 of file gtVariationTestCaseFunction.php.

                                 { 
    $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);
  }

Here is the call graph for this function:

Definition at line 44 of file gtVariationTestCaseFunction.php.

                               {
    $this->testCase[] = "--TEST--";
    $this->testCase[] = "Test function ".$this->subject->getName()."() by substituting argument ".$this->argumentNumber." with ".$this->variationData." values.";
  }
gtTestCase::toString ( ) [inherited]

Convert test case from array to string.

Returns:
string

Definition at line 38 of file gtTestCase.php.

                             {
    $testCaseString = "";
    foreach($this->testCase as $line) {
      $testCaseString .= $line."\n";
    }
    return $testCaseString;
  }

Member Data Documentation

Definition at line 8 of file gtVariationTestCaseFunction.php.

gtTestCase::$optionalSections [protected, inherited]

Definition at line 30 of file gtTestCase.php.

gtTestCase::$subject [protected, inherited]

Reimplemented in gtBasicTestCase, and gtVariationTestCaseMethod.

Definition at line 14 of file gtTestCase.php.

Reimplemented from gtTestCase.

Definition at line 10 of file gtVariationTestCaseFunction.php.

Definition at line 9 of file gtVariationTestCaseFunction.php.


The documentation for this class was generated from the following file: