Back to index

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

Class for basic test case construction. More...

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

List of all members.

Public Member Functions

 constructSubjectCalls ()
 addBasicEcho ()
 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

 $subject
 $testCase
 $optionalSections

Detailed Description

Class for basic test case construction.

Definition at line 7 of file gtBasicTestCase.php.


Member Function Documentation

Definition at line 32 of file gtBasicTestCase.php.

                                 {
    $this->testCase[] = "echo \"*** Test by calling method or function with its expected arguments ***\\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::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:

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:

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 27 of file gtBasicTestCase.php.

                                          {
        $this->argInit();
        $this->subjectCalls();
  }

Here is the call graph for this function:

Here is the caller 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 gtBasicTestCase::getInstance ( optionalSections,
type = 'function' 
) [static]

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

Parameters:
string$type
Returns:
test case object

Definition at line 18 of file gtBasicTestCase.php.

                                                                            {
    if($type == 'function') {
      return new gtBasicTestCaseFunction($optionalSections);
    }
    if($type =='method') {
      return new gtBasicTestCaseMethod($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;
  }
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

gtTestCase::$optionalSections [protected, inherited]

Definition at line 30 of file gtTestCase.php.

Reimplemented from gtTestCase.

Definition at line 9 of file gtBasicTestCase.php.

gtTestCase::$testCase [protected, inherited]

Reimplemented in gtVariationTestCaseMethod, and gtVariationTestCaseFunction.

Definition at line 22 of file gtTestCase.php.


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