]> git.mxchange.org Git - friendica.git/blob - tests/src/Core/Console/ConsoleTest.php
Refactoring Logging to use Configuration
[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\Core\Config\Configuration;
7 use Friendica\Test\MockedTest;
8 use Friendica\Test\Util\AppMockTrait;
9 use Friendica\Test\Util\Intercept;
10 use Friendica\Test\Util\VFSTrait;
11 use Friendica\Util\Profiler;
12
13 abstract class ConsoleTest extends MockedTest
14 {
15         use VFSTrait;
16         use AppMockTrait;
17
18         /**
19          * @var array The default argv for a Console Instance
20          */
21         protected $consoleArgv = [ 'consoleTest.php' ];
22
23         protected function setUp()
24         {
25                 parent::setUp();
26
27                 if (!getenv('MYSQL_DATABASE')) {
28                         $this->markTestSkipped('Please set the MYSQL_* environment variables to your test database credentials.');
29                 }
30
31                 Intercept::setUp();
32
33                 $this->setUpVfsDir();
34                 $configMock = \Mockery::mock(Configuration::class);
35                 $this->mockApp($this->root, $configMock);
36                 $profileMock = \Mockery::mock(Profiler::class);
37                 $this->app->shouldReceive('getProfiler')->andReturn($profileMock);
38         }
39
40         /**
41          * Dumps the execution of an console output to a string and returns it
42          *
43          * @param Console $console The current console instance
44          *
45          * @return string the output of the execution
46          */
47         protected function dumpExecute($console)
48         {
49                 Intercept::reset();
50                 $console->execute();
51                 $returnStr = Intercept::$cache;
52                 Intercept::reset();
53
54                 return $returnStr;
55         }
56 }