2018-08-17 21:41:46 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Test\src\Core\Console;
|
|
|
|
|
2018-10-31 10:16:15 +01:00
|
|
|
use Asika\SimpleConsole\Console;
|
|
|
|
use Friendica\Test\Util\AppMockTrait;
|
2018-08-17 21:41:46 +02:00
|
|
|
use Friendica\Test\Util\Intercept;
|
2018-10-06 16:27:20 +02:00
|
|
|
use Friendica\Test\Util\VFSTrait;
|
2018-08-17 21:41:46 +02:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
abstract class ConsoleTest extends TestCase
|
|
|
|
{
|
2018-10-06 16:27:20 +02:00
|
|
|
use VFSTrait;
|
2018-10-31 10:16:15 +01:00
|
|
|
use AppMockTrait;
|
2018-08-17 21:41:46 +02:00
|
|
|
|
|
|
|
protected $stdout;
|
|
|
|
|
|
|
|
protected function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
if (!getenv('MYSQL_DATABASE')) {
|
|
|
|
$this->markTestSkipped('Please set the MYSQL_* environment variables to your test database credentials.');
|
|
|
|
}
|
|
|
|
|
2018-10-31 10:16:15 +01:00
|
|
|
Intercept::setUp();
|
|
|
|
|
2018-08-27 06:15:55 +02:00
|
|
|
$this->setUpVfsDir();
|
2018-10-31 10:16:15 +01:00
|
|
|
$this->mockApp($this->root);
|
|
|
|
}
|
2018-08-27 06:15:55 +02:00
|
|
|
|
2018-10-31 10:16:15 +01:00
|
|
|
protected function tearDown()
|
|
|
|
{
|
|
|
|
\Mockery::close();
|
2018-10-06 16:27:20 +02:00
|
|
|
|
2018-10-31 10:16:15 +01:00
|
|
|
parent::tearDown();
|
2018-08-17 21:41:46 +02:00
|
|
|
}
|
|
|
|
|
2018-10-31 10:16:15 +01:00
|
|
|
/**
|
|
|
|
* Dumps the execution of an console output to a string and returns it
|
|
|
|
*
|
|
|
|
* @param Console $console The current console instance
|
|
|
|
*
|
|
|
|
* @return string the output of the execution
|
|
|
|
*/
|
|
|
|
protected function dumpExecute($console)
|
|
|
|
{
|
2018-08-17 21:41:46 +02:00
|
|
|
Intercept::reset();
|
2018-10-31 10:16:15 +01:00
|
|
|
$console->execute();
|
2018-08-17 21:41:46 +02:00
|
|
|
$returnStr = Intercept::$cache;
|
|
|
|
Intercept::reset();
|
2018-08-27 06:15:55 +02:00
|
|
|
|
2018-10-31 10:16:15 +01:00
|
|
|
return $returnStr;
|
2018-08-27 06:15:55 +02:00
|
|
|
}
|
2018-08-17 21:41:46 +02:00
|
|
|
}
|