mirror of
https://github.com/friendica/friendica
synced 2025-04-24 05:50:11 +00:00
Automatic Install Tests & Doku (#5674)
* Automatic Installation Testing - New dev-library "mikey179/vfsStream" - created "reload" method for App-Reloads - ConsoleTest now using virtual directory - Adding Automatic Installation Tests - Fixing some probable install-failures * Updating README for Automatic Installation * Updating README for Automatic Installation * Bugfix normal installation * Fixing copying of config files
This commit is contained in:
parent
31d47ade78
commit
2838e4ebaf
11 changed files with 665 additions and 111 deletions
|
@ -4,7 +4,10 @@ namespace Friendica\Test\src\Core\Console;
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Test\Util\Intercept;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use org\bovigo\vfs\vfsStreamDirectory;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class ConsoleTest extends TestCase
|
||||
|
@ -18,6 +21,11 @@ abstract class ConsoleTest extends TestCase
|
|||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* @var vfsStreamDirectory The Stream Directory
|
||||
*/
|
||||
protected $root;
|
||||
|
||||
protected $stdout;
|
||||
|
||||
protected function setUp()
|
||||
|
@ -30,12 +38,19 @@ abstract class ConsoleTest extends TestCase
|
|||
$this->markTestSkipped('Please set the MYSQL_* environment variables to your test database credentials.');
|
||||
}
|
||||
|
||||
$this->setUpVfsDir();
|
||||
|
||||
// Reusable App object
|
||||
$this->app = BaseObject::getApp();
|
||||
$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);
|
||||
|
@ -45,4 +60,48 @@ abstract class ConsoleTest extends TestCase
|
|||
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('<? php');
|
||||
}
|
||||
|
||||
private function setConfigFile($filename)
|
||||
{
|
||||
$file = dirname(__DIR__) . DIRECTORY_SEPARATOR .
|
||||
'..' . DIRECTORY_SEPARATOR .
|
||||
'..' . DIRECTORY_SEPARATOR .
|
||||
'..' . DIRECTORY_SEPARATOR .
|
||||
'config' . DIRECTORY_SEPARATOR .
|
||||
$filename;
|
||||
|
||||
if (file_exists($file)) {
|
||||
vfsStream::newFile($filename)
|
||||
->at($this->root->getChild('config'))
|
||||
->setContent(file_get_contents($file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue