~ubuntu-branches/ubuntu/quantal/php5/quantal

« back to all changes in this revision

Viewing changes to scripts/dev/generate-phpt/src/testcase/gtVariationTestCaseMethod.php

  • Committer: Bazaar Package Importer
  • Author(s): Sean Finney
  • Date: 2009-07-01 09:12:10 UTC
  • mto: (0.9.1) (1.1.17 upstream)
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: james.westby@ubuntu.com-20090701091210-go0h6506p62on17r
Tags: upstream-5.3.0
ImportĀ upstreamĀ versionĀ 5.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * Class for variation tests for a PHP method
 
5
 */
 
6
class 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
?>
 
 
b'\\ No newline at end of file'