]> git.mxchange.org Git - friendica.git/blob - tests/src/Core/Console/ConsoleTest.php
Bugfixing executable (Mocking the executable)
[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         /**
17          * @var array The default argv for a Console Instance
18          */
19         protected $consoleArgv = [ 'consoleTest.php' ];
20
21         protected function setUp()
22         {
23                 parent::setUp();
24
25                 if (!getenv('MYSQL_DATABASE')) {
26                         $this->markTestSkipped('Please set the MYSQL_* environment variables to your test database credentials.');
27                 }
28
29                 Intercept::setUp();
30
31                 $this->setUpVfsDir();
32                 $this->mockApp($this->root);
33         }
34
35         protected function tearDown()
36         {
37                 \Mockery::close();
38
39                 parent::tearDown();
40         }
41
42         /**
43          * Dumps the execution of an console output to a string and returns it
44          *
45          * @param Console $console The current console instance
46          *
47          * @return string the output of the execution
48          */
49         protected function dumpExecute($console)
50         {
51                 Intercept::reset();
52                 $console->execute();
53                 $returnStr = Intercept::$cache;
54                 Intercept::reset();
55
56                 return $returnStr;
57         }
58 }