3 namespace Friendica\Test\src\Core\Console;
6 use Friendica\BaseObject;
7 use Friendica\Database\DBA;
8 use Friendica\Test\Util\Intercept;
9 use Friendica\Test\Util\VFSTrait;
10 use org\bovigo\vfs\vfsStream;
11 use org\bovigo\vfs\vfsStreamDirectory;
12 use PHPUnit\Framework\TestCase;
14 abstract class ConsoleTest extends TestCase
19 * @var MultiUseConsole Extension of the basic Friendica Console for testing purpose
23 * @var App The Friendica App
29 protected function setUp()
35 if (!getenv('MYSQL_DATABASE')) {
36 $this->markTestSkipped('Please set the MYSQL_* environment variables to your test database credentials.');
41 // fake console.php for setting an executable
42 vfsStream::newFile('console.php')
43 ->at($this->root->getChild('bin'))
44 ->setContent('<? php');
46 // Reusable App object
47 $this->app = new App($this->root->url());
48 BaseObject::setApp($this->app);
49 $this->console = new MultiUseConsole();
52 public function execute($args) {
55 array_unshift($args, $this->getExecutablePath());
57 $this->console->reset();
58 $this->console->parseTestArgv($args);
59 $this->console->execute();
61 $returnStr = Intercept::$cache;
67 * @return string returns the path to the console executable during tests
69 protected function getExecutablePath() {
70 return $this->root->getChild('bin' . DIRECTORY_SEPARATOR . 'console.php')->url();