gtOptionalSectionsTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. require_once 'PHPUnit/Framework.php';
  3. require_once dirname(__FILE__) . '/../src/gtAutoload.php';
  4. class gtOptionalSectionsTest extends PHPUnit_Framework_TestCase
  5. {
  6. public function testBasic() {
  7. $clo = new gtCommandLineOptions();
  8. $clo->parse(array('generate-phpt.php', '-s', 'skipif:ini'));
  9. $opt = new gtOptionalSections();
  10. $opt->setOptions($clo);
  11. $a = $opt->getOptions();
  12. $this->assertEquals(true, $a['skipif']);
  13. $this->assertEquals(true, $a['ini']);
  14. $this->assertEquals(false, $a['clean']);
  15. }
  16. /**
  17. * @expectedException RuntimeException
  18. */
  19. public function testException() {
  20. $clo = new gtCommandLineOptions();
  21. $clo->parse(array('generate-phpt.php', '-s', 'blah'));
  22. $opt = new gtOptionalSections();
  23. $opt->setOptions($clo);
  24. }
  25. public function testSkip() {
  26. $clo = new gtCommandLineOptions();
  27. $clo->parse(array('generate-phpt.php', '-s', 'skipif', '-x', 'standard'));
  28. $opt = new gtOptionalSections();
  29. $opt->setOptions($clo);
  30. $opt = new gtOptionalSections();
  31. $opt->setOptions($clo);
  32. $this->assertEquals('standard', $opt->getSkipifExt() );
  33. }
  34. public function testSkipKey() {
  35. $clo = new gtCommandLineOptions();
  36. $clo->parse(array('generate-phpt.php', '-s', 'skipif', '-k', 'win'));
  37. $opt = new gtOptionalSections();
  38. $opt->setOptions($clo);
  39. $opt = new gtOptionalSections();
  40. $opt->setOptions($clo);
  41. $this->assertEquals('win', $opt->getSkipifKey() );
  42. }
  43. }
  44. ?>