]> git.mxchange.org Git - friendica.git/blob - tests/src/Core/Console/ConsoleTest.php
6b58ccced216586ac3837a38ba30647a8fd2ca29
[friendica.git] / tests / src / Core / Console / ConsoleTest.php
1 <?php
2
3 namespace Friendica\Test\src\Core\Console;
4
5 use Asika\SimpleConsole\Console;
6 use Friendica\Test\Util\AppMockTrait;
7 use Friendica\Test\Util\Intercept;
8 use Friendica\Test\Util\VFSTrait;
9 use PHPUnit\Framework\TestCase;
10
11 abstract class ConsoleTest extends TestCase
12 {
13         use VFSTrait;
14         use AppMockTrait;
15
16         protected $stdout;
17
18         protected function setUp()
19         {
20                 parent::setUp();
21
22                 if (!getenv('MYSQL_DATABASE')) {
23                         $this->markTestSkipped('Please set the MYSQL_* environment variables to your test database credentials.');
24                 }
25
26                 Intercept::setUp();
27
28                 $this->setUpVfsDir();
29                 $this->mockApp($this->root);
30         }
31
32         protected function tearDown()
33         {
34                 \Mockery::close();
35
36                 parent::tearDown();
37         }
38
39         /**
40          * Dumps the execution of an console output to a string and returns it
41          *
42          * @param Console $console The current console instance
43          *
44          * @return string the output of the execution
45          */
46         protected function dumpExecute($console)
47         {
48                 Intercept::reset();
49                 $console->execute();
50                 $returnStr = Intercept::$cache;
51                 Intercept::reset();
52
53                 return $returnStr;
54         }
55 }