FileModeExampleTestCaseOldWay.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * This file is part of vfsStream.
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. *
  8. * @package org\bovigo\vfs
  9. */
  10. namespace org\bovigo\vfs\example;
  11. require_once 'FilemodeExample.php';
  12. /**
  13. * Test case for class FilemodeExample.
  14. */
  15. class FilemodeExampleTestCaseOldWay extends \PHPUnit_Framework_TestCase
  16. {
  17. /**
  18. * set up test environmemt
  19. */
  20. public function setUp()
  21. {
  22. if (file_exists(__DIR__ . '/id') === true) {
  23. rmdir(__DIR__ . '/id');
  24. }
  25. }
  26. /**
  27. * clear up test environment
  28. */
  29. public function tearDown()
  30. {
  31. if (file_exists(__DIR__ . '/id') === true) {
  32. rmdir(__DIR__ . '/id');
  33. }
  34. }
  35. /**
  36. * test correct file mode for created directory
  37. */
  38. public function testDirectoryHasCorrectDefaultFilePermissions()
  39. {
  40. $example = new FilemodeExample('id');
  41. $example->setDirectory(__DIR__);
  42. if (DIRECTORY_SEPARATOR === '\\') {
  43. // can not really test on windows, filemode from mkdir() is ignored
  44. $this->assertEquals(40777, decoct(fileperms(__DIR__ . '/id')));
  45. } else {
  46. $this->assertEquals(40700, decoct(fileperms(__DIR__ . '/id')));
  47. }
  48. }
  49. /**
  50. * test correct file mode for created directory
  51. */
  52. public function testDirectoryHasCorrectDifferentFilePermissions()
  53. {
  54. $example = new FilemodeExample('id', 0755);
  55. $example->setDirectory(__DIR__);
  56. if (DIRECTORY_SEPARATOR === '\\') {
  57. // can not really test on windows, filemode from mkdir() is ignored
  58. $this->assertEquals(40777, decoct(fileperms(__DIR__ . '/id')));
  59. } else {
  60. $this->assertEquals(40755, decoct(fileperms(__DIR__ . '/id')));
  61. }
  62. }
  63. }
  64. ?>