1
|
|
|
<?php |
2
|
|
|
namespace Codeception\Module; |
3
|
|
|
|
4
|
|
|
use Robo\Robo; |
5
|
|
|
use Symfony\Component\Console\Output\BufferedOutput; |
6
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
7
|
|
|
|
8
|
|
|
trait SeeInOutputTrait |
9
|
|
|
{ |
10
|
|
|
protected $testPrinter; |
11
|
|
|
protected $capturedOutput; |
12
|
|
|
protected $logger; |
13
|
|
|
|
14
|
|
|
public function initSeeInOutputTrait($container, $input = null) |
15
|
|
|
{ |
16
|
|
|
$this->capturedOutput = ''; |
17
|
|
|
$this->testPrinter = new BufferedOutput(OutputInterface::VERBOSITY_DEBUG); |
18
|
|
|
|
19
|
|
|
$app = Robo::createDefaultApplication(); |
20
|
|
|
$config = new \Robo\Config(); |
|
|
|
|
21
|
|
|
\Robo\Robo::configureContainer($container, $app, $config, $input, $this->testPrinter); |
22
|
|
|
|
23
|
|
|
// Set the application dispatcher |
24
|
|
|
$app->setDispatcher($container->get('eventDispatcher')); |
25
|
|
|
$this->logger = $container->get('logger'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function capturedOutputStream() |
29
|
|
|
{ |
30
|
|
|
return $this->testPrinter; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function logger() |
34
|
|
|
{ |
35
|
|
|
return $this->logger; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
protected function accumulate() |
39
|
|
|
{ |
40
|
|
|
$this->capturedOutput .= $this->testPrinter->fetch(); |
41
|
|
|
return $this->capturedOutput; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function seeInOutput($value) |
45
|
|
|
{ |
46
|
|
|
$output = $this->accumulate(); |
47
|
|
|
$output = $this->simplify($output); |
48
|
|
|
$this->assertContains($value, $output); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function doNotSeeInOutput($value) |
52
|
|
|
{ |
53
|
|
|
$output = $this->accumulate(); |
54
|
|
|
$output = $this->simplify($output); |
55
|
|
|
$this->assertNotContains($value, $output); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function seeOutputEquals($value) |
59
|
|
|
{ |
60
|
|
|
$output = $this->accumulate(); |
61
|
|
|
$output = $this->simplify($output); |
62
|
|
|
$this->assertEquals($value, $output); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Make our output comparisons more platform-agnostic by converting |
67
|
|
|
* CRLF (Windows) or raw CR (confused output) to a LF (unix/Mac). |
68
|
|
|
*/ |
69
|
|
View Code Duplication |
protected function simplify($output) |
70
|
|
|
{ |
71
|
|
|
$output = str_replace("\r\n", "\n", $output); |
72
|
|
|
$output = str_replace("\r", "\n", $output); |
73
|
|
|
|
74
|
|
|
return $output; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.