4
* Class for variation tests for a PHP method
6
class gtVariationTestCaseMethod extends gtVariationTestCase {
9
protected $argumentNumber;
10
protected $variationData;
13
public function __construct($opt) {
14
$this->optionalSections = $opt;
18
* Set data neede to construct variation tests
20
* @param gtMethod $method
21
* @param string $argumentNumber
22
* @param string $variationData
24
public function setUp(gtMethod $method, $argumentNumber, $variationData) {
25
$this->subject = $method;
26
$this->argumentNumber = $argumentNumber;
27
$this->variationData = $variationData;
32
* Constructs the test case as a array of strings
35
public function constructTestCase() {
36
$this->constructCommonHeaders();
38
$this->addVariationEcho();
40
$this->constructorArgInit();
41
$this->constructorCreateInstance();
43
$this->constructSubjectcalls();
44
$this->constructCommonClosing();
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.";
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);
61
$this->testCase[] = " var_dump(\$class->".$this->subject->getName()."( ".$list." ) );";
62
$this->testCase = gtCodeSnippet::append('loopClose', $this->testCase);
b'\\ No newline at end of file'