gtCommandLineOptionsTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. require_once 'PHPUnit/Framework.php';
  3. require_once dirname(__FILE__) . '/../src/gtAutoload.php';
  4. class gtCommandLineOptionsTest extends PHPUnit_Framework_TestCase
  5. {
  6. /**
  7. * @expectedException RuntimeException
  8. */
  9. public function testNoOption() {
  10. $clo = new gtCommandLineOptions();
  11. $clo->parse(array('generate-phpt.php'));
  12. }
  13. public function testShortOption() {
  14. $clo = new gtCommandLineOptions();
  15. $clo->parse(array('generate-phpt.php', '-h'));
  16. $this->assertTrue($clo->hasOption('h'));
  17. }
  18. public function testShortOptionArgument() {
  19. $clo = new gtCommandLineOptions();
  20. $clo->parse(array('generate-phpt.php', '-f', 'some-function'));
  21. $this->assertTrue($clo->hasOption('f'));
  22. $this->assertEquals('some-function', $clo->getOption('f'));
  23. }
  24. /**
  25. * @expectedException RuntimeException
  26. */
  27. public function testInvalidOption() {
  28. $clo = new gtCommandLineOptions();
  29. $clo->parse(array('generate-phpt.php', '-z'));
  30. }
  31. /**
  32. * @expectedException RuntimeException
  33. */
  34. public function testMissingArgument() {
  35. $clo = new gtCommandLineOptions();
  36. $clo->parse(array('generate-phpt.php', '-f'));
  37. }
  38. }
  39. ?>