1<?php
2
3/**
4 * Class for variation tests for a PHP method
5 */
6class gtVariationTestCaseMethod extends gtVariationTestCase {
7
8  protected $subject;
9  protected $argumentNumber;
10  protected $variationData;
11  protected $testCase;
12
13  public function __construct($opt) {
14    $this->optionalSections = $opt;
15  }
16
17  /**
18   * Set data neede to construct variation tests
19   *
20   * @param gtMethod $method
21   * @param string $argumentNumber
22   * @param string $variationData
23   */
24  public function setUp(gtMethod $method, $argumentNumber, $variationData) {
25    $this->subject = $method;
26    $this->argumentNumber = $argumentNumber;
27    $this->variationData = $variationData;
28  }
29
30
31  /**
32   * Constructs the test case as a array of strings
33   *
34   */
35  public function constructTestCase() {
36    $this->constructCommonHeaders();
37
38    $this->addVariationEcho();
39
40    $this->constructorArgInit();
41    $this->constructorCreateInstance();
42
43    $this->constructSubjectcalls();
44    $this->constructCommonClosing();
45
46  }
47
48  public function testHeader() {
49    $this->testCase[] = "--TEST--";
50    $this->testCase[] = "Test class ".$this->subject->getClassName()." method ".$this->subject->getName()."() by substituting argument ".$this->argumentNumber." with ".$this->variationData." values.";
51  }
52
53  public function subjectCalls() {
54    $this->testCase = gtCodeSnippet::append('loopStart', $this->testCase);
55    // Construct the argument list to pass to the method being tested
56    $argumentList = explode(",", $this->subject->getMaximumArgumentList());
57    $argumentList[$this->argumentNumber -1 ] = "\$var ";
58    $list = implode(", ", $argumentList);
59
60
61    $this->testCase[] = "  var_dump(\$class->".$this->subject->getName()."( ".$list." ) );";
62    $this->testCase = gtCodeSnippet::append('loopClose', $this->testCase);
63
64  }
65
66}
67
68?>