LocalTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Gaufrette\Functional\FileStream;
  3. use Gaufrette\Filesystem;
  4. use Gaufrette\Adapter\Local as LocalAdapter;
  5. use Gaufrette\Functional\LocalDirectoryDeletor;
  6. class LocalTest extends FunctionalTestCase
  7. {
  8. protected $directory;
  9. public function setUp()
  10. {
  11. $this->directory = __DIR__.DIRECTORY_SEPARATOR.'filesystem';
  12. @mkdir($this->directory.DIRECTORY_SEPARATOR.'subdir', 0777, true);
  13. umask(0002);
  14. $this->filesystem = new Filesystem(new LocalAdapter($this->directory, true, 0770));
  15. $this->registerLocalFilesystemInStream();
  16. }
  17. public function testDirectoryChmod()
  18. {
  19. if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {
  20. $this->markTestSkipped('Chmod and umask are not available on Windows.');
  21. }
  22. $r = fopen('gaufrette://filestream/foo/bar', 'a+');
  23. fclose($r);
  24. $perms = fileperms($this->directory . '/foo/');
  25. $this->assertEquals('0770', substr(sprintf('%o', $perms), -4));
  26. }
  27. public function tearDown()
  28. {
  29. LocalDirectoryDeletor::deleteDirectory($this->directory);
  30. }
  31. /**
  32. * @test
  33. */
  34. public function shouldSupportsDirectory()
  35. {
  36. $this->assertFileExists('gaufrette://filestream/subdir');
  37. $this->assertDirectoryExists('gaufrette://filestream/subdir');
  38. }
  39. }