FileSystemHarness.php 685 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Test harness that sets up a filesystem sandbox for file-emulation
  4. * functions to safely unit test in.
  5. *
  6. * @todo Make an automatic FSTools mock or something
  7. */
  8. class FSTools_FileSystemHarness extends UnitTestCase
  9. {
  10. protected $dir, $oldDir;
  11. function __construct() {
  12. parent::__construct();
  13. $this->dir = 'tmp/' . md5(uniqid(rand(), true)) . '/';
  14. mkdir($this->dir);
  15. $this->oldDir = getcwd();
  16. }
  17. function __destruct() {
  18. FSTools::singleton()->rmdirr($this->dir);
  19. }
  20. function setup() {
  21. chdir($this->dir);
  22. }
  23. function tearDown() {
  24. chdir($this->oldDir);
  25. }
  26. }
  27. // vim: et sw=4 sts=4