1<?php 2 3/** 4 * Basic test case for a PHP function 5 * 6 */ 7class gtBasicTestCaseFunction extends gtBasicTestCase { 8 9 10 public function __construct($opt) { 11 $this->optionalSections = $opt; 12 } 13 14 /** 15 * Set the function name 16 * 17 * @param gtFunction $function 18 */ 19 public function setFunction($function) { 20 $this->subject = $function; 21 } 22 23 public function constructTestCase() { 24 $this->constructCommonHeaders(); 25 26 $this->addBasicEcho(); 27 28 $this->constructSubjectCalls(); 29 30 $this->constructCommonClosing(); 31 32 } 33 34 35 /** 36 * Construct test case header 37 * 38 */ 39 public function testHeader() { 40 //Opening section and start of test case array. 41 $this->testCase[] = "--TEST--"; 42 $this->testCase[] = "Test function ".$this->subject->getName()."() by calling it with its expected arguments"; 43 } 44 45 /** 46 * Add the test section to call the function 47 * 48 */ 49 public function subjectCalls() { 50 // Construct the argument list to pass to the function being tested 51 $lists = $this->subject->getValidArgumentLists(); 52 53 foreach($lists as $list){ 54 55 $this->testCase = gtCodeSnippet::appendBlankLines(1, $this->testCase ); 56 $this->testCase[] = "var_dump(".$this->subject->getName()."( ".$list." ) );"; 57 } 58 $this->testCase = gtCodeSnippet::appendBlankLines(2, $this->testCase ); 59 } 60 61} 62?> 63