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