1cd
2<?php
3require_once 'PHPUnit/Framework.php';
4require_once dirname(__FILE__) . '/../src/gtAutoload.php';
5
6
7class gtFunctionTest extends PHPUnit_Framework_TestCase
8{
9  public function testArguments() {
10
11    $f = new gtFunction('cos');
12    $f->setArgumentNames();
13    $m = $f->getMandatoryArgumentNames();
14    $this->assertEquals($m[0], 'number');
15  }
16
17  public function testArguments2() {
18
19    $f = new gtFunction('version_compare');
20    $f->setArgumentNames();
21    $m = $f->getMandatoryArgumentNames();
22    $o = $f->getOptionalArgumentNames();
23    $this->assertEquals($m[0], 'ver1');
24    $this->assertEquals($m[1], 'ver2');
25    $this->assertEquals($o[0], 'oper');
26
27  }
28
29  public function testExtraArguments() {
30
31    $f = new gtFunction('version_compare');
32    $f->setArgumentNames();
33    $f->setExtraArgumentList();
34
35    $this->assertEquals('$ver1, $ver2, $oper, $extra_arg', $f->getExtraArgumentList());
36  }
37
38  public function testShortArguments() {
39
40    $f = new gtFunction('version_compare');
41    $f->setArgumentNames();
42    $f->setShortArgumentList();
43
44    $this->assertEquals('$ver1', $f->getShortArgumentList());
45  }
46
47   public function testAllArgumentList() {
48
49    $f = new gtFunction('version_compare');
50    $f->setArgumentNames();
51    $f->setValidArgumentLists();
52    $a = $f->getValidArgumentLists();
53
54    $this->assertEquals('$ver1, $ver2', $a[0]);
55    $this->assertEquals('$ver1, $ver2, $oper', $a[1]);
56  }
57
58   public function testInitialisation() {
59
60    $f = new gtFunction('version_compare');
61    $f->setArgumentNames();
62    $f->setInitialisationStatements();
63    $a = $f->getInitialisationStatements();
64
65    $this->assertEquals('$ver1 = ', $a[0]);
66    $this->assertEquals('$ver2 = ', $a[1]);
67    $this->assertEquals('$oper = ', $a[2]);
68  }
69
70}
71?>