Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VFSTrait.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Friendica\Test\Util;
  3. use org\bovigo\vfs\vfsStream;
  4. use org\bovigo\vfs\vfsStreamDirectory;
  5. trait VFSTrait
  6. {
  7. /**
  8. * @var vfsStreamDirectory The Stream Directory
  9. */
  10. protected $root;
  11. protected function setUpVfsDir() {
  12. // the used directories inside the App class
  13. $structure = [
  14. 'config' => [],
  15. 'bin' => []
  16. ];
  17. // create a virtual directory and copy all needed files and folders to it
  18. $this->root = vfsStream::setup('friendica', null, $structure);
  19. $this->setConfigFile('config.ini.php');
  20. $this->setConfigFile('settings.ini.php');
  21. $this->setConfigFile('local.ini.php');
  22. $this->setConfigFile('dbstructure.json');
  23. }
  24. protected function setConfigFile($filename)
  25. {
  26. $file = dirname(__DIR__) . DIRECTORY_SEPARATOR .
  27. '..' . DIRECTORY_SEPARATOR .
  28. 'config' . DIRECTORY_SEPARATOR .
  29. $filename;
  30. if (file_exists($file)) {
  31. vfsStream::newFile($filename)
  32. ->at($this->root->getChild('config'))
  33. ->setContent(file_get_contents($file));
  34. }
  35. }
  36. protected function delConfigFile($filename)
  37. {
  38. if ($this->root->hasChild('config/' . $filename)) {
  39. $this->root->removeChild('config/' . $filename);
  40. }
  41. }
  42. }