gtMethodTest.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. require_once 'PHPUnit/Framework.php';
  3. require_once dirname(__FILE__) . '/../src/gtAutoload.php';
  4. class gtMethodTest extends PHPUnit_Framework_TestCase
  5. {
  6. public function testGetParams() {
  7. $m = new gtMethod('DOMDocument', 'createAttribute');
  8. $m->setArgumentNames();
  9. $a = $m->getMandatoryArgumentNames();
  10. $this->assertEquals($a[0], 'name');
  11. }
  12. public function testConstructor() {
  13. $m = new gtMethod('DOMDocument', 'createAttribute');
  14. $m->setConstructorArgumentNames();
  15. $a = $m->getConstructorArgumentNames();
  16. $this->assertEquals($a[0], 'version');
  17. $this->assertEquals($a[1], 'encoding');
  18. }
  19. public function testExtraParamList() {
  20. $m = new gtMethod('DOMDocument', 'createAttribute');
  21. $m->setArgumentNames();
  22. $m->setExtraArgumentList();
  23. $this->assertEquals('$name, $extra_arg',$m->getExtraArgumentList());
  24. }
  25. public function testShortParamList() {
  26. $m = new gtMethod('DOMDocument', 'createAttribute');
  27. $m->setArgumentNames();
  28. $m->setShortArgumentList();
  29. $this->assertEquals('',$m->getShortArgumentList());
  30. }
  31. public function testAllParamList() {
  32. $m = new gtMethod('DOMDocument', 'createAttribute');
  33. $m->setArgumentNames();
  34. $m->setValidArgumentLists();
  35. $a = $m->getValidArgumentLists();
  36. $this->assertEquals('$name',$a[0]);
  37. }
  38. public function testMaxParamList() {
  39. $m = new gtMethod('DOMDocument', 'createAttribute');
  40. $m->setArgumentNames();
  41. $m->setValidArgumentLists();
  42. $this->assertEquals('$name',$m->getMaximumArgumentList());
  43. }
  44. public function testConstructorList() {
  45. $m = new gtMethod('Phar', 'buildFromDirectory');
  46. $m->setArgumentNames();
  47. $m->setConstructorArgumentNames();
  48. $m->setConstructorArgumentList();
  49. $this->assertEquals('$filename, $flags, $alias, $fileformat',$m->getConstructorArgumentList());
  50. }
  51. public function testConstructorInit() {
  52. $m = new gtMethod('Phar', 'buildFromDirectory');
  53. $m->setArgumentNames();
  54. $m->setConstructorArgumentNames();
  55. $m->setConstructorInitStatements();
  56. $a = $m->getConstructorInitStatements();
  57. $this->assertEquals('$filename = ',$a[0]);
  58. $this->assertEquals('$flags = ',$a[1]);
  59. $this->assertEquals('$alias = ',$a[2]);
  60. $this->assertEquals('$fileformat = ',$a[3]);
  61. }
  62. }
  63. ?>