/
PhpunitShellTest.php
72 lines (57 loc) · 1.55 KB
/
PhpunitShellTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
App::uses('PhpunitShell', 'Phpunit.Console/Command');
class PhpunitShellTest extends CakeTestCase {
public $PhpunitShell;
public function setUp() {
parent::setUp();
$this->PhpunitShell = new TestPhpunitShell();
}
public function testObject() {
$this->assertTrue(is_object($this->PhpunitShell));
$this->assertIsA($this->PhpunitShell, 'PhpunitShell');
}
public function testInfo() {
ob_start();
$this->PhpunitShell->info();
$res = ob_get_clean();
debug($res); ob_flush();
$this->assertTrue(!empty($res));
$this->assertTextContains('# PHPUnit 3.7.', $res);
}
public function testVersions() {
ob_start();
$this->PhpunitShell->versions();
$res = ob_get_clean();
debug($res); ob_flush();
$this->assertTrue(!empty($res));
$this->assertTextContains('3.7 : v3.7.', $res);
}
public function testPackages() {
ob_start();
$this->PhpunitShell->packages();
$res = ob_get_clean();
debug($res); ob_flush();
$this->assertTextContains('Please provide a version like so', $res);
$this->PhpunitShell->args[0] = '3.7';
$this->PhpunitShell->packages();
$res = ob_get_clean();
debug($res); ob_flush();
$this->assertTextContains('PHPUnit 3.7.', $res);
}
}
/**
* Helper to directly display console output
*/
class TestPhpunitShell extends PhpunitShell {
public function out($message = null, $newlines = 1, $level = 1) {
echo $message . PHP_EOL;
}
/*
public function error($message = null, $newlines = 1) {
echo $message.PHP_EOL;
}
public function err($message = null, $newlines = 1) {
echo $message.PHP_EOL;
}
*/
}