1<?php
2
3/**
4 * Class for extended variations. Needs 'data type' and argument to vary
5 */
6
7abstract class gtVariationTestCase extends gtTestCase {
8
9
10  /**
11   * Returns an instance of a test case for a method or a function
12   *
13   * @param string $type
14   * @return test case object
15   */
16  public static function getInstance($optionalSections, $type = 'function') {
17
18    if($type == 'function') {
19      return new gtVariationTestCaseFunction($optionalSections);
20    }
21    if($type =='method') {
22      return new gtVariationTestCaseMethod($optionalSections);
23    }
24
25  }
26
27  public function argInitVariation() {
28    $statements = $this->subject->getInitialisationStatements();
29    for($i=0; $i<count($statements); $i++) {
30      if($i != ( $this->argumentNumber -1) ) {
31        $this->testCase[] = $statements[$i];
32      }
33    }
34    $this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
35  }
36
37  public function addVariationCode() {
38    $this->testCase = gtCodeSnippet::append($this->variationData, $this->testCase);
39    $this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase );
40  }
41
42  public function constructSubjectCalls() {
43    $this->argInitVariation();
44    $this->addVariationCode();
45    $this->subjectCalls();
46  }
47
48  public function addVariationEcho() {
49    $this->testCase[] = "echo \"*** Test substituting argument ".$this->argumentNumber." with ".$this->variationData." values ***\\n\";";
50    $this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase );
51  }
52
53}
54?>
55