markTestSkipped('Please set the MYSQL_* environment variables to your test database credentials.'); } $this->setUpVfsDir(); // Reusable App object $this->app = new App($this->root->url()); BaseObject::setApp($this->app); $this->console = new MultiUseConsole(); } public function execute($args) { DBA::disconnect(); $this->app->reload(); array_unshift($args, $this->getExecutablePath()); Intercept::reset(); $this->console->reset(); $this->console->parseTestArgv($args); $this->console->execute(); $returnStr = Intercept::$cache; Intercept::reset(); return $returnStr; } /** * @return string returns the path to the console executable during tests */ protected function getExecutablePath() { return $this->root->getChild('bin' . DIRECTORY_SEPARATOR . 'console.php')->url(); } private function setUpVfsDir() { // the used directories inside the App class $structure = [ 'config' => [], 'bin' => [] ]; // create a virtual directory and copy all needed files and folders to it $this->root = vfsStream::setup('friendica', null, $structure); $this->setConfigFile('config.ini.php'); $this->setConfigFile('settings.ini.php'); $this->setConfigFile('local.ini.php'); $this->setConfigFile('dbstructure.json'); // fake console.php for setting an executable vfsStream::newFile('console.php') ->at($this->root->getChild('bin')) ->setContent('at($this->root->getChild('config')) ->setContent(file_get_contents($file)); } } }