X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=tests%2FUtil%2FVFSTrait.php;h=53d37f85c81be96443acc7765af5786c78a1a338;hb=1301a53f20a5164d484a3a83368d4eb9174523ae;hp=50999b984d1f3ddae4dbd2e9552661c3fc5d2024;hpb=98d90e131ded624c552102dd450a21e6a67aecf1;p=friendica.git diff --git a/tests/Util/VFSTrait.php b/tests/Util/VFSTrait.php index 50999b984d..53d37f85c8 100644 --- a/tests/Util/VFSTrait.php +++ b/tests/Util/VFSTrait.php @@ -1,4 +1,23 @@ . + * + */ namespace Friendica\Test\Util; @@ -21,33 +40,37 @@ trait VFSTrait $structure = [ 'config' => [], 'bin' => [], - 'test' => [] + 'static' => [], + 'test' => [], + 'logs' => [], + 'config2' => [], ]; // create a virtual directory and copy all needed files and folders to it - $this->root = vfsStream::setup('friendica', null, $structure); + $this->root = vfsStream::setup('friendica', 0777, $structure); - $this->setConfigFile('defaults.config.php'); - $this->setConfigFile('settings.config.php'); + $this->setConfigFile('dbstructure.config.php', true); + $this->setConfigFile('defaults.config.php', true); + $this->setConfigFile('settings.config.php', true); $this->setConfigFile('local.config.php'); - $this->setConfigFile('dbstructure.config.php'); } /** * Copying a config file from the file system to the Virtual File System * * @param string $filename The filename of the config file + * @param bool $static True, if the folder `static` instead of `config` should be used */ - protected function setConfigFile($filename) + protected function setConfigFile(string $filename, bool $static = false) { $file = dirname(__DIR__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . - 'config' . DIRECTORY_SEPARATOR . + ($static ? 'static' : 'config') . DIRECTORY_SEPARATOR . $filename; if (file_exists($file)) { vfsStream::newFile($filename) - ->at($this->root->getChild('config')) + ->at($this->root->getChild(($static ? 'static' : 'config'))) ->setContent(file_get_contents($file)); } } @@ -56,11 +79,12 @@ trait VFSTrait * Delets a config file from the Virtual File System * * @param string $filename The filename of the config file + * @param bool $static True, if the folder `static` instead of `config` should be used */ - protected function delConfigFile($filename) + protected function delConfigFile(string $filename, bool $static = false) { - if ($this->root->hasChild('config/' . $filename)) { - $this->root->removeChild('config/' . $filename); + if ($this->root->hasChild(($static ? 'static' : 'config') . '/' . $filename)) { + $this->root->getChild(($static ? 'static' : 'config'))->removeChild($filename); } } }