source: trunk/server/www/vendors/simpletest/test/shell_tester_test.php @ 6

Last change on this file since 6 was 6, checked in by sander, 12 years ago

Added SimpleTest? test framework

File size: 1.4 KB
Line 
1<?php
2// $Id: shell_tester_test.php 1505 2007-04-30 23:39:59Z lastcraft $
3require_once(dirname(__FILE__) . '/../autorun.php');
4require_once(dirname(__FILE__) . '/../shell_tester.php');
5Mock::generate('SimpleShell');
6
7class TestOfShellTestCase extends ShellTestCase {
8    var $_mock_shell = false;
9   
10    function &_getShell() {
11        return $this->_mock_shell;
12    }
13   
14    function testGenericEquality() {
15        $this->assertEqual('a', 'a');
16        $this->assertNotEqual('a', 'A');
17    }
18   
19    function testExitCode() {
20        $this->_mock_shell = &new MockSimpleShell();
21        $this->_mock_shell->setReturnValue('execute', 0);
22        $this->_mock_shell->expectOnce('execute', array('ls'));
23        $this->assertTrue($this->execute('ls'));
24        $this->assertExitCode(0);
25    }
26   
27    function testOutput() {
28        $this->_mock_shell = &new MockSimpleShell();
29        $this->_mock_shell->setReturnValue('execute', 0);
30        $this->_mock_shell->setReturnValue('getOutput', "Line 1\nLine 2\n");
31        $this->assertOutput("Line 1\nLine 2\n");
32    }
33   
34    function testOutputPatterns() {
35        $this->_mock_shell = &new MockSimpleShell();
36        $this->_mock_shell->setReturnValue('execute', 0);
37        $this->_mock_shell->setReturnValue('getOutput', "Line 1\nLine 2\n");
38        $this->assertOutputPattern('/line/i');
39        $this->assertNoOutputPattern('/line 2/');
40    }
41}
42?>
Note: See TracBrowser for help on using the repository browser.