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
26 // create a virtual directory and copy all needed files and folders to it
27 $this->root = vfsStream::setup('friendica', null, $structure);
29 $this->setConfigFile('config.ini.php');
30 $this->setConfigFile('settings.ini.php');
31 $this->setConfigFile('local.ini.php');
32 $this->setConfigFile('dbstructure.php');
36 * Copying a config file from the file system to the Virtual File System
38 * @param string $filename The filename of the config file
40 protected function setConfigFile($filename)
42 $file = dirname(__DIR__) . DIRECTORY_SEPARATOR .
43 '..' . DIRECTORY_SEPARATOR .
44 'config' . DIRECTORY_SEPARATOR .
47 if (file_exists($file)) {
48 vfsStream::newFile($filename)
49 ->at($this->root->getChild('config'))
50 ->setContent(file_get_contents($file));
55 * Delets a config file from the Virtual File System
57 * @param string $filename The filename of the config file
59 protected function delConfigFile($filename)
61 if ($this->root->hasChild('config/' . $filename)) {
62 $this->root->removeChild('config/' . $filename);