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
27 // create a virtual directory and copy all needed files and folders to it
28 $this->root = vfsStream::setup('friendica', 0777, $structure);
30 $this->setConfigFile('defaults.config.php');
31 $this->setConfigFile('settings.config.php');
32 $this->setConfigFile('local.config.php');
33 $this->setConfigFile('dbstructure.config.php');
37 * Copying a config file from the file system to the Virtual File System
39 * @param string $filename The filename of the config file
41 protected function setConfigFile($filename)
43 $file = dirname(__DIR__) . DIRECTORY_SEPARATOR .
44 '..' . DIRECTORY_SEPARATOR .
45 'config' . DIRECTORY_SEPARATOR .
48 if (file_exists($file)) {
49 vfsStream::newFile($filename)
50 ->at($this->root->getChild('config'))
51 ->setContent(file_get_contents($file));
56 * Delets a config file from the Virtual File System
58 * @param string $filename The filename of the config file
60 protected function delConfigFile($filename)
62 if ($this->root->hasChild('config/' . $filename)) {
63 $this->root->getChild('config')->removeChild($filename);