Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Foundation\Testing\Concerns;
4
 
5
use Illuminate\Console\OutputStyle;
6
use Illuminate\Contracts\Console\Kernel;
7
use Illuminate\Testing\PendingCommand;
8
 
9
trait InteractsWithConsole
10
{
11
    /**
12
     * Indicates if the console output should be mocked.
13
     *
14
     * @var bool
15
     */
16
    public $mockConsoleOutput = true;
17
 
18
    /**
19
     * All of the expected output lines.
20
     *
21
     * @var array
22
     */
23
    public $expectedOutput = [];
24
 
25
    /**
26
     * All of the expected text to be present in the output.
27
     *
28
     * @var array
29
     */
30
    public $expectedOutputSubstrings = [];
31
 
32
    /**
33
     * All of the output lines that aren't expected to be displayed.
34
     *
35
     * @var array
36
     */
37
    public $unexpectedOutput = [];
38
 
39
    /**
40
     * All of the text that is not expected to be present in the output.
41
     *
42
     * @var array
43
     */
44
    public $unexpectedOutputSubstrings = [];
45
 
46
    /**
47
     * All of the expected output tables.
48
     *
49
     * @var array
50
     */
51
    public $expectedTables = [];
52
 
53
    /**
54
     * All of the expected questions.
55
     *
56
     * @var array
57
     */
58
    public $expectedQuestions = [];
59
 
60
    /**
61
     * All of the expected choice questions.
62
     *
63
     * @var array
64
     */
65
    public $expectedChoices = [];
66
 
67
    /**
68
     * Call artisan command and return code.
69
     *
70
     * @param  string  $command
71
     * @param  array  $parameters
72
     * @return \Illuminate\Testing\PendingCommand|int
73
     */
74
    public function artisan($command, $parameters = [])
75
    {
76
        if (! $this->mockConsoleOutput) {
77
            return $this->app[Kernel::class]->call($command, $parameters);
78
        }
79
 
80
        return new PendingCommand($this, $this->app, $command, $parameters);
81
    }
82
 
83
    /**
84
     * Disable mocking the console output.
85
     *
86
     * @return $this
87
     */
88
    protected function withoutMockingConsoleOutput()
89
    {
90
        $this->mockConsoleOutput = false;
91
 
92
        $this->app->offsetUnset(OutputStyle::class);
93
 
94
        return $this;
95
    }
96
}