summaryrefslogtreecommitdiff
path: root/scripts/dev/generate-phpt/src/testcase/gtVariationTestCase.php
blob: 039367d5b3d0aa357b8e690ef6c165336c18c0ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

<?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 );
  }

}
?>