3 namespace Friendica\Test\Util;
6 use org\bovigo\vfs\vfsStream;
7 use org\bovigo\vfs\vfsStreamDirectory;
12 * @var vfsStreamDirectory The Stream Directory
17 * Sets up the Virtual File System for Friendica with common files (config, dbstructure)
19 protected function setUpVfsDir() {
20 // the used directories inside the App class
29 // create a virtual directory and copy all needed files and folders to it
30 $this->root = vfsStream::setup('friendica', 0777, $structure);
32 $this->setConfigFile('dbstructure.config.php', true);
33 $this->setConfigFile('defaults.config.php', true);
34 $this->setConfigFile('settings.config.php', true);
35 $this->setConfigFile('local.config.php');
39 * Copying a config file from the file system to the Virtual File System
41 * @param string $filename The filename of the config file
42 * @param bool $static True, if the folder `static` instead of `config` should be used
44 protected function setConfigFile($filename, bool $static = false)
46 $file = dirname(__DIR__) . DIRECTORY_SEPARATOR .
47 '..' . DIRECTORY_SEPARATOR .
48 ($static ? 'static' : 'config') . DIRECTORY_SEPARATOR .
51 if (file_exists($file)) {
52 vfsStream::newFile($filename)
53 ->at($this->root->getChild(($static ? 'static' : 'config')))
54 ->setContent(file_get_contents($file));
59 * Delets a config file from the Virtual File System
61 * @param string $filename The filename of the config file
62 * @param bool $static True, if the folder `static` instead of `config` should be used
64 protected function delConfigFile($filename, bool $static = false)
66 if ($this->root->hasChild(($static ? 'static' : 'config') . '/' . $filename)) {
67 $this->root->getChild(($static ? 'static' : 'config'))->removeChild($filename);