shell_test.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. // $Id: shell_test.php 1748 2008-04-14 01:50:41Z lastcraft $
  3. require_once(dirname(__FILE__) . '/../autorun.php');
  4. require_once(dirname(__FILE__) . '/../shell_tester.php');
  5. class TestOfShell extends UnitTestCase {
  6. function testEcho() {
  7. $shell = new SimpleShell();
  8. $this->assertIdentical($shell->execute('echo Hello'), 0);
  9. $this->assertPattern('/Hello/', $shell->getOutput());
  10. }
  11. function testBadCommand() {
  12. $shell = new SimpleShell();
  13. $this->assertNotEqual($ret = $shell->execute('blurgh! 2>&1'), 0);
  14. }
  15. }
  16. class TestOfShellTesterAndShell extends ShellTestCase {
  17. function testEcho() {
  18. $this->assertTrue($this->execute('echo Hello'));
  19. $this->assertExitCode(0);
  20. $this->assertoutput('Hello');
  21. }
  22. function testFileExistence() {
  23. $this->assertFileExists(dirname(__FILE__) . '/all_tests.php');
  24. $this->assertFileNotExists('wibble');
  25. }
  26. function testFilePatterns() {
  27. $this->assertFilePattern('/all[_ ]tests/i', dirname(__FILE__) . '/all_tests.php');
  28. $this->assertNoFilePattern('/sputnik/i', dirname(__FILE__) . '/all_tests.php');
  29. }
  30. }
  31. ?>