Changing Friendica\App\Mode from static methods to public methods
- Changing from static methods to public methods - Adding dev-composer-dependency Mockery for static method mocking (f.e. Config, DBA) - Adding ModeTest with Mocking - removing bootstrap from phpunit.xml because of double loading tests\bootstrap.php
This commit is contained in:
parent
5014779052
commit
31148e25cf
21 changed files with 498 additions and 106 deletions
52
tests/Util/VFSTrait.php
Normal file
52
tests/Util/VFSTrait.php
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\Util;
|
||||
|
||||
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use org\bovigo\vfs\vfsStreamDirectory;
|
||||
|
||||
trait VFSTrait
|
||||
{
|
||||
/**
|
||||
* @var vfsStreamDirectory The Stream Directory
|
||||
*/
|
||||
protected $root;
|
||||
|
||||
protected 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');
|
||||
}
|
||||
|
||||
protected function setConfigFile($filename)
|
||||
{
|
||||
$file = dirname(__DIR__) . 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));
|
||||
}
|
||||
}
|
||||
|
||||
protected function delConfigFile($filename)
|
||||
{
|
||||
if ($this->root->hasChild('config/' . $filename)) {
|
||||
$this->root->removeChild('config/' . $filename);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue