2018-08-17 19:41:46 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Test\src\Core\Console;
|
|
|
|
|
2018-10-31 09:16:15 +00:00
|
|
|
use Asika\SimpleConsole\Console;
|
|
|
|
use Friendica\Test\Util\AppMockTrait;
|
2018-08-17 19:41:46 +00:00
|
|
|
use Friendica\Test\Util\Intercept;
|
2018-10-06 14:27:20 +00:00
|
|
|
use Friendica\Test\Util\VFSTrait;
|
2018-08-17 19:41:46 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
abstract class ConsoleTest extends TestCase
|
|
|
|
{
|
2018-10-06 14:27:20 +00:00
|
|
|
use VFSTrait;
|
2018-10-31 09:16:15 +00:00
|
|
|
use AppMockTrait;
|
2018-08-17 19:41:46 +00: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 09:16:15 +00:00
|
|
|
Intercept::setUp();
|
|
|
|
|
2018-08-27 04:15:55 +00:00
|
|
|
$this->setUpVfsDir();
|
2018-10-31 09:16:15 +00:00
|
|
|
$this->mockApp($this->root);
|
|
|
|
}
|
2018-08-27 04:15:55 +00:00
|
|
|
|
2018-10-31 09:16:15 +00:00
|
|
|
protected function tearDown()
|
|
|
|
{
|
|
|
|
\Mockery::close();
|
2018-10-06 14:27:20 +00:00
|
|
|
|
2018-10-31 09:16:15 +00:00
|
|
|
parent::tearDown();
|
2018-08-17 19:41:46 +00:00
|
|
|
}
|
|
|
|
|
2018-10-31 09:16:15 +00: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 19:41:46 +00:00
|
|
|
Intercept::reset();
|
2018-10-31 09:16:15 +00:00
|
|
|
$console->execute();
|
2018-08-17 19:41:46 +00:00
|
|
|
$returnStr = Intercept::$cache;
|
|
|
|
Intercept::reset();
|
2018-08-27 04:15:55 +00:00
|
|
|
|
2018-10-31 09:16:15 +00:00
|
|
|
return $returnStr;
|
2018-08-27 04:15:55 +00:00
|
|
|
}
|
2018-08-17 19:41:46 +00:00
|
|
|
}
|