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