-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTestWriter.php
More file actions
99 lines (88 loc) · 1.74 KB
/
TestWriter.php
File metadata and controls
99 lines (88 loc) · 1.74 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
* PHPCSDevTools, tools for PHP_CodeSniffer sniff developers.
*
* @package PHPCSDevTools
* @copyright 2019 PHPCSDevTools Contributors
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
* @link https://github.com/PHPCSStandards/PHPCSDevTools
*/
namespace PHPCSDevTools\Tests;
use PHPCSDevTools\Scripts\Utils\Writer;
/**
* Test Helper to catch text normally send to the command line.
*
* @since 2.0.0
*/
final class TestWriter implements Writer
{
/**
* Text written to STDOUT during the test.
*
* @var string
*/
private $stdout = '';
/**
* Text written to STDERR during the test.
*
* @var string
*/
private $stderr = '';
/**
* All output as written during the test.
*
* @var string
*/
private $output = '';
/**
* Catch output to STDOUT.
*
* @param string $text Output to send.
*
* @return void
*/
public function toStdout($text)
{
$this->stdout .= $text;
$this->output .= $text;
}
/**
* Catch output to STDERR.
*
* @param string $text Output to send.
*
* @return void
*/
public function toStderr($text)
{
$this->stderr .= $text;
$this->output .= $text;
}
/**
* Retrieve output send to STDOUT.
*
* @return string
*/
public function getStdout()
{
return $this->stdout;
}
/**
* Retrieve output send to STDERR.
*
* @return string
*/
public function getStderr()
{
return $this->stderr;
}
/**
* Retrieve all output send.
*
* @return string
*/
public function getOutput()
{
return $this->output;
}
}