BackUpWordPress - Version 3.2.5

Version Description

  • Security fixes related to add_query_arg
Download this release

Release Info

Developer pauldewouters
Plugin Icon 128x128 BackUpWordPress
Version 3.2.5
Comparing to
See all releases

Code changes from version 3.2.4 to 3.2.5

Files changed (106) hide show
  1. admin/constants.php +7 -7
  2. admin/enable-support.php +1 -1
  3. admin/menu.php +3 -3
  4. admin/schedule-form-excludes.php +5 -6
  5. admin/schedule-form.php +2 -2
  6. admin/schedule-sentence.php +4 -2
  7. admin/schedule-settings.php +1 -1
  8. admin/server-info.php +1 -1
  9. assets/hmbkp.min.js +1 -1
  10. backupwordpress.php +6 -1
  11. changelog +17 -0
  12. classes/class-backup.php +19 -13
  13. classes/class-plugin.php +1 -6
  14. classes/class-schedule.php +3 -0
  15. classes/class-services.php +1 -2
  16. classes/class-setup.php +22 -6
  17. functions/interface.php +16 -0
  18. languages/backupwordpress.pot +89 -89
  19. readme.txt +26 -2
  20. vendor/autoload.php +1 -1
  21. vendor/composer/ClassLoader.php +27 -0
  22. vendor/composer/autoload_namespaces.php +1 -0
  23. vendor/composer/autoload_real.php +4 -4
  24. vendor/composer/installed.json +57 -6
  25. vendor/mikey179/vfsStream/CHANGELOG.md +192 -0
  26. vendor/mikey179/vfsStream/LICENSE +27 -0
  27. vendor/mikey179/vfsStream/README.md +8 -0
  28. vendor/mikey179/vfsStream/composer.json +33 -0
  29. vendor/mikey179/vfsStream/examples/Example.php +54 -0
  30. vendor/mikey179/vfsStream/examples/ExampleTestCaseOldWay.php +48 -0
  31. vendor/mikey179/vfsStream/examples/ExampleTestCaseWithVfsStream.php +47 -0
  32. vendor/mikey179/vfsStream/examples/FailureExample.php +50 -0
  33. vendor/mikey179/vfsStream/examples/FailureExampleTestCase.php +58 -0
  34. vendor/mikey179/vfsStream/examples/FileModeExampleTestCaseOldWay.php +67 -0
  35. vendor/mikey179/vfsStream/examples/FilePermissionsExample.php +29 -0
  36. vendor/mikey179/vfsStream/examples/FilePermissionsExampleTestCase.php +44 -0
  37. vendor/mikey179/vfsStream/examples/FilemodeExample.php +62 -0
  38. vendor/mikey179/vfsStream/examples/FilemodeExampleTestCaseWithVfsStream.php +53 -0
  39. vendor/mikey179/vfsStream/examples/bootstrap.php +3 -0
  40. vendor/mikey179/vfsStream/phpdoc.dist.xml +14 -0
  41. vendor/mikey179/vfsStream/phpunit.xml.dist +42 -0
  42. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/DotDirectory.php +36 -0
  43. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/Quota.php +87 -0
  44. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/FileContent.php +71 -0
  45. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/LargeFileContent.php +167 -0
  46. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/SeekableFileContent.php +129 -0
  47. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/StringBasedFileContent.php +97 -0
  48. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStream.php +462 -0
  49. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamAbstractContent.php +419 -0
  50. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamBlock.php +34 -0
  51. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamContainer.php +62 -0
  52. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamContainerIterator.php +94 -0
  53. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamContent.php +214 -0
  54. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamDirectory.php +267 -0
  55. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamException.php +20 -0
  56. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamFile.php +394 -0
  57. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamWrapper.php +986 -0
  58. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamAbstractVisitor.php +65 -0
  59. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitor.php +108 -0
  60. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamStructureVisitor.php +112 -0
  61. vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamVisitor.php +56 -0
  62. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/DirectoryIterationTestCase.php +318 -0
  63. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/Issue104TestCase.php +52 -0
  64. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/PermissionsTestCase.php +118 -0
  65. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/QuotaTestCase.php +81 -0
  66. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/UnlinkTestCase.php +58 -0
  67. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/content/LargeFileContentTestCase.php +225 -0
  68. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/content/StringBasedFileContentTestCase.php +230 -0
  69. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/proxy/vfsStreamWrapperRecordingProxy.php +326 -0
  70. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamAbstractContentTestCase.php +1054 -0
  71. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamBlockTestCase.php +89 -0
  72. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamContainerIteratorTestCase.php +112 -0
  73. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamDirectoryIssue18TestCase.php +81 -0
  74. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamDirectoryTestCase.php +335 -0
  75. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamExLockTestCase.php +56 -0
  76. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamFileTestCase.php +306 -0
  77. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamGlobTestCase.php +29 -0
  78. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamResolveIncludePathTestCase.php +62 -0
  79. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamTestCase.php +728 -0
  80. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamUmaskTestCase.php +195 -0
  81. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperAlreadyRegisteredTestCase.php +63 -0
  82. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperBaseTestCase.php +99 -0
  83. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperDirSeparatorTestCase.php +73 -0
  84. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperDirTestCase.php +460 -0
  85. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperFileTestCase.php +458 -0
  86. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperFileTimesTestCase.php +315 -0
  87. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperFlockTestCase.php +440 -0
  88. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperLargeFileTestCase.php +77 -0
  89. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperQuotaTestCase.php +224 -0
  90. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperSetOptionTestCase.php +76 -0
  91. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperStreamSelectTestCase.php +35 -0
  92. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperTestCase.php +770 -0
  93. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperWithoutRootTestCase.php +64 -0
  94. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamZipTestCase.php +53 -0
  95. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/visitor/vfsStreamAbstractVisitorTestCase.php +99 -0
  96. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitorTestCase.php +103 -0
  97. vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/visitor/vfsStreamStructureVisitorTestCase.php +86 -0
  98. vendor/mikey179/vfsStream/src/test/resources/filesystemcopy/withSubfolders/aFile.txt +1 -0
  99. vendor/mikey179/vfsStream/src/test/resources/filesystemcopy/withSubfolders/subfolder1/file1.txt +1 -0
  100. vendor/symfony/finder/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php +1 -1
  101. vendor/symfony/finder/Symfony/Component/Finder/Comparator/NumberComparator.php +2 -2
  102. vendor/symfony/finder/Symfony/Component/Finder/Finder.php +5 -5
  103. vendor/symfony/finder/Symfony/Component/Finder/README.md +1 -1
  104. vendor/symfony/finder/Symfony/Component/Finder/Shell/Command.php +1 -1
  105. vendor/symfony/finder/Symfony/Component/Finder/composer.json +3 -0
  106. vendor/symfony/finder/Symfony/Component/Finder/phpunit.xml.dist +1 -2
admin/constants.php CHANGED
@@ -11,7 +11,7 @@
11
  <td>
12
 
13
  <?php if ( defined( 'HMBKP_PATH' ) ) { ?>
14
- <p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . HMBKP_PATH . '</code>' ); ?></p>
15
  <?php } ?>
16
 
17
  <p><?php printf( __( 'The path to folder you would like to store your backup files in, defaults to %s.', 'backupwordpress' ), '<code>' . esc_html( hmbkp_path() ) . '</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_PATH', '/home/willmot/backups' );</code></p>
@@ -27,7 +27,7 @@
27
  <td>
28
 
29
  <?php if ( defined( 'HMBKP_MYSQLDUMP_PATH' ) ) { ?>
30
- <p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . HMBKP_MYSQLDUMP_PATH . '</code>' ); ?></p>
31
  <?php } ?>
32
 
33
  <p><?php printf( __( 'The path to your %1$s executable. Will be used for the %2$s part of the back up if available.', 'backupwordpress' ), '<code>mysqldump</code>', '<code>' . __( 'database', 'backupwordpress' ) . '</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_MYSQLDUMP_PATH', '/opt/local/bin/mysqldump' );</code></p>
@@ -43,7 +43,7 @@
43
  <td>
44
 
45
  <?php if ( defined( 'HMBKP_ZIP_PATH' ) ) { ?>
46
- <p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . HMBKP_ZIP_PATH . '</code>' ); ?></p>
47
  <?php } ?>
48
 
49
  <p><?php printf( __( 'The path to your %1$s executable. Will be used to zip up your %2$s and %3$s if available.', 'backupwordpress' ), '<code>zip</code>', '<code>' . __( 'files', 'backupwordpress' ) . '</code>', '<code>' . __( 'database', 'backupwordpress' ) . '</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_ZIP_PATH', '/opt/local/bin/zip' );</code></p>
@@ -59,7 +59,7 @@
59
  <td>
60
 
61
  <?php if ( defined( 'HMBKP_EXCLUDE' ) ) { ?>
62
- <p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . HMBKP_EXCLUDE . '</code>' ); ?></p>
63
  <?php } ?>
64
 
65
  <p><?php _e( 'Comma separated list of files or directories to exclude, the backups directory is automatically excluded.', 'backupwordpress' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_EXCLUDE', '/wp-content/uploads/, /stats/, .svn/, *.txt' );</code></p>
@@ -75,7 +75,7 @@
75
  <td>
76
 
77
  <?php if ( defined( 'HMBKP_CAPABILITY' ) ) { ?>
78
- <p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . HMBKP_CAPABILITY . '</code>' ); ?></p>
79
  <?php } ?>
80
 
81
  <p><?php printf( __( 'The capability to use when calling %1$s. Defaults to %2$s.', 'backupwordpress' ), '<code>add_menu_page</code>', '<code>manage_options</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_CAPABILITY', 'edit_posts' );</code></p>
@@ -91,7 +91,7 @@
91
  <td>
92
 
93
  <?php if ( defined( 'HMBKP_ROOT' ) ) { ?>
94
- <p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . HMBKP_ROOT . '</code>' ); ?></p>
95
  <?php } ?>
96
 
97
  <p><?php printf( __( 'The root directory that is backed up. Defaults to %s.', 'backupwordpress' ), '<code>' . HM\BackUpWordPress\Backup::get_home_path() . '</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_ROOT', ABSPATH . 'wp/' );</code></p>
@@ -107,7 +107,7 @@
107
  <td>
108
 
109
  <?php if ( defined( 'HMBKP_SCHEDULE_TIME' ) && HMBKP_SCHEDULE_TIME !== '11pm' ) { ?>
110
- <p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . HMBKP_SCHEDULE_TIME . '</code>' ); ?></p>
111
  <?php } ?>
112
 
113
  <p><?php printf( __( 'The time that your schedules should run. Defaults to %s.', 'backupwordpress' ), '<code>23:00</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_SCHEDULE_TIME', '07:30' );</code></p>
11
  <td>
12
 
13
  <?php if ( defined( 'HMBKP_PATH' ) ) { ?>
14
+ <p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . esc_html( HMBKP_PATH ) . '</code>' ); ?></p>
15
  <?php } ?>
16
 
17
  <p><?php printf( __( 'The path to folder you would like to store your backup files in, defaults to %s.', 'backupwordpress' ), '<code>' . esc_html( hmbkp_path() ) . '</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_PATH', '/home/willmot/backups' );</code></p>
27
  <td>
28
 
29
  <?php if ( defined( 'HMBKP_MYSQLDUMP_PATH' ) ) { ?>
30
+ <p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . esc_html( HMBKP_MYSQLDUMP_PATH ) . '</code>' ); ?></p>
31
  <?php } ?>
32
 
33
  <p><?php printf( __( 'The path to your %1$s executable. Will be used for the %2$s part of the back up if available.', 'backupwordpress' ), '<code>mysqldump</code>', '<code>' . __( 'database', 'backupwordpress' ) . '</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_MYSQLDUMP_PATH', '/opt/local/bin/mysqldump' );</code></p>
43
  <td>
44
 
45
  <?php if ( defined( 'HMBKP_ZIP_PATH' ) ) { ?>
46
+ <p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . esc_html( HMBKP_ZIP_PATH ) . '</code>' ); ?></p>
47
  <?php } ?>
48
 
49
  <p><?php printf( __( 'The path to your %1$s executable. Will be used to zip up your %2$s and %3$s if available.', 'backupwordpress' ), '<code>zip</code>', '<code>' . __( 'files', 'backupwordpress' ) . '</code>', '<code>' . __( 'database', 'backupwordpress' ) . '</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_ZIP_PATH', '/opt/local/bin/zip' );</code></p>
59
  <td>
60
 
61
  <?php if ( defined( 'HMBKP_EXCLUDE' ) ) { ?>
62
+ <p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . esc_html( HMBKP_EXCLUDE ) . '</code>' ); ?></p>
63
  <?php } ?>
64
 
65
  <p><?php _e( 'Comma separated list of files or directories to exclude, the backups directory is automatically excluded.', 'backupwordpress' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_EXCLUDE', '/wp-content/uploads/, /stats/, .svn/, *.txt' );</code></p>
75
  <td>
76
 
77
  <?php if ( defined( 'HMBKP_CAPABILITY' ) ) { ?>
78
+ <p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . esc_html( HMBKP_CAPABILITY ) . '</code>' ); ?></p>
79
  <?php } ?>
80
 
81
  <p><?php printf( __( 'The capability to use when calling %1$s. Defaults to %2$s.', 'backupwordpress' ), '<code>add_menu_page</code>', '<code>manage_options</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_CAPABILITY', 'edit_posts' );</code></p>
91
  <td>
92
 
93
  <?php if ( defined( 'HMBKP_ROOT' ) ) { ?>
94
+ <p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . esc_html( HMBKP_ROOT ) . '</code>' ); ?></p>
95
  <?php } ?>
96
 
97
  <p><?php printf( __( 'The root directory that is backed up. Defaults to %s.', 'backupwordpress' ), '<code>' . HM\BackUpWordPress\Backup::get_home_path() . '</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_ROOT', ABSPATH . 'wp/' );</code></p>
107
  <td>
108
 
109
  <?php if ( defined( 'HMBKP_SCHEDULE_TIME' ) && HMBKP_SCHEDULE_TIME !== '11pm' ) { ?>
110
+ <p><?php printf( __( 'You\'ve set it to: %s', 'backupwordpress' ), '<code>' . esc_html( HMBKP_SCHEDULE_TIME ) . '</code>' ); ?></p>
111
  <?php } ?>
112
 
113
  <p><?php printf( __( 'The time that your schedules should run. Defaults to %s.', 'backupwordpress' ), '<code>23:00</code>' ); ?> <?php _e( 'e.g.', 'backupwordpress' ); ?> <code>define( 'HMBKP_SCHEDULE_TIME', '07:30' );</code></p>
admin/enable-support.php CHANGED
@@ -12,7 +12,7 @@
12
 
13
  <thead>
14
  <tr>
15
- <th scope="col" colspan="2"><?php echo ucwords( $group ); ?></th>
16
  </tr>
17
  </thead>
18
 
12
 
13
  <thead>
14
  <tr>
15
+ <th scope="col" colspan="2"><?php echo esc_html( ucwords( $group ) ); ?></th>
16
  </tr>
17
  </thead>
18
 
admin/menu.php CHANGED
@@ -99,10 +99,10 @@ function hmbkp_contextual_help() {
99
  );
100
 
101
  get_current_screen()->set_help_sidebar(
102
- '<p><strong>' . __( 'For more information:', 'backupwordpress' ) . '</strong></p>' .
103
  '<p><a href="https://github.com/humanmade/backupwordpress" target="_blank">GitHub</a></p>' .
104
- '<p><a href="http://wordpress.org/tags/backupwordpress?forum_id=10" target="_blank">' . __( 'Support Forums', 'backupwordpress' ) . '</a></p>' .
105
- '<p><a href="http://translate.hmn.md/" target="_blank">' . __( 'Help with translation', 'backupwordpress' ) . '</a></p>'
106
  );
107
 
108
  }
99
  );
100
 
101
  get_current_screen()->set_help_sidebar(
102
+ '<p><strong>' . esc_html__( 'For more information:', 'backupwordpress' ) . '</strong></p>' .
103
  '<p><a href="https://github.com/humanmade/backupwordpress" target="_blank">GitHub</a></p>' .
104
+ '<p><a href="http://wordpress.org/tags/backupwordpress?forum_id=10" target="_blank">' . esc_html__( 'Support Forums', 'backupwordpress' ) . '</a></p>' .
105
+ '<p><a href="http://translate.hmn.md/" target="_blank">' . esc_html__( 'Help with translation', 'backupwordpress' ) . '</a></p>'
106
  );
107
 
108
  }
admin/schedule-form-excludes.php CHANGED
@@ -165,7 +165,7 @@
165
  <?php echo esc_html( $size ); ?>
166
 
167
  <a class="dashicons dashicons-update"
168
- href="<?php echo wp_nonce_url( add_query_arg( 'hmbkp_recalculate_directory_filesize', urlencode( $schedule->backup->get_root() ) ), 'hmbkp-recalculate_directory_filesize' ); ?>"><span><?php _e( 'Refresh', 'backupwordpress' ); ?></span></a>
169
 
170
  </code>
171
 
@@ -249,7 +249,7 @@
249
  <?php } elseif ( $file->isDir() ) { ?>
250
 
251
  <code title="<?php echo esc_attr( $file->getRealPath() ); ?>"><a
252
- href="<?php echo add_query_arg( 'hmbkp_directory_browse', urlencode( $file->getPathname() ) ); ?>"><?php echo esc_html( $file->getBasename() ); ?></a></code>
253
 
254
  <?php } ?>
255
 
@@ -281,13 +281,12 @@
281
 
282
  <a title="<?php _e( 'Recalculate the size of this directory', 'backupwordpress' ); ?>"
283
  class="dashicons dashicons-update"
284
- href="<?php echo wp_nonce_url( add_query_arg( 'hmbkp_recalculate_directory_filesize', urlencode( $file->getPathname() ) ), 'hmbkp-recalculate_directory_filesize' ); ?>"><span><?php _e( 'Refresh', 'backupwordpress' ); ?></span></a>
285
 
286
  <?php } ?>
287
 
288
  </code>
289
 
290
-
291
  <?php } else { ?>
292
 
293
  <code>--</code>
@@ -340,11 +339,11 @@
340
  $exclude_path = trailingslashit( $file->getPathname() );
341
  } ?>
342
 
343
- <a href="<?php echo wp_nonce_url( add_query_arg( array(
344
  'hmbkp_schedule_id' => $schedule->get_id(),
345
  'action' => 'hmbkp_add_exclude_rule',
346
  'hmbkp_exclude_pathname' => urlencode( $exclude_path )
347
- ), admin_url( 'admin-post.php' ) ), 'hmbkp-add-exclude-rule', 'hmbkp-add-exclude-rule-nonce' ); ?>"
348
  class="button-secondary"><?php _e( 'Exclude &rarr;', 'backupwordpress' ); ?></a>
349
 
350
  <?php } ?>
165
  <?php echo esc_html( $size ); ?>
166
 
167
  <a class="dashicons dashicons-update"
168
+ href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'hmbkp_recalculate_directory_filesize', urlencode( $schedule->backup->get_root() ) ), 'hmbkp-recalculate_directory_filesize' ) ); ?>"><span><?php _e( 'Refresh', 'backupwordpress' ); ?></span></a>
169
 
170
  </code>
171
 
249
  <?php } elseif ( $file->isDir() ) { ?>
250
 
251
  <code title="<?php echo esc_attr( $file->getRealPath() ); ?>"><a
252
+ href="<?php echo esc_url( add_query_arg( 'hmbkp_directory_browse', urlencode( $file->getPathname() ) ) ); ?>"><?php echo esc_html( $file->getBasename() ); ?></a></code>
253
 
254
  <?php } ?>
255
 
281
 
282
  <a title="<?php _e( 'Recalculate the size of this directory', 'backupwordpress' ); ?>"
283
  class="dashicons dashicons-update"
284
+ href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'hmbkp_recalculate_directory_filesize', urlencode( $file->getPathname() ) ), 'hmbkp-recalculate_directory_filesize' ) ); ?>"><span><?php _e( 'Refresh', 'backupwordpress' ); ?></span></a>
285
 
286
  <?php } ?>
287
 
288
  </code>
289
 
 
290
  <?php } else { ?>
291
 
292
  <code>--</code>
339
  $exclude_path = trailingslashit( $file->getPathname() );
340
  } ?>
341
 
342
+ <a href="<?php echo esc_url( wp_nonce_url( add_query_arg( array(
343
  'hmbkp_schedule_id' => $schedule->get_id(),
344
  'action' => 'hmbkp_add_exclude_rule',
345
  'hmbkp_exclude_pathname' => urlencode( $exclude_path )
346
+ ), admin_url( 'admin-post.php' ) ), 'hmbkp-add-exclude-rule', 'hmbkp-add-exclude-rule-nonce' ) ); ?>"
347
  class="button-secondary"><?php _e( 'Exclude &rarr;', 'backupwordpress' ); ?></a>
348
 
349
  <?php } ?>
admin/schedule-form.php CHANGED
@@ -19,7 +19,7 @@ hmbkp_clear_settings_errors();
19
 
20
  ?>
21
 
22
- <form method="post" action="<?php echo admin_url( 'admin-post.php' ); ?>">
23
 
24
  <input type="hidden" name="hmbkp_schedule_id" value="<?php echo esc_attr( $schedule->get_id() ); ?>" />
25
  <input type="hidden" name="action" value="hmbkp_edit_schedule_submit" />
@@ -171,7 +171,7 @@ hmbkp_clear_settings_errors();
171
  <?php printf( __( 'Past this limit older backups will be deleted automatically.', 'backupwordpress' ) ); ?>
172
 
173
  <?php if ( $schedule->is_site_size_cached() ) {
174
- printf( __( 'This schedule will store a maximum of %s of backups.', 'backupwordpress' ), '<code>' . size_format( $schedule->get_site_size() * $schedule->get_max_backups() ) . '</code>' );
175
  } ?>
176
 
177
  </p>
19
 
20
  ?>
21
 
22
+ <form method="post" action="<?php echo esc_url( self_admin_url( 'admin-post.php' ) ); ?>">
23
 
24
  <input type="hidden" name="hmbkp_schedule_id" value="<?php echo esc_attr( $schedule->get_id() ); ?>" />
25
  <input type="hidden" name="action" value="hmbkp_edit_schedule_submit" />
171
  <?php printf( __( 'Past this limit older backups will be deleted automatically.', 'backupwordpress' ) ); ?>
172
 
173
  <?php if ( $schedule->is_site_size_cached() ) {
174
+ printf( __( 'This schedule will store a maximum of %s of backups.', 'backupwordpress' ), '<code>' . esc_html( size_format( $schedule->get_site_size() * $schedule->get_max_backups() ) ) . '</code>' );
175
  } ?>
176
 
177
  </p>
admin/schedule-sentence.php CHANGED
@@ -95,7 +95,9 @@ $email_msg = $services = '';
95
 
96
  foreach ( HM\BackUpWordPress\Services::get_services( $schedule ) as $file => $service ) {
97
 
98
- if ( 'Email' === $service->name ) {
 
 
99
  $email_msg = wp_kses_post( $service->display() );
100
 
101
  } elseif ( $service->is_service_active() ) {
@@ -115,7 +117,7 @@ if ( ! empty( $services ) && count( $services ) > 1 ) {
115
 
116
  <div class="hmbkp-schedule-sentence<?php if ( $schedule->get_status() ) { ?> hmbkp-running<?php } ?>">
117
 
118
- <?php $sentence = sprintf( _x( 'Backup my %1$s %2$s %3$s, %4$s.', '1: Backup Type 2: Total size of backup 3: Schedule 4: Number of backups to store', 'backupwordpress' ), '<span>' . $type . '</span>', $filesize, $reoccurrence, $backup_to_keep );
119
 
120
  if ( $email_msg ) {
121
  $sentence .= sprintf( __( '%s. ', 'backupwordpress' ), $email_msg );
95
 
96
  foreach ( HM\BackUpWordPress\Services::get_services( $schedule ) as $file => $service ) {
97
 
98
+ if ( is_wp_error( $service ) ) {
99
+ $email_msg = $service->get_error_message();
100
+ } elseif ( 'Email' === $service->name ) {
101
  $email_msg = wp_kses_post( $service->display() );
102
 
103
  } elseif ( $service->is_service_active() ) {
117
 
118
  <div class="hmbkp-schedule-sentence<?php if ( $schedule->get_status() ) { ?> hmbkp-running<?php } ?>">
119
 
120
+ <?php $sentence = sprintf( _x( 'Backup my %1$s %2$s %3$s, %4$s.', '1: Backup Type 2: Total size of backup 3: Schedule 4: Number of backups to store', 'backupwordpress' ), '<span>' . esc_html( $type ) . '</span>', $filesize, $reoccurrence, $backup_to_keep );
121
 
122
  if ( $email_msg ) {
123
  $sentence .= sprintf( __( '%s. ', 'backupwordpress' ), $email_msg );
admin/schedule-settings.php CHANGED
@@ -76,7 +76,7 @@ if ( HM\BackUpWordPress\Schedules::get_instance()->get_schedule( $schedule->get_
76
 
77
  ?>
78
 
79
- <form method="post" action="<?php echo admin_url( 'admin-post.php' ); ?>">
80
 
81
  <input type="hidden" name="hmbkp_schedule_id" value="<?php echo esc_attr( $schedule->get_id() ); ?>" />
82
  <input type="hidden" name="action" value="hmbkp_edit_schedule_services_submit" />
76
 
77
  ?>
78
 
79
+ <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
80
 
81
  <input type="hidden" name="hmbkp_schedule_id" value="<?php echo esc_attr( $schedule->get_id() ); ?>" />
82
  <input type="hidden" name="action" value="hmbkp_edit_schedule_services_submit" />
admin/server-info.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  foreach ( HM\BackUpWordPress\Requirements::get_requirement_groups() as $group ) : ?>
4
 
5
- <h3><?php echo ucwords( $group ); ?></h3>
6
 
7
  <table class="fixed widefat">
8
 
2
 
3
  foreach ( HM\BackUpWordPress\Requirements::get_requirement_groups() as $group ) : ?>
4
 
5
+ <h3><?php echo esc_html( ucwords( $group ) ); ?></h3>
6
 
7
  <table class="fixed widefat">
8
 
assets/hmbkp.min.js CHANGED
@@ -1 +1 @@
1
- function hmbkpToggleScheduleFields(a){a="undefined"!=typeof a?a:"manually";var b=jQuery(".recurring-setting"),c=jQuery("#schedule-start"),d=jQuery("p.twice-js");switch(a){case"manually":b.hide();break;case"hmbkp_hourly":b.hide();break;case"hmbkp_daily":b.hide(),c.show(),d.hide();break;case"hmbkp_twicedaily":b.hide(),c.show(),d.show();break;case"hmbkp_weekly":case"hmbkp_fortnightly":b.hide(),jQuery("#start-day").show(),c.show(),d.hide();break;case"hmbkp_monthly":b.hide(),c.show(),jQuery("#start-date").show(),d.hide()}}function hmbkpCatchResponseAndOfferToEmail(a){a&&0!==a?(jQuery(".hmbkp-schedule-sentence.hmbkp-running").removeClass("hmbkp-running").addClass("hmbkp-error"),jQuery.post(ajaxurl,{nonce:hmbkp.nonce,action:"hmbkp_backup_error",hmbkp_error:a},function(a){a&&0!==a&&location.reload(!0)})):location.reload(!0),jQuery(document).one("click",".hmbkp_send_error_via_email",function(b){b.preventDefault(),jQuery(this).addClass("hmbkp-ajax-loading").attr("disabled","disabled"),jQuery.post(ajaxurl,{nonce:hmbkp.nonce,action:"hmbkp_email_error",hmbkp_error:a},function(){})})}jQuery(document).ready(function(a){a.ajaxSetup({cache:!1}),a("select#hmbkp_schedule_recurrence_type").size()&&(hmbkpToggleScheduleFields(a("select#hmbkp_schedule_recurrence_type").val()),a(document).on("change","select#hmbkp_schedule_recurrence_type",function(){hmbkpToggleScheduleFields(a(this).val())})),a(document).on("click",".hmbkp-schedule-actions .delete-action",function(a){confirm(hmbkp.delete_schedule)||a.preventDefault()}),a(document).on("click",".hmbkp_manage_backups_row .delete-action",function(a){confirm(hmbkp.delete_backup)||a.preventDefault()}),a(document).on("click",".hmbkp-edit-schedule-excludes-form .delete-action",function(a){confirm(hmbkp.remove_exclude_rule)||a.preventDefault()}),a.post(ajaxurl,{nonce:hmbkp.nonce,action:"hmbkp_cron_test"},function(b){"1"!==b&&a(".wrap > h2").after(b)}),a(document).on("click",".hmbkp-run",function(b){a(this).closest(".hmbkp-schedule-sentence").addClass("hmbkp-running"),a(".hmbkp-error").removeClass("hmbkp-error");var c=a("[data-hmbkp-schedule-id]").attr("data-hmbkp-schedule-id");a.post(ajaxurl,{hmbkp_run_schedule_nonce:hmbkp.hmbkp_run_schedule_nonce,action:"hmbkp_run_schedule",hmbkp_schedule_id:c}),b.preventDefault()}),a(document).on("heartbeat-send",function(b,c){c.hmbkp_schedule_id=a("[data-hmbkp-schedule-id]").attr("data-hmbkp-schedule-id"),a(".hmbkp-schedule-sentence.hmbkp-running").size()?c.hmbkp_is_in_progress=!0:c.hmbkp_client_request="site_size"}),a(document).on("heartbeat-tick",function(b,c){if(0!==c.hmbkp_schedule_status||a(".hmbkp-error").size()||location.reload(!0),0!==c.hmbkp_schedule_status&&void 0!==c.hmbkp_schedule_status&&a(".hmbkp-status").replaceWith(c.hmbkp_schedule_status),void 0!==c.hmbkp_site_size&&a("code.calculating").size()){a("code.calculating").text(c.hmbkp_site_size);var d=a(".hmbkp-exclude-settings");d.size()&&d.replaceWith(c.hmbkp_dir_sizes)}}),a(document).on("click",".hmbkp-thickbox-close",function(a){a.preventDefault(),tb_remove()})});
1
+ function hmbkpToggleScheduleFields(a){a="undefined"!=typeof a?a:"manually";var b=jQuery(".recurring-setting"),c=jQuery("#schedule-start"),d=jQuery("p.twice-js");switch(a){case"manually":b.hide();break;case"hmbkp_hourly":b.hide();break;case"hmbkp_daily":b.hide(),c.show(),d.hide();break;case"hmbkp_twicedaily":b.hide(),c.show(),d.show();break;case"hmbkp_weekly":case"hmbkp_fortnightly":b.hide(),jQuery("#start-day").show(),c.show(),d.hide();break;case"hmbkp_monthly":b.hide(),c.show(),jQuery("#start-date").show(),d.hide()}}function hmbkpCatchResponseAndOfferToEmail(a){a&&0!==a?(jQuery(".hmbkp-schedule-sentence.hmbkp-running").removeClass("hmbkp-running").addClass("hmbkp-error"),jQuery.post(ajaxurl,{nonce:hmbkp.nonce,action:"hmbkp_backup_error",hmbkp_error:a},function(a){a&&0!==a&&location.reload(!0)})):location.reload(!0),jQuery(document).one("click",".hmbkp_send_error_via_email",function(b){b.preventDefault(),jQuery(this).addClass("hmbkp-ajax-loading").attr("disabled","disabled"),jQuery.post(ajaxurl,{nonce:hmbkp.nonce,action:"hmbkp_email_error",hmbkp_error:a},function(){})})}jQuery(document).ready(function(a){a.ajaxSetup({cache:!1}),a("select#hmbkp_schedule_recurrence_type").size()&&(hmbkpToggleScheduleFields(a("select#hmbkp_schedule_recurrence_type").val()),a(document).on("change","select#hmbkp_schedule_recurrence_type",function(){hmbkpToggleScheduleFields(a(this).val())})),a(document).on("click",".hmbkp-schedule-actions .delete-action",function(a){confirm(hmbkp.delete_schedule)||a.preventDefault()}),a(document).on("click",".hmbkp_manage_backups_row .delete-action",function(a){confirm(hmbkp.delete_backup)||a.preventDefault()}),a(document).on("click",".hmbkp-edit-schedule-excludes-form .delete-action",function(a){confirm(hmbkp.remove_exclude_rule)||a.preventDefault()}),a.post(ajaxurl,{nonce:hmbkp.nonce,action:"hmbkp_cron_test"},function(b){"1"!==b&&a(".wrap > h2").after(b)}),a(document).on("click",".hmbkp-run",function(b){a(this).closest(".hmbkp-schedule-sentence").addClass("hmbkp-running"),a(".hmbkp-error").removeClass("hmbkp-error");var c=a("[data-hmbkp-schedule-id]").attr("data-hmbkp-schedule-id");a.post(ajaxurl,{hmbkp_run_schedule_nonce:hmbkp.hmbkp_run_schedule_nonce,action:"hmbkp_run_schedule",hmbkp_schedule_id:c}),b.preventDefault()}),a(document).on("heartbeat-send",function(b,c){c.hmbkp_schedule_id=a("[data-hmbkp-schedule-id]").attr("data-hmbkp-schedule-id"),a(".hmbkp-schedule-sentence.hmbkp-running").size()?c.hmbkp_is_in_progress=!0:c.hmbkp_client_request="site_size"}),a(document).on("heartbeat-tick",function(b,c){if(0!==c.hmbkp_schedule_status||a(".hmbkp-error").size()||location.reload(!0),0!==c.hmbkp_schedule_status&&void 0!==c.hmbkp_schedule_status&&a(".hmbkp-status").replaceWith(c.hmbkp_schedule_status),void 0!==c.hmbkp_site_size&&a("code.calculating").size()){a("code.calculating").text(c.hmbkp_site_size);var d=a(".hmbkp-exclude-settings");d.size()&&d.replaceWith(c.hmbkp_dir_sizes)}}),a(document).on("click",".hmbkp-thickbox-close",function(a){a.preventDefault(),window.parent.tb_remove()})});
backupwordpress.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: BackUpWordPress Backup Plugin
4
  Plugin URI: http://bwp.hmn.md/
5
  Description: Simple automated backups of your WordPress powered website. Once activated you'll find me under <strong>Tools &rarr; Backups</strong>. On multisite, you'll find me under the Network Settings menu.
6
- Version: 3.2.4
7
  Author: Human Made Limited
8
  Author URI: http://hmn.md/
9
  License: GPL-2.0+
@@ -42,6 +42,11 @@ if ( version_compare( phpversion(), '5.3', '>=' ) ) {
42
  define( 'HMBKP_BASENAME', plugin_basename( __FILE__ ) );
43
  }
44
 
 
 
 
 
 
45
  require_once( HMBKP_PLUGIN_PATH . 'classes/class-plugin.php' );
46
 
47
  } else {
3
  Plugin Name: BackUpWordPress Backup Plugin
4
  Plugin URI: http://bwp.hmn.md/
5
  Description: Simple automated backups of your WordPress powered website. Once activated you'll find me under <strong>Tools &rarr; Backups</strong>. On multisite, you'll find me under the Network Settings menu.
6
+ Version: 3.2.5
7
  Author: Human Made Limited
8
  Author URI: http://hmn.md/
9
  License: GPL-2.0+
42
  define( 'HMBKP_BASENAME', plugin_basename( __FILE__ ) );
43
  }
44
 
45
+ require_once( HMBKP_PLUGIN_PATH . 'classes/class-setup.php' );
46
+
47
+ register_activation_hook( __FILE__, array( 'HM\BackUpWordPress\Setup', 'activate' ) );
48
+ register_deactivation_hook( __FILE__, array( 'HM\BackUpWordPress\Setup', 'deactivate' ) );
49
+
50
  require_once( HMBKP_PLUGIN_PATH . 'classes/class-plugin.php' );
51
 
52
  } else {
changelog ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ * Fixes an issue when evaluating expression with empty
2
+ * Fixes a fatal error on PHP 5.3
3
+ * Displays other notices
4
+ * Updates stable tag
5
+ * Adds some escaping and sanitizing
6
+ * Defines plugins dir for different environments
7
+ * Adds tests for activation and deactivation hooks
8
+ * Adds a debugging function for tests
9
+ * Symlinks plugin into tests dir
10
+ * Splits out deactivation code into separate functions
11
+ * Fixes activation and deactivation hooks not being fired
12
+ * Exclude backups folder from size calculation
13
+ * Fixes a misplaced parenthesis
14
+ * Fixes how error messages are bubbled up
15
+ * get home path should return defined value
16
+ * Removes redundant exclude statement as CVS folders are excluded by default
17
+ * Adds a flag parameter to allow get_files to return all files including default excludes
classes/class-backup.php CHANGED
@@ -173,6 +173,7 @@ namespace HM\BackUpWordPress {
173
  'backup-db',
174
  'Envato-backups',
175
  'managewp',
 
176
  );
177
 
178
  /**
@@ -255,6 +256,10 @@ namespace HM\BackUpWordPress {
255
  */
256
  public static function get_home_path() {
257
 
 
 
 
 
258
  $home_url = home_url();
259
  $site_url = site_url();
260
 
@@ -311,10 +316,6 @@ namespace HM\BackUpWordPress {
311
  set_error_handler( array( $this, 'error_handler' ) );
312
 
313
  // Some properties can be overridden with defines
314
- if ( defined( 'HMBKP_ROOT' ) && HMBKP_ROOT ) {
315
- $this->set_root( HMBKP_ROOT );
316
- }
317
-
318
  if ( defined( 'HMBKP_EXCLUDE' ) && HMBKP_EXCLUDE ) {
319
  $this->set_excludes( HMBKP_EXCLUDE, true );
320
  }
@@ -1205,11 +1206,13 @@ namespace HM\BackUpWordPress {
1205
  }
1206
 
1207
  /**
1208
- * Return an array of all files in the filesystem
 
 
1209
  *
1210
- * @return \RecursiveIteratorIterator
1211
  */
1212
- public function get_files() {
1213
 
1214
  $found = array();
1215
 
@@ -1222,8 +1225,11 @@ namespace HM\BackUpWordPress {
1222
  $finder->ignoreDotFiles( false );
1223
  $finder->ignoreUnreadableDirs();
1224
 
1225
- foreach ( $this->default_excludes() as $exclude ) {
1226
- $finder->notPath( $exclude );
 
 
 
1227
  }
1228
 
1229
  foreach ( $finder->in( $this->get_root() ) as $entry ) {
@@ -1249,7 +1255,7 @@ namespace HM\BackUpWordPress {
1249
 
1250
  $excludes = $this->exclude_string( 'regex' );
1251
 
1252
- foreach ( $this->get_files() as $file ) {
1253
 
1254
  // Skip dot files, they should only exist on versions of PHP between 5.2.11 -> 5.3
1255
  if ( method_exists( $file, 'isDot' ) && $file->isDot() ) {
@@ -1289,7 +1295,7 @@ namespace HM\BackUpWordPress {
1289
 
1290
  $excludes = $this->exclude_string( 'regex' );
1291
 
1292
- foreach ( $this->get_files() as $file ) {
1293
 
1294
  // Skip dot files, they should only exist on versions of PHP between 5.2.11 -> 5.3
1295
  if ( method_exists( $file, 'isDot' ) && $file->isDot() ) {
@@ -1325,7 +1331,7 @@ namespace HM\BackUpWordPress {
1325
 
1326
  $this->unreadable_files = array();
1327
 
1328
- foreach ( $this->get_files() as $file ) {
1329
 
1330
  // Skip dot files, they should only exist on versions of PHP between 5.2.11 -> 5.3
1331
  if ( method_exists( $file, 'isDot' ) && $file->isDot() ) {
@@ -1955,4 +1961,4 @@ namespace {
1955
 
1956
  }
1957
 
1958
- }
173
  'backup-db',
174
  'Envato-backups',
175
  'managewp',
176
+ 'backupwordpress-*-backups'
177
  );
178
 
179
  /**
256
  */
257
  public static function get_home_path() {
258
 
259
+ if ( defined( 'HMBKP_ROOT' ) && HMBKP_ROOT ) {
260
+ return self::conform_dir( HMBKP_ROOT );
261
+ }
262
+
263
  $home_url = home_url();
264
  $site_url = site_url();
265
 
316
  set_error_handler( array( $this, 'error_handler' ) );
317
 
318
  // Some properties can be overridden with defines
 
 
 
 
319
  if ( defined( 'HMBKP_EXCLUDE' ) && HMBKP_EXCLUDE ) {
320
  $this->set_excludes( HMBKP_EXCLUDE, true );
321
  }
1206
  }
1207
 
1208
  /**
1209
+ * Return an array of all files in the filesystem.
1210
+ *
1211
+ * @param bool $ignore_default_exclude_rules If true then will return all files under root. Otherwise returns all files except those matching default exclude rules.
1212
  *
1213
+ * @return array
1214
  */
1215
+ public function get_files( $ignore_default_exclude_rules = false ) {
1216
 
1217
  $found = array();
1218
 
1225
  $finder->ignoreDotFiles( false );
1226
  $finder->ignoreUnreadableDirs();
1227
 
1228
+ if ( ! $ignore_default_exclude_rules ) {
1229
+ // Skips folders/files that match default exclude patterns
1230
+ foreach ( $this->default_excludes() as $exclude ) {
1231
+ $finder->notPath( $exclude );
1232
+ }
1233
  }
1234
 
1235
  foreach ( $finder->in( $this->get_root() ) as $entry ) {
1255
 
1256
  $excludes = $this->exclude_string( 'regex' );
1257
 
1258
+ foreach ( $this->get_files( true ) as $file ) {
1259
 
1260
  // Skip dot files, they should only exist on versions of PHP between 5.2.11 -> 5.3
1261
  if ( method_exists( $file, 'isDot' ) && $file->isDot() ) {
1295
 
1296
  $excludes = $this->exclude_string( 'regex' );
1297
 
1298
+ foreach ( $this->get_files( true ) as $file ) {
1299
 
1300
  // Skip dot files, they should only exist on versions of PHP between 5.2.11 -> 5.3
1301
  if ( method_exists( $file, 'isDot' ) && $file->isDot() ) {
1331
 
1332
  $this->unreadable_files = array();
1333
 
1334
+ foreach ( $this->get_files( true ) as $file ) {
1335
 
1336
  // Skip dot files, they should only exist on versions of PHP between 5.2.11 -> 5.3
1337
  if ( method_exists( $file, 'isDot' ) && $file->isDot() ) {
1961
 
1962
  }
1963
 
1964
+ }
classes/class-plugin.php CHANGED
@@ -2,16 +2,11 @@
2
 
3
  namespace HM\BackUpWordPress;
4
 
5
- require_once( HMBKP_PLUGIN_PATH . 'classes/class-setup.php' );
6
-
7
- register_activation_hook( __FILE__, array( 'HM\BackUpWordPress\Setup', 'activate' ) );
8
- register_deactivation_hook( __FILE__, array( 'HM\BackUpWordPress\Setup', 'deactivate' ) );
9
-
10
  /**
11
  * Class Plugin
12
  */
13
  final class Plugin {
14
- const PLUGIN_VERSION = '3.2.4';
15
 
16
  /**
17
  * @var Plugin The singleton instance.
2
 
3
  namespace HM\BackUpWordPress;
4
 
 
 
 
 
 
5
  /**
6
  * Class Plugin
7
  */
8
  final class Plugin {
9
+ const PLUGIN_VERSION = '3.2.5';
10
 
11
  /**
12
  * @var Plugin The singleton instance.
classes/class-schedule.php CHANGED
@@ -898,6 +898,9 @@ class Scheduled_Backup {
898
  // Pass the actions to all the services
899
  // Todo should be decoupled into the service class
900
  foreach ( Services::get_services( $this ) as $service ) {
 
 
 
901
  $service->action( $action, $backup );
902
  }
903
 
898
  // Pass the actions to all the services
899
  // Todo should be decoupled into the service class
900
  foreach ( Services::get_services( $this ) as $service ) {
901
+ if ( is_wp_error( $service ) ) {
902
+ return $service;
903
+ }
904
  $service->action( $action, $backup );
905
  }
906
 
classes/class-services.php CHANGED
@@ -76,7 +76,6 @@ class Services {
76
  * @return bool|WP_Error
77
  */
78
  public static function register( $filepath, $classname ) {
79
-
80
  if ( ! file_exists( $filepath ) ) {
81
  return new \WP_Error( 'hmbkp_invalid_path_error', sprintf( __( 'Argument 1 for %s must be a valid filepath', 'backupwordpress' ), __METHOD__ ) );
82
  }
@@ -112,7 +111,7 @@ class Services {
112
  private static function instantiate( $classname ) {
113
 
114
  if ( ! class_exists( $classname ) ) {
115
- return new \WP_Error( 'hmbkp_invalid_type_error', sprintf( __( 'Argument 1 for %s must be a valid class', 'backupwordpress' ) ), __METHOD__ );
116
  }
117
 
118
  /**
76
  * @return bool|WP_Error
77
  */
78
  public static function register( $filepath, $classname ) {
 
79
  if ( ! file_exists( $filepath ) ) {
80
  return new \WP_Error( 'hmbkp_invalid_path_error', sprintf( __( 'Argument 1 for %s must be a valid filepath', 'backupwordpress' ), __METHOD__ ) );
81
  }
111
  private static function instantiate( $classname ) {
112
 
113
  if ( ! class_exists( $classname ) ) {
114
+ return new \WP_Error( 'hmbkp_invalid_type_error', sprintf( __( 'Argument 1 for %s must be a valid class', 'backupwordpress' ), __METHOD__ ) );
115
  }
116
 
117
  /**
classes/class-setup.php CHANGED
@@ -22,13 +22,13 @@ class Setup {
22
  */
23
  public static function activate() {
24
 
25
- // loads the translation files for the Error message in the wp_die call.
26
- load_plugin_textdomain( 'backupwordpress', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
27
-
28
  if ( ! current_user_can( 'activate_plugins' ) ) {
29
  return;
30
  }
31
 
 
 
 
32
  if ( ! self::meets_requirements() ) {
33
 
34
  wp_die( self::get_notice_message(), __( 'BackUpWordPress', 'backupwordpress' ), array( 'back_link' => true ) );
@@ -51,16 +51,33 @@ class Setup {
51
  return;
52
  }
53
 
 
 
 
 
 
 
 
 
 
 
 
54
  // Delete Cron schedules.
55
  global $wpdb;
56
 
57
  $schedules = $wpdb->get_col( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE %s", 'hmbkp_schedule_%' ) );
58
 
59
  foreach ( array_map( function ( $item ) {
60
- return ltrim( $item, 'hmbkp_schedule_' );
61
- }, $schedules ) as $item ) {
62
  wp_clear_scheduled_hook( 'hmbkp_schedule_hook', array( 'id' => $item ) );
63
  }
 
 
 
 
 
 
64
 
65
  // Delete all transients
66
  $transients = array(
@@ -72,7 +89,6 @@ class Setup {
72
  );
73
 
74
  array_map( 'delete_transient', $transients );
75
-
76
  }
77
 
78
  /**
22
  */
23
  public static function activate() {
24
 
 
 
 
25
  if ( ! current_user_can( 'activate_plugins' ) ) {
26
  return;
27
  }
28
 
29
+ // loads the translation files for the Error message in the wp_die call.
30
+ load_plugin_textdomain( 'backupwordpress', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
31
+
32
  if ( ! self::meets_requirements() ) {
33
 
34
  wp_die( self::get_notice_message(), __( 'BackUpWordPress', 'backupwordpress' ), array( 'back_link' => true ) );
51
  return;
52
  }
53
 
54
+ self::delete_schedules();
55
+
56
+ self::delete_transients();
57
+
58
+ }
59
+
60
+ /**
61
+ * Deletes the backup schedule database entries and WP Cron entries.
62
+ */
63
+ public static function delete_schedules() {
64
+
65
  // Delete Cron schedules.
66
  global $wpdb;
67
 
68
  $schedules = $wpdb->get_col( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE %s", 'hmbkp_schedule_%' ) );
69
 
70
  foreach ( array_map( function ( $item ) {
71
+ return ltrim( $item, 'hmbkp_schedule_' );
72
+ }, $schedules ) as $item ) {
73
  wp_clear_scheduled_hook( 'hmbkp_schedule_hook', array( 'id' => $item ) );
74
  }
75
+ }
76
+
77
+ /**
78
+ * Deletes the plugin's transients from the database.
79
+ */
80
+ public static function delete_transients() {
81
 
82
  // Delete all transients
83
  $transients = array(
89
  );
90
 
91
  array_map( 'delete_transient', $transients );
 
92
  }
93
 
94
  /**
functions/interface.php CHANGED
@@ -95,6 +95,22 @@ function hmbkp_admin_notices() {
95
 
96
  <?php endif; ?>
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  <?php echo ob_get_clean();
99
 
100
  }
95
 
96
  <?php endif; ?>
97
 
98
+ <?php $notices = array_filter( $notices );
99
+
100
+ if ( ! empty( $notices ) ) : ?>
101
+
102
+ <?php foreach ( $notices as $notice_type ) : ?>
103
+ <?php if ( ! ( in_array( $notice_type, array( 'server_config', 'backup_errors' ) ) ) ) : ?>
104
+ <div id="hmbkp-warning" class="error fade">
105
+ <?php foreach ( array_unique( $notice_type ) as $msg ) : ?>
106
+ <p><?php echo wp_kses_data( $msg ); ?></p>
107
+ <?php endforeach; ?>
108
+ </div>
109
+ <?php endif; ?>
110
+ <?php endforeach; ?>
111
+
112
+ <?php endif; ?>
113
+
114
  <?php echo ob_get_clean();
115
 
116
  }
languages/backupwordpress.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the GPL-2.0+.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: BackUpWordPress Backup Plugin 3.2.3\n"
6
  "Report-Msgid-Bugs-To: support@humanmade.co.uk\n"
7
- "POT-Creation-Date: 2015-04-01 07:48:07+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -447,11 +447,11 @@ msgstr ""
447
  msgid "Refresh"
448
  msgstr ""
449
 
450
- #: admin/schedule-form-excludes.php:185 admin/schedule-form-excludes.php:309
451
  msgid "Symlink"
452
  msgstr ""
453
 
454
- #: admin/schedule-form-excludes.php:189 admin/schedule-form-excludes.php:313
455
  msgid "Folder"
456
  msgstr ""
457
 
@@ -459,27 +459,27 @@ msgstr ""
459
  msgid "Recalculate the size of this directory"
460
  msgstr ""
461
 
462
- #: admin/schedule-form-excludes.php:317
463
  msgid "File"
464
  msgstr ""
465
 
466
- #: admin/schedule-form-excludes.php:328
467
  msgid "Unreadable files won't be backed up."
468
  msgstr ""
469
 
470
- #: admin/schedule-form-excludes.php:328
471
  msgid "Unreadable"
472
  msgstr ""
473
 
474
- #: admin/schedule-form-excludes.php:332
475
  msgid "Excluded"
476
  msgstr ""
477
 
478
- #: admin/schedule-form-excludes.php:348
479
  msgid "Exclude &rarr;"
480
  msgstr ""
481
 
482
- #: admin/schedule-form-excludes.php:366 admin/schedule-form.php:192
483
  #: admin/schedule-settings.php:88
484
  msgid "Done"
485
  msgstr ""
@@ -632,23 +632,23 @@ msgstr ""
632
  msgid "store the last %1$s backups in %2$s"
633
  msgstr ""
634
 
635
- #: admin/schedule-sentence.php:121
636
  msgid "%s. "
637
  msgstr ""
638
 
639
- #: admin/schedule-sentence.php:125
640
  msgid "Send a copy of each backup to %s."
641
  msgstr ""
642
 
643
- #: admin/schedule-sentence.php:156
644
  msgid "Backups will be compressed and should be smaller than this."
645
  msgstr ""
646
 
647
- #: admin/schedule-sentence.php:160
648
  msgid "this shouldn't take long&hellip;"
649
  msgstr ""
650
 
651
- #: admin/schedule-sentence.php:160
652
  msgid "calculating the size of your backup&hellip;"
653
  msgstr ""
654
 
@@ -678,49 +678,49 @@ msgid ""
678
  "Destinations &amp; Unlimited Sites)%4$s"
679
  msgstr ""
680
 
681
- #: backupwordpress.php:48
682
  msgid ""
683
  "BackUpWordPress will not work on this site. ( PHP Version %s is unsupported "
684
  ")"
685
  msgstr ""
686
 
687
- #: backupwordpress.php:48
688
  msgid "BackUpWordPress Error"
689
  msgstr ""
690
 
691
- #: classes/class-backup.php:386
692
  msgid "archive filename must be a non empty string"
693
  msgstr ""
694
 
695
- #: classes/class-backup.php:390
696
  msgid "invalid file extension for archive filename <code>%s</code>"
697
  msgstr ""
698
 
699
- #: classes/class-backup.php:431
700
  msgid "database dump filename must be a non empty string"
701
  msgstr ""
702
 
703
- #: classes/class-backup.php:435
704
  msgid "invalid file extension for database dump filename <code>%s</code>"
705
  msgstr ""
706
 
707
- #: classes/class-backup.php:469
708
  msgid "Invalid root path <code>%s</code> must be a valid directory path"
709
  msgstr ""
710
 
711
- #: classes/class-backup.php:495
712
  msgid ""
713
  "Invalid existing archive filepath <code>%s</code> must be a non empty "
714
  "(string)"
715
  msgstr ""
716
 
717
- #: classes/class-backup.php:550
718
  msgid ""
719
  "Invalid backup type <code>%s</code> must be one of (string) file, database "
720
  "or complete"
721
  msgstr ""
722
 
723
- #: classes/class-backup.php:1921
724
  msgid "Could not connect to mysql"
725
  msgstr ""
726
 
@@ -827,34 +827,34 @@ msgstr ""
827
  msgid "This %s file ensures that other people cannot download your backup files."
828
  msgstr ""
829
 
830
- #: classes/class-plugin.php:218
831
  msgid "Update"
832
  msgstr ""
833
 
834
- #: classes/class-plugin.php:219
835
  msgid "Cancel"
836
  msgstr ""
837
 
838
- #: classes/class-plugin.php:220
839
  msgid ""
840
  "Are you sure you want to delete this schedule? All of it's backups will "
841
  "also be deleted."
842
  msgstr ""
843
 
844
- #: classes/class-plugin.php:220 classes/class-plugin.php:221
845
- #: classes/class-plugin.php:222 classes/class-plugin.php:223
846
  msgid "'Cancel' to go back, 'OK' to delete."
847
  msgstr ""
848
 
849
- #: classes/class-plugin.php:221
850
  msgid "Are you sure you want to delete this backup?"
851
  msgstr ""
852
 
853
- #: classes/class-plugin.php:222
854
  msgid "Are you sure you want to remove this exclude rule?"
855
  msgstr ""
856
 
857
- #: classes/class-plugin.php:223
858
  msgid ""
859
  "Reducing the number of backups that are stored on this server will cause "
860
  "some of your existing backups to be deleted, are you sure that's what you "
@@ -877,7 +877,7 @@ msgstr ""
877
  msgid "Argument 1 for %s must be a valid cron reoccurrence or \"manually\""
878
  msgstr ""
879
 
880
- #: classes/class-schedule.php:778 functions/interface.php:251
881
  msgid "Starting Backup"
882
  msgstr ""
883
 
@@ -885,64 +885,64 @@ msgstr ""
885
  msgid "Error writing to file. (%s)"
886
  msgstr ""
887
 
888
- #: classes/class-schedule.php:913
889
  msgid "Dumping Database %s"
890
  msgstr ""
891
 
892
- #: classes/class-schedule.php:918
893
  msgid "Verifying Database Dump %s"
894
  msgstr ""
895
 
896
- #: classes/class-schedule.php:923
897
  msgid "Creating zip archive %s"
898
  msgstr ""
899
 
900
- #: classes/class-schedule.php:928
901
  msgid "Verifying Zip Archive %s"
902
  msgstr ""
903
 
904
- #: classes/class-schedule.php:933
905
  msgid "Finishing Backup"
906
  msgstr ""
907
 
908
- #: classes/class-schedule.php:984
909
  msgid "An unexpected error occured"
910
  msgstr ""
911
 
912
- #: classes/class-schedule.php:1047
913
  #. translators: min=minute
914
  msgid "%s min"
915
  msgid_plural "%s mins"
916
  msgstr[0] ""
917
  msgstr[1] ""
918
 
919
- #: classes/class-schedule.php:1057
920
  msgid "%s hour"
921
  msgid_plural "%s hours"
922
  msgstr[0] ""
923
  msgstr[1] ""
924
 
925
- #: classes/class-schedule.php:1119
926
  msgid "Argument 1 for %s must be a non empty string"
927
  msgstr ""
928
 
929
- #: classes/class-schedule.php:1124
930
  msgid "%s doesn't exist"
931
  msgstr ""
932
 
933
- #: classes/class-schedule.php:1129
934
  msgid "That backup wasn't created by this schedule"
935
  msgstr ""
936
 
937
- #: classes/class-services.php:81
938
  msgid "Argument 1 for %s must be a valid filepath"
939
  msgstr ""
940
 
941
- #: classes/class-services.php:97
942
  msgid "Argument 1 for %s must be a registered service"
943
  msgstr ""
944
 
945
- #: classes/class-services.php:115 classes/deprecated.php:81
946
  msgid "Argument 1 for %s must be a valid class"
947
  msgstr ""
948
 
@@ -950,7 +950,7 @@ msgstr ""
950
  msgid "BackUpWordPress"
951
  msgstr ""
952
 
953
- #: classes/class-setup.php:154
954
  msgid ""
955
  "BackUpWordPress requires PHP version %1$s or later and WordPress version "
956
  "%2$s or later to run. It has not been activated. %3$s%4$s%5$sLearn more%6$s"
@@ -1010,167 +1010,167 @@ msgstr ""
1010
  msgid "Dismiss"
1011
  msgstr ""
1012
 
1013
- #: functions/interface.php:120
1014
  msgid ""
1015
  "The backups directory can't be created because your %1$s directory isn't "
1016
  "writable, run %2$s or %3$s or create the folder yourself."
1017
  msgstr ""
1018
 
1019
- #: functions/interface.php:124
1020
  msgid ""
1021
  "Your backups directory isn't writable, run %1$s or %2$s or set the "
1022
  "permissions yourself."
1023
  msgstr ""
1024
 
1025
- #: functions/interface.php:128
1026
  msgid ""
1027
  "%1$s is running in %2$s, please contact your host and ask them to disable "
1028
  "it. BackUpWordPress may not work correctly whilst %3$s is on."
1029
  msgstr ""
1030
 
1031
- #: functions/interface.php:128
1032
  msgid "http://php.net/manual/en/features.safe-mode.php"
1033
  msgstr ""
1034
 
1035
- #: functions/interface.php:128
1036
  msgid "Safe Mode"
1037
  msgstr ""
1038
 
1039
- #: functions/interface.php:136
1040
  msgid "Your custom path does not exist"
1041
  msgstr ""
1042
 
1043
- #: functions/interface.php:140
1044
  msgid ""
1045
  "Your custom path is unreachable due to a restriction set in your PHP "
1046
  "configuration (open_basedir)"
1047
  msgstr ""
1048
 
1049
- #: functions/interface.php:145
1050
  msgid ""
1051
  "Your custom backups directory %1$s doesn't exist and can't be created, your "
1052
  "backups will be saved to %2$s instead."
1053
  msgstr ""
1054
 
1055
- #: functions/interface.php:149
1056
  msgid ""
1057
  "Your custom backups directory %1$s isn't writable, new backups will be "
1058
  "saved to %2$s instead."
1059
  msgstr ""
1060
 
1061
- #: functions/interface.php:158
1062
  msgid "Your site root path %s isn't readable."
1063
  msgstr ""
1064
 
1065
- #: functions/interface.php:220
1066
  msgid "Database and Files"
1067
  msgstr ""
1068
 
1069
- #: functions/interface.php:224
1070
  msgid "Files"
1071
  msgstr ""
1072
 
1073
- #: functions/interface.php:228
1074
  msgid "Database"
1075
  msgstr ""
1076
 
1077
- #: functions/interface.php:235
1078
  msgid "Legacy"
1079
  msgstr ""
1080
 
1081
- #: functions/interface.php:250
1082
  msgid "Started %s ago"
1083
  msgstr ""
1084
 
1085
- #: functions/interface.php:252
1086
  msgid "cancel"
1087
  msgstr ""
1088
 
1089
- #: functions/interface.php:300
1090
  msgid "No backups completed"
1091
  msgstr ""
1092
 
1093
- #: functions/interface.php:311
1094
  msgid "Complete Hourly"
1095
  msgstr ""
1096
 
1097
- #: functions/interface.php:312
1098
  msgid "File Hourly"
1099
  msgstr ""
1100
 
1101
- #: functions/interface.php:313
1102
  msgid "Database Hourly"
1103
  msgstr ""
1104
 
1105
- #: functions/interface.php:314
1106
  msgid "Complete Twicedaily"
1107
  msgstr ""
1108
 
1109
- #: functions/interface.php:315
1110
  msgid "File Twicedaily"
1111
  msgstr ""
1112
 
1113
- #: functions/interface.php:316
1114
  msgid "Database Twicedaily"
1115
  msgstr ""
1116
 
1117
- #: functions/interface.php:317
1118
  msgid "Complete Daily"
1119
  msgstr ""
1120
 
1121
- #: functions/interface.php:318
1122
  msgid "File Daily"
1123
  msgstr ""
1124
 
1125
- #: functions/interface.php:319
1126
  msgid "Database Daily"
1127
  msgstr ""
1128
 
1129
- #: functions/interface.php:320
1130
  msgid "Complete Weekly"
1131
  msgstr ""
1132
 
1133
- #: functions/interface.php:321
1134
  msgid "File Weekly"
1135
  msgstr ""
1136
 
1137
- #: functions/interface.php:322
1138
  msgid "Database Weekly"
1139
  msgstr ""
1140
 
1141
- #: functions/interface.php:323
1142
  msgid "Complete Biweekly"
1143
  msgstr ""
1144
 
1145
- #: functions/interface.php:324
1146
  msgid "File Biweekly"
1147
  msgstr ""
1148
 
1149
- #: functions/interface.php:325
1150
  msgid "Database Biweekly"
1151
  msgstr ""
1152
 
1153
- #: functions/interface.php:326
1154
  msgid "Complete Monthly"
1155
  msgstr ""
1156
 
1157
- #: functions/interface.php:327
1158
  msgid "File Monthly"
1159
  msgstr ""
1160
 
1161
- #: functions/interface.php:328
1162
  msgid "Database Monthly"
1163
  msgstr ""
1164
 
1165
- #: functions/interface.php:329
1166
  msgid "Complete Manually"
1167
  msgstr ""
1168
 
1169
- #: functions/interface.php:330
1170
  msgid "File Manually"
1171
  msgstr ""
1172
 
1173
- #: functions/interface.php:331
1174
  msgid "Database Manually"
1175
  msgstr ""
1176
 
@@ -1197,14 +1197,14 @@ msgstr ""
1197
  msgid "http://hmn.md/"
1198
  msgstr ""
1199
 
1200
- #: admin/schedule-sentence.php:118
1201
  msgctxt ""
1202
  "1: Backup Type 2: Total size of backup 3: Schedule 4: Number of backups to "
1203
  "store"
1204
  msgid "Backup my %1$s %2$s %3$s, %4$s."
1205
  msgstr ""
1206
 
1207
- #: functions/interface.php:302
1208
  msgctxt "backups count"
1209
  msgid "One backup completed"
1210
  msgid_plural "%1$s backups completed"
2
  # This file is distributed under the GPL-2.0+.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: BackUpWordPress Backup Plugin 3.2.5\n"
6
  "Report-Msgid-Bugs-To: support@humanmade.co.uk\n"
7
+ "POT-Creation-Date: 2015-04-29 09:30:39+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
447
  msgid "Refresh"
448
  msgstr ""
449
 
450
+ #: admin/schedule-form-excludes.php:185 admin/schedule-form-excludes.php:308
451
  msgid "Symlink"
452
  msgstr ""
453
 
454
+ #: admin/schedule-form-excludes.php:189 admin/schedule-form-excludes.php:312
455
  msgid "Folder"
456
  msgstr ""
457
 
459
  msgid "Recalculate the size of this directory"
460
  msgstr ""
461
 
462
+ #: admin/schedule-form-excludes.php:316
463
  msgid "File"
464
  msgstr ""
465
 
466
+ #: admin/schedule-form-excludes.php:327
467
  msgid "Unreadable files won't be backed up."
468
  msgstr ""
469
 
470
+ #: admin/schedule-form-excludes.php:327
471
  msgid "Unreadable"
472
  msgstr ""
473
 
474
+ #: admin/schedule-form-excludes.php:331
475
  msgid "Excluded"
476
  msgstr ""
477
 
478
+ #: admin/schedule-form-excludes.php:347
479
  msgid "Exclude &rarr;"
480
  msgstr ""
481
 
482
+ #: admin/schedule-form-excludes.php:365 admin/schedule-form.php:192
483
  #: admin/schedule-settings.php:88
484
  msgid "Done"
485
  msgstr ""
632
  msgid "store the last %1$s backups in %2$s"
633
  msgstr ""
634
 
635
+ #: admin/schedule-sentence.php:123
636
  msgid "%s. "
637
  msgstr ""
638
 
639
+ #: admin/schedule-sentence.php:127
640
  msgid "Send a copy of each backup to %s."
641
  msgstr ""
642
 
643
+ #: admin/schedule-sentence.php:158
644
  msgid "Backups will be compressed and should be smaller than this."
645
  msgstr ""
646
 
647
+ #: admin/schedule-sentence.php:162
648
  msgid "this shouldn't take long&hellip;"
649
  msgstr ""
650
 
651
+ #: admin/schedule-sentence.php:162
652
  msgid "calculating the size of your backup&hellip;"
653
  msgstr ""
654
 
678
  "Destinations &amp; Unlimited Sites)%4$s"
679
  msgstr ""
680
 
681
+ #: backupwordpress.php:53
682
  msgid ""
683
  "BackUpWordPress will not work on this site. ( PHP Version %s is unsupported "
684
  ")"
685
  msgstr ""
686
 
687
+ #: backupwordpress.php:53
688
  msgid "BackUpWordPress Error"
689
  msgstr ""
690
 
691
+ #: classes/class-backup.php:388
692
  msgid "archive filename must be a non empty string"
693
  msgstr ""
694
 
695
+ #: classes/class-backup.php:392
696
  msgid "invalid file extension for archive filename <code>%s</code>"
697
  msgstr ""
698
 
699
+ #: classes/class-backup.php:433
700
  msgid "database dump filename must be a non empty string"
701
  msgstr ""
702
 
703
+ #: classes/class-backup.php:437
704
  msgid "invalid file extension for database dump filename <code>%s</code>"
705
  msgstr ""
706
 
707
+ #: classes/class-backup.php:471
708
  msgid "Invalid root path <code>%s</code> must be a valid directory path"
709
  msgstr ""
710
 
711
+ #: classes/class-backup.php:497
712
  msgid ""
713
  "Invalid existing archive filepath <code>%s</code> must be a non empty "
714
  "(string)"
715
  msgstr ""
716
 
717
+ #: classes/class-backup.php:552
718
  msgid ""
719
  "Invalid backup type <code>%s</code> must be one of (string) file, database "
720
  "or complete"
721
  msgstr ""
722
 
723
+ #: classes/class-backup.php:1926
724
  msgid "Could not connect to mysql"
725
  msgstr ""
726
 
827
  msgid "This %s file ensures that other people cannot download your backup files."
828
  msgstr ""
829
 
830
+ #: classes/class-plugin.php:213
831
  msgid "Update"
832
  msgstr ""
833
 
834
+ #: classes/class-plugin.php:214
835
  msgid "Cancel"
836
  msgstr ""
837
 
838
+ #: classes/class-plugin.php:215
839
  msgid ""
840
  "Are you sure you want to delete this schedule? All of it's backups will "
841
  "also be deleted."
842
  msgstr ""
843
 
844
+ #: classes/class-plugin.php:215 classes/class-plugin.php:216
845
+ #: classes/class-plugin.php:217 classes/class-plugin.php:218
846
  msgid "'Cancel' to go back, 'OK' to delete."
847
  msgstr ""
848
 
849
+ #: classes/class-plugin.php:216
850
  msgid "Are you sure you want to delete this backup?"
851
  msgstr ""
852
 
853
+ #: classes/class-plugin.php:217
854
  msgid "Are you sure you want to remove this exclude rule?"
855
  msgstr ""
856
 
857
+ #: classes/class-plugin.php:218
858
  msgid ""
859
  "Reducing the number of backups that are stored on this server will cause "
860
  "some of your existing backups to be deleted, are you sure that's what you "
877
  msgid "Argument 1 for %s must be a valid cron reoccurrence or \"manually\""
878
  msgstr ""
879
 
880
+ #: classes/class-schedule.php:778 functions/interface.php:267
881
  msgid "Starting Backup"
882
  msgstr ""
883
 
885
  msgid "Error writing to file. (%s)"
886
  msgstr ""
887
 
888
+ #: classes/class-schedule.php:916
889
  msgid "Dumping Database %s"
890
  msgstr ""
891
 
892
+ #: classes/class-schedule.php:921
893
  msgid "Verifying Database Dump %s"
894
  msgstr ""
895
 
896
+ #: classes/class-schedule.php:926
897
  msgid "Creating zip archive %s"
898
  msgstr ""
899
 
900
+ #: classes/class-schedule.php:931
901
  msgid "Verifying Zip Archive %s"
902
  msgstr ""
903
 
904
+ #: classes/class-schedule.php:936
905
  msgid "Finishing Backup"
906
  msgstr ""
907
 
908
+ #: classes/class-schedule.php:987
909
  msgid "An unexpected error occured"
910
  msgstr ""
911
 
912
+ #: classes/class-schedule.php:1050
913
  #. translators: min=minute
914
  msgid "%s min"
915
  msgid_plural "%s mins"
916
  msgstr[0] ""
917
  msgstr[1] ""
918
 
919
+ #: classes/class-schedule.php:1060
920
  msgid "%s hour"
921
  msgid_plural "%s hours"
922
  msgstr[0] ""
923
  msgstr[1] ""
924
 
925
+ #: classes/class-schedule.php:1122
926
  msgid "Argument 1 for %s must be a non empty string"
927
  msgstr ""
928
 
929
+ #: classes/class-schedule.php:1127
930
  msgid "%s doesn't exist"
931
  msgstr ""
932
 
933
+ #: classes/class-schedule.php:1132
934
  msgid "That backup wasn't created by this schedule"
935
  msgstr ""
936
 
937
+ #: classes/class-services.php:80
938
  msgid "Argument 1 for %s must be a valid filepath"
939
  msgstr ""
940
 
941
+ #: classes/class-services.php:96
942
  msgid "Argument 1 for %s must be a registered service"
943
  msgstr ""
944
 
945
+ #: classes/class-services.php:114 classes/deprecated.php:81
946
  msgid "Argument 1 for %s must be a valid class"
947
  msgstr ""
948
 
950
  msgid "BackUpWordPress"
951
  msgstr ""
952
 
953
+ #: classes/class-setup.php:170
954
  msgid ""
955
  "BackUpWordPress requires PHP version %1$s or later and WordPress version "
956
  "%2$s or later to run. It has not been activated. %3$s%4$s%5$sLearn more%6$s"
1010
  msgid "Dismiss"
1011
  msgstr ""
1012
 
1013
+ #: functions/interface.php:136
1014
  msgid ""
1015
  "The backups directory can't be created because your %1$s directory isn't "
1016
  "writable, run %2$s or %3$s or create the folder yourself."
1017
  msgstr ""
1018
 
1019
+ #: functions/interface.php:140
1020
  msgid ""
1021
  "Your backups directory isn't writable, run %1$s or %2$s or set the "
1022
  "permissions yourself."
1023
  msgstr ""
1024
 
1025
+ #: functions/interface.php:144
1026
  msgid ""
1027
  "%1$s is running in %2$s, please contact your host and ask them to disable "
1028
  "it. BackUpWordPress may not work correctly whilst %3$s is on."
1029
  msgstr ""
1030
 
1031
+ #: functions/interface.php:144
1032
  msgid "http://php.net/manual/en/features.safe-mode.php"
1033
  msgstr ""
1034
 
1035
+ #: functions/interface.php:144
1036
  msgid "Safe Mode"
1037
  msgstr ""
1038
 
1039
+ #: functions/interface.php:152
1040
  msgid "Your custom path does not exist"
1041
  msgstr ""
1042
 
1043
+ #: functions/interface.php:156
1044
  msgid ""
1045
  "Your custom path is unreachable due to a restriction set in your PHP "
1046
  "configuration (open_basedir)"
1047
  msgstr ""
1048
 
1049
+ #: functions/interface.php:161
1050
  msgid ""
1051
  "Your custom backups directory %1$s doesn't exist and can't be created, your "
1052
  "backups will be saved to %2$s instead."
1053
  msgstr ""
1054
 
1055
+ #: functions/interface.php:165
1056
  msgid ""
1057
  "Your custom backups directory %1$s isn't writable, new backups will be "
1058
  "saved to %2$s instead."
1059
  msgstr ""
1060
 
1061
+ #: functions/interface.php:174
1062
  msgid "Your site root path %s isn't readable."
1063
  msgstr ""
1064
 
1065
+ #: functions/interface.php:236
1066
  msgid "Database and Files"
1067
  msgstr ""
1068
 
1069
+ #: functions/interface.php:240
1070
  msgid "Files"
1071
  msgstr ""
1072
 
1073
+ #: functions/interface.php:244
1074
  msgid "Database"
1075
  msgstr ""
1076
 
1077
+ #: functions/interface.php:251
1078
  msgid "Legacy"
1079
  msgstr ""
1080
 
1081
+ #: functions/interface.php:266
1082
  msgid "Started %s ago"
1083
  msgstr ""
1084
 
1085
+ #: functions/interface.php:268
1086
  msgid "cancel"
1087
  msgstr ""
1088
 
1089
+ #: functions/interface.php:316
1090
  msgid "No backups completed"
1091
  msgstr ""
1092
 
1093
+ #: functions/interface.php:327
1094
  msgid "Complete Hourly"
1095
  msgstr ""
1096
 
1097
+ #: functions/interface.php:328
1098
  msgid "File Hourly"
1099
  msgstr ""
1100
 
1101
+ #: functions/interface.php:329
1102
  msgid "Database Hourly"
1103
  msgstr ""
1104
 
1105
+ #: functions/interface.php:330
1106
  msgid "Complete Twicedaily"
1107
  msgstr ""
1108
 
1109
+ #: functions/interface.php:331
1110
  msgid "File Twicedaily"
1111
  msgstr ""
1112
 
1113
+ #: functions/interface.php:332
1114
  msgid "Database Twicedaily"
1115
  msgstr ""
1116
 
1117
+ #: functions/interface.php:333
1118
  msgid "Complete Daily"
1119
  msgstr ""
1120
 
1121
+ #: functions/interface.php:334
1122
  msgid "File Daily"
1123
  msgstr ""
1124
 
1125
+ #: functions/interface.php:335
1126
  msgid "Database Daily"
1127
  msgstr ""
1128
 
1129
+ #: functions/interface.php:336
1130
  msgid "Complete Weekly"
1131
  msgstr ""
1132
 
1133
+ #: functions/interface.php:337
1134
  msgid "File Weekly"
1135
  msgstr ""
1136
 
1137
+ #: functions/interface.php:338
1138
  msgid "Database Weekly"
1139
  msgstr ""
1140
 
1141
+ #: functions/interface.php:339
1142
  msgid "Complete Biweekly"
1143
  msgstr ""
1144
 
1145
+ #: functions/interface.php:340
1146
  msgid "File Biweekly"
1147
  msgstr ""
1148
 
1149
+ #: functions/interface.php:341
1150
  msgid "Database Biweekly"
1151
  msgstr ""
1152
 
1153
+ #: functions/interface.php:342
1154
  msgid "Complete Monthly"
1155
  msgstr ""
1156
 
1157
+ #: functions/interface.php:343
1158
  msgid "File Monthly"
1159
  msgstr ""
1160
 
1161
+ #: functions/interface.php:344
1162
  msgid "Database Monthly"
1163
  msgstr ""
1164
 
1165
+ #: functions/interface.php:345
1166
  msgid "Complete Manually"
1167
  msgstr ""
1168
 
1169
+ #: functions/interface.php:346
1170
  msgid "File Manually"
1171
  msgstr ""
1172
 
1173
+ #: functions/interface.php:347
1174
  msgid "Database Manually"
1175
  msgstr ""
1176
 
1197
  msgid "http://hmn.md/"
1198
  msgstr ""
1199
 
1200
+ #: admin/schedule-sentence.php:120
1201
  msgctxt ""
1202
  "1: Backup Type 2: Total size of backup 3: Schedule 4: Number of backups to "
1203
  "store"
1204
  msgid "Backup my %1$s %2$s %3$s, %4$s."
1205
  msgstr ""
1206
 
1207
+ #: functions/interface.php:318
1208
  msgctxt "backups count"
1209
  msgid "One backup completed"
1210
  msgid_plural "%1$s backups completed"
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: humanmade, willmot, pauldewouters, joehoyle, mattheu, tcrsavage, cuvelier
3
  Tags: back up, backup, backups, database, zip, db, files, archive, wp-cli, humanmade
4
  Requires at least: 3.9
5
- Tested up to: 4.2-beta
6
- Stable tag: 3.2.4
7
 
8
  Simple automated backups of your WordPress powered website.
9
 
@@ -118,6 +118,10 @@ You can also tweet <a href="http://twitter.com/humanmadeltd">@humanmadeltd</a> o
118
 
119
  == Upgrade Notice ==
120
 
 
 
 
 
121
  = 3.2.1 =
122
 
123
  * Important bug fixes. Please upgrade to this version to avoid incomplete or broken backups.
@@ -140,6 +144,26 @@ You can also tweet <a href="http://twitter.com/humanmadeltd">@humanmadeltd</a> o
140
 
141
  == Changelog ==
142
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  ### 3.2.4 / 2015-04-01
144
 
145
  * Fixes default exclude pattern that was too greedy.
2
  Contributors: humanmade, willmot, pauldewouters, joehoyle, mattheu, tcrsavage, cuvelier
3
  Tags: back up, backup, backups, database, zip, db, files, archive, wp-cli, humanmade
4
  Requires at least: 3.9
5
+ Tested up to: 4.2
6
+ Stable tag: 3.2.5
7
 
8
  Simple automated backups of your WordPress powered website.
9
 
118
 
119
  == Upgrade Notice ==
120
 
121
+ = 3.2.5 =
122
+
123
+ * Security fixes related to add_query_arg
124
+
125
  = 3.2.1 =
126
 
127
  * Important bug fixes. Please upgrade to this version to avoid incomplete or broken backups.
144
 
145
  == Changelog ==
146
 
147
+ ### 3.2.5 / 2015-04-29
148
+
149
+ * Fixes an issue when evaluating expression with empty
150
+ * Fixes a fatal error on PHP 5.3
151
+ * Displays other notices
152
+ * Updates stable tag
153
+ * Adds some escaping and sanitizing
154
+ * Defines plugins dir for different environments
155
+ * Adds tests for activation and deactivation hooks
156
+ * Adds a debugging function for tests
157
+ * Symlinks plugin into tests dir
158
+ * Splits out deactivation code into separate functions
159
+ * Fixes activation and deactivation hooks not being fired
160
+ * Exclude backups folder from size calculation
161
+ * Fixes a misplaced parenthesis
162
+ * Fixes how error messages are bubbled up
163
+ * get home path should return defined value
164
+ * Removes redundant exclude statement as CVS folders are excluded by default
165
+ * Adds a flag parameter to allow get_files to return all files including default excludes
166
+
167
  ### 3.2.4 / 2015-04-01
168
 
169
  * Fixes default exclude pattern that was too greedy.
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInitba9512989056f1653376251cbe20b82c::getLoader();
4
 
5
  require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit2bf0ac6fa5ac73bc9dad2e829cb16011::getLoader();
vendor/composer/ClassLoader.php CHANGED
@@ -54,11 +54,14 @@ class ClassLoader
54
  private $useIncludePath = false;
55
  private $classMap = array();
56
 
 
 
57
  public function getPrefixes()
58
  {
59
  if (!empty($this->prefixesPsr0)) {
60
  return call_user_func_array('array_merge', $this->prefixesPsr0);
61
  }
 
62
  return array();
63
  }
64
 
@@ -247,6 +250,27 @@ class ClassLoader
247
  return $this->useIncludePath;
248
  }
249
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  /**
251
  * Registers this instance as an autoloader.
252
  *
@@ -298,6 +322,9 @@ class ClassLoader
298
  if (isset($this->classMap[$class])) {
299
  return $this->classMap[$class];
300
  }
 
 
 
301
 
302
  $file = $this->findFileWithExtension($class, '.php');
303
 
54
  private $useIncludePath = false;
55
  private $classMap = array();
56
 
57
+ private $classMapAuthoritative = false;
58
+
59
  public function getPrefixes()
60
  {
61
  if (!empty($this->prefixesPsr0)) {
62
  return call_user_func_array('array_merge', $this->prefixesPsr0);
63
  }
64
+
65
  return array();
66
  }
67
 
250
  return $this->useIncludePath;
251
  }
252
 
253
+ /**
254
+ * Turns off searching the prefix and fallback directories for classes
255
+ * that have not been registered with the class map.
256
+ *
257
+ * @param bool $classMapAuthoritative
258
+ */
259
+ public function setClassMapAuthoritative($classMapAuthoritative)
260
+ {
261
+ $this->classMapAuthoritative = $classMapAuthoritative;
262
+ }
263
+
264
+ /**
265
+ * Should class lookup fail if not found in the current class map?
266
+ *
267
+ * @return bool
268
+ */
269
+ public function isClassMapAuthoritative()
270
+ {
271
+ return $this->classMapAuthoritative;
272
+ }
273
+
274
  /**
275
  * Registers this instance as an autoloader.
276
  *
322
  if (isset($this->classMap[$class])) {
323
  return $this->classMap[$class];
324
  }
325
+ if ($this->classMapAuthoritative) {
326
+ return false;
327
+ }
328
 
329
  $file = $this->findFileWithExtension($class, '.php');
330
 
vendor/composer/autoload_namespaces.php CHANGED
@@ -6,5 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
 
9
  'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
10
  );
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
+ 'org\\bovigo\\vfs\\' => array($vendorDir . '/mikey179/vfsStream/src/main/php'),
10
  'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
11
  );
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInitba9512989056f1653376251cbe20b82c
6
  {
7
  private static $loader;
8
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInitba9512989056f1653376251cbe20b82c
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInitba9512989056f1653376251cbe20b82c', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInitba9512989056f1653376251cbe20b82c', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
@@ -44,7 +44,7 @@ class ComposerAutoloaderInitba9512989056f1653376251cbe20b82c
44
  }
45
  }
46
 
47
- function composerRequireba9512989056f1653376251cbe20b82c($file)
48
  {
49
  require $file;
50
  }
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit2bf0ac6fa5ac73bc9dad2e829cb16011
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit2bf0ac6fa5ac73bc9dad2e829cb16011', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit2bf0ac6fa5ac73bc9dad2e829cb16011', 'loadClassLoader'));
25
 
26
  $map = require __DIR__ . '/autoload_namespaces.php';
27
  foreach ($map as $namespace => $path) {
44
  }
45
  }
46
 
47
+ function composerRequire2bf0ac6fa5ac73bc9dad2e829cb16011($file)
48
  {
49
  require $file;
50
  }
vendor/composer/installed.json CHANGED
@@ -1,24 +1,27 @@
1
  [
2
  {
3
  "name": "symfony/finder",
4
- "version": "v2.6.4",
5
- "version_normalized": "2.6.4.0",
6
  "target-dir": "Symfony/Component/Finder",
7
  "source": {
8
  "type": "git",
9
  "url": "https://github.com/symfony/Finder.git",
10
- "reference": "16513333bca64186c01609961a2bb1b95b5e1355"
11
  },
12
  "dist": {
13
  "type": "zip",
14
- "url": "https://api.github.com/repos/symfony/Finder/zipball/16513333bca64186c01609961a2bb1b95b5e1355",
15
- "reference": "16513333bca64186c01609961a2bb1b95b5e1355",
16
  "shasum": ""
17
  },
18
  "require": {
19
  "php": ">=5.3.3"
20
  },
21
- "time": "2015-01-03 08:01:59",
 
 
 
22
  "type": "library",
23
  "extra": {
24
  "branch-alias": {
@@ -47,5 +50,53 @@
47
  ],
48
  "description": "Symfony Finder Component",
49
  "homepage": "http://symfony.com"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
51
  ]
1
  [
2
  {
3
  "name": "symfony/finder",
4
+ "version": "v2.6.6",
5
+ "version_normalized": "2.6.6.0",
6
  "target-dir": "Symfony/Component/Finder",
7
  "source": {
8
  "type": "git",
9
  "url": "https://github.com/symfony/Finder.git",
10
+ "reference": "5dbe2e73a580618f5b4880fda93406eed25de251"
11
  },
12
  "dist": {
13
  "type": "zip",
14
+ "url": "https://api.github.com/repos/symfony/Finder/zipball/5dbe2e73a580618f5b4880fda93406eed25de251",
15
+ "reference": "5dbe2e73a580618f5b4880fda93406eed25de251",
16
  "shasum": ""
17
  },
18
  "require": {
19
  "php": ">=5.3.3"
20
  },
21
+ "require-dev": {
22
+ "symfony/phpunit-bridge": "~2.7"
23
+ },
24
+ "time": "2015-03-30 15:54:10",
25
  "type": "library",
26
  "extra": {
27
  "branch-alias": {
50
  ],
51
  "description": "Symfony Finder Component",
52
  "homepage": "http://symfony.com"
53
+ },
54
+ {
55
+ "name": "mikey179/vfsStream",
56
+ "version": "dev-master",
57
+ "version_normalized": "9999999-dev",
58
+ "source": {
59
+ "type": "git",
60
+ "url": "https://github.com/mikey179/vfsStream.git",
61
+ "reference": "3a0e11a1df90d32b553bf12c012f836729a5abff"
62
+ },
63
+ "dist": {
64
+ "type": "zip",
65
+ "url": "https://api.github.com/repos/mikey179/vfsStream/zipball/3a0e11a1df90d32b553bf12c012f836729a5abff",
66
+ "reference": "3a0e11a1df90d32b553bf12c012f836729a5abff",
67
+ "shasum": ""
68
+ },
69
+ "require": {
70
+ "php": ">=5.3.0"
71
+ },
72
+ "require-dev": {
73
+ "phpunit/phpunit": "~4.5"
74
+ },
75
+ "time": "2015-04-13 17:47:24",
76
+ "type": "library",
77
+ "extra": {
78
+ "branch-alias": {
79
+ "dev-master": "1.5.x-dev"
80
+ }
81
+ },
82
+ "installation-source": "source",
83
+ "autoload": {
84
+ "psr-0": {
85
+ "org\\bovigo\\vfs\\": "src/main/php"
86
+ }
87
+ },
88
+ "notification-url": "https://packagist.org/downloads/",
89
+ "license": [
90
+ "BSD-3-Clause"
91
+ ],
92
+ "authors": [
93
+ {
94
+ "name": "Frank Kleine",
95
+ "homepage": "http://frankkleine.de/",
96
+ "role": "Developer"
97
+ }
98
+ ],
99
+ "description": "Virtual file system to mock the real file system in unit tests.",
100
+ "homepage": "http://vfs.bovigo.org/"
101
  }
102
  ]
vendor/mikey179/vfsStream/CHANGELOG.md ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1.5.0 (2015-03-29)
2
+ ------------------
3
+
4
+ * implemented #91: `vfsStream::copyFromFileSystem()` should create large file instances
5
+ * implemented #92: `vfsStream::copyFromFileSystem()` should respect block devices
6
+ * fixed #107: `touch()` does not respect file permissions
7
+ * fixed #105: vfs directory structure is not reset after each test
8
+ * fixed #104: vfsStream can't handle url encoded pathes
9
+
10
+
11
+ 1.4.0 (2014-09-14)
12
+ ------------------
13
+
14
+ * implemented #85: Added support for emulating block devices in the virtual filesystem, feature provided by Harris Borawski
15
+ * fixed #68: Unlink a non-existing file now triggers a PHP warning
16
+
17
+
18
+ 1.3.0 (2014-07-21)
19
+ ------------------
20
+
21
+ * implemented #79: possibility to mock large files without large memory footprint, see https://github.com/mikey179/vfsStream/wiki/MockingLargeFiles
22
+ * implemented #67: added partial support for text-mode translation flag (i.e., no actual translation of line endings takes place) so it no longer throws an exception (provided by Anthon Pang)
23
+ * fixed issue #74: issue with trailing windows path separators (provided by Sebastian Krüger)
24
+ * fixed issue #50: difference between real file system and vfs with `RecursiveDirectoryIterator`
25
+ * fixed issue #80: touch with no arguments for modification and access time behave incorrect
26
+ * deprecated `org\bovigo\vfs\vfsStreamFile::readUntilEnd()`
27
+ * deprecated `org\bovigo\vfs\vfsStreamFile::getBytesRead()`
28
+
29
+
30
+ 1.2.0 (2013-04-01)
31
+ ------------------
32
+
33
+ * implemented issue #34: provide `url()` method on all `vfsStreamContent` instances
34
+ * added `org\bovigo\vfs\vfsStreamContent::url()`
35
+ * added `org\bovigo\vfs\vfsStreamContent::path()`
36
+ * fixed issue #40: flock implementation doesn't work correctly, patch provided by Kamil Dziedzic
37
+ * fixed issue #49: call to member function on a non-object when trying to delete a file one above root where a file with same name in root exists
38
+ * fixed issue #51: `unlink()` must consider permissions of directory where file is inside, not of the file to unlink itself
39
+ * fixed issue #52: `chmod()`, `chown()` and `chgrp()` must consider permissions of directory where file/directory is inside
40
+ * fixed issue #53: `chmod()`, `chown()` and `chgrp()` must consider current user and current owner of file/directoy to change
41
+
42
+
43
+ 1.1.0 (2012-08-25)
44
+ ------------------
45
+
46
+ * implemented issue #11: add support for `streamWrapper::stream_metadata()` vfsStream now supports `touch()`, `chown()`, `chgrp()` and `chmod()`
47
+ * implemented issue #33: add support for `stream_truncate()` (provided by https://github.com/nikcorg)
48
+ * implemented issue #35: size limit (quota) for VFS
49
+
50
+
51
+ 1.0.0 (2012-05-15)
52
+ ------------------
53
+
54
+ * raised requirement for PHP version to 5.3.0
55
+ * migrated codebase to use namespaces
56
+ * changed distribution from PEAR to Composer
57
+ * implemented issue #30: support "c" mode for `fopen()`
58
+ * fixed issue #31: prohibit aquiring locks when already locked / release lock on `fclose()`
59
+ * fixed issue #32: problems when subfolder has same name as folder
60
+ * fixed issue #36: `vfsStreamWrapper::stream_open()` should return false while trying to open existing non-writable file, patch provided by Alexander Peresypkin
61
+
62
+
63
+ 0.11.2 (2012-01-14)
64
+ -------------------
65
+
66
+ * fixed issue #29: set permissions properly when using `vfsStream::copyFromFileSystem()`, patch provided by predakanga
67
+ * fixed failing tests under PHP > 5.3.2
68
+
69
+
70
+ 0.11.1 (2011-12-04)
71
+ -------------------
72
+
73
+ * fixed issue #28: `mkdir()` overwrites existing directories/files
74
+
75
+
76
+ 0.11.0 (2011-11-29)
77
+ -------------------
78
+
79
+ * implemented issue #20: `vfsStream::create()` removes old structure
80
+ * implemented issue #4: possibility to copy structure from existing file system
81
+ * fixed issue #23: `unlink()` should not remove any directory
82
+ * fixed issue #25: `vfsStreamDirectory::hasChild()` gives false positives for nested paths, patch provided by Andrew Coulton
83
+ * fixed issue #26: opening a file for reading only should not update its modification time, reported and initial patch provided by Ludovic Chabant
84
+
85
+
86
+ 0.10.1 (2011-08-22)
87
+ -------------------
88
+
89
+ * fixed issue #16: replace `vfsStreamContent` to `vfsStreamContainer` for autocompletion
90
+ * fixed issue #17: `vfsStream::create()` has issues with numeric directories, patch provided by mathieuk
91
+
92
+
93
+ 0.10.0 (2011-07-22)
94
+ -------------------
95
+
96
+ * added new method `vfsStreamContainer::hasChildren()` and `vfsStreamDirectory::hasChildren()`
97
+ * implemented issue #14: less verbose way to initialize vfsStream
98
+ * implemented issue #13: remove deprecated method `vfsStreamContent::setFilemtime()`
99
+ * implemented issue #6: locking meachanism for files
100
+ * ensured that `stream_set_blocking()`, `stream_set_timeout()` and `stream_set_write_buffer()` on vfsStream urls have the same behaviour with PHP 5.2 and 5.3
101
+ * implemented issue #10: method to print directory structure
102
+
103
+
104
+ 0.9.0 (2011-07-13)
105
+ ------------------
106
+
107
+ * implemented feature request issue #7: add support for `fileatime()` and `filectime()`
108
+ * fixed issue #3: add support for `streamWrapper::stream_cast()`
109
+ * fixed issue #9: resolve path not called everywhere its needed
110
+ * deprecated `vfsStreamAbstractContent::setFilemtime()`, use `vfsStreamAbstractContent::lastModified()` instead, will be removed with 0.10.0
111
+
112
+
113
+ 0.8.0 (2010-10-08)
114
+ ------------------
115
+
116
+ * implemented enhancement #6: use `vfsStream::umask()` to influence initial file mode for files and directories
117
+ * implemented enhancement #19: support of .. in the url, patch provided by Guislain Duthieuw
118
+ * fixed issue #18: `getChild()` returns NULL when child's name contains parent name
119
+ * fixed bug with incomplete error message when accessing non-existing files on root level
120
+
121
+
122
+ 0.7.0 (2010-06-08)
123
+ ------------------
124
+
125
+ * added new `vfsStream::setup()` method to simplify vfsStream usage
126
+ * fixed issue #15: `mkdir()` creates a subfolder in a folder without permissions
127
+
128
+
129
+ 0.6.0 (2010-02-15)
130
+ ------------------
131
+
132
+ * added support for `$mode` param when opening files, implements enhancement #7 and fixes issue #13
133
+ * `vfsStreamWrapper::stream_open()` now evaluates `$options` for `STREAM_REPORT_ERRORS`
134
+
135
+
136
+ 0.5.0 (2010-01-25)
137
+ ------------------
138
+
139
+ * added support for `rename()`, patch provided by Benoit Aubuchon
140
+ * added support for . as directory alias so that `vfs://foo/.` resolves to `vfs://foo`, can be used as workaround for bug #8
141
+
142
+
143
+ 0.4.0 (2009-07-13)
144
+ ------------------
145
+
146
+ * added support for file modes, users and groups (with restrictions, see http://code.google.com/p/bovigo/wiki/vfsStreamDocsKnownIssues)
147
+ * fixed bug #5: `vfsStreamDirectory::addChild()` does not replace child with same name
148
+ * fixed bug with `is_writable()` because of missing `stat()` fields, patch provided by Sergey Galkin
149
+
150
+
151
+ 0.3.2 (2009-02-16)
152
+ ------------------
153
+
154
+ * support trailing slashes on directories in vfsStream urls, patch provided by Gabriel Birke
155
+ * fixed bug #4: vfsstream can only be read once, reported by Christoph Bloemer
156
+ * enabled multiple iterations at the same time over the same directory
157
+
158
+
159
+ 0.3.1 (2008-02-18)
160
+ ------------------
161
+
162
+ * fixed path/directory separator issues under linux systems
163
+ * fixed uid/gid issues under linux systems
164
+
165
+
166
+ 0.3.0 (2008-01-02)
167
+ ------------------
168
+
169
+ * added support for `rmdir()`
170
+ * added `vfsStream::newDirectory()`, dropped `vfsStreamDirectory::ceate()`
171
+ * added new interface `vfsStreamContainer`
172
+ * added `vfsStreamContent::at()` which allows code like `$file = vfsStream::newFile('file.txt.')->withContent('foo')->at($otherDir);`
173
+ * added `vfsStreamContent::lastModified()`, made `vfsStreamContent::setFilemtime()` an alias for this
174
+ * moved from Stubbles development environment to bovigo
175
+ * refactorings to reduce crap index of various methods
176
+
177
+
178
+ 0.2.0 (2007-12-29)
179
+ ------------------
180
+
181
+ * moved `vfsStreamWrapper::PROTOCOL` to `vfsStream::SCHEME`
182
+ * added new `vfsStream::url()` method to assist in creating correct vfsStream urls
183
+ * added `vfsStream::path()` method as opposite to `vfsStream::url()`
184
+ * a call to `vfsStreamWrapper::register()` will now reset the root to null, implemented on request from David Zuelke
185
+ * added support for `is_readable()`, `is_dir()`, `is_file()`
186
+ * added `vfsStream::newFile()` to be able to do `$file = vfsStream::newFile("foo.txt")->withContent("bar");`
187
+
188
+
189
+ 0.1.0 (2007-12-14)
190
+ ------------------
191
+
192
+ * Initial release.
vendor/mikey179/vfsStream/LICENSE ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2007-2015, Frank Kleine
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are
6
+ met:
7
+
8
+ * Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+ * Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+ * Neither the name of Stubbles nor the names of its
14
+ contributors may be used to endorse or promote products derived
15
+ from this software without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21
+ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
vendor/mikey179/vfsStream/README.md ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ You can find documentation in the [wiki](https://github.com/mikey179/vfsStream/wiki).
2
+
3
+ Also you might want to check [vfsStream examples](https://github.com/mikey179/vfsStream-examples).
4
+
5
+
6
+ [![Build Status](https://secure.travis-ci.org/mikey179/vfsStream.png)](http://travis-ci.org/mikey179/vfsStream) [![Coverage Status](https://coveralls.io/repos/mikey179/vfsStream/badge.png?branch=master)](https://coveralls.io/r/mikey179/vfsStream?branch=master)
7
+
8
+ [![Latest Stable Version](https://poser.pugx.org/mikey179/vfsStream/version.png)](https://packagist.org/packages/mikey179/vfsStream) [![Latest Unstable Version](https://poser.pugx.org/mikey179/vfsStream/v/unstable.png)](//packagist.org/packages/mikey179/vfsStream)
vendor/mikey179/vfsStream/composer.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "mikey179/vfsStream",
3
+ "type": "library",
4
+ "homepage": "http://vfs.bovigo.org/",
5
+ "description": "Virtual file system to mock the real file system in unit tests.",
6
+ "license": "BSD-3-Clause",
7
+ "authors": [
8
+ {
9
+ "name": "Frank Kleine",
10
+ "homepage": "http://frankkleine.de/",
11
+ "role": "Developer"
12
+ }
13
+ ],
14
+ "support": {
15
+ "issues": "https://github.com/mikey179/vfsStream/issues",
16
+ "source": "https://github.com/mikey179/vfsStream/tree/master",
17
+ "wiki": "https://github.com/mikey179/vfsStream/wiki"
18
+ },
19
+ "require": {
20
+ "php": ">=5.3.0"
21
+ },
22
+ "require-dev": {
23
+ "phpunit/phpunit": "~4.5"
24
+ },
25
+ "autoload": {
26
+ "psr-0": { "org\\bovigo\\vfs\\": "src/main/php" }
27
+ },
28
+ "extra": {
29
+ "branch-alias": {
30
+ "dev-master": "1.5.x-dev"
31
+ }
32
+ }
33
+ }
vendor/mikey179/vfsStream/examples/Example.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
12
+ * Example class.
13
+ */
14
+ class Example
15
+ {
16
+ /**
17
+ * id of the example
18
+ *
19
+ * @type string
20
+ */
21
+ protected $id;
22
+ /**
23
+ * a directory where we do something..
24
+ *
25
+ * @type string
26
+ */
27
+ protected $directory;
28
+
29
+ /**
30
+ * constructor
31
+ *
32
+ * @param string $id
33
+ */
34
+ public function __construct($id)
35
+ {
36
+ $this->id = $id;
37
+ }
38
+
39
+ /**
40
+ * sets the directory
41
+ *
42
+ * @param string $directory
43
+ */
44
+ public function setDirectory($directory)
45
+ {
46
+ $this->directory = $directory . DIRECTORY_SEPARATOR . $this->id;
47
+ if (file_exists($this->directory) === false) {
48
+ mkdir($this->directory, 0700, true);
49
+ }
50
+ }
51
+
52
+ // more source code here...
53
+ }
54
+ ?>
vendor/mikey179/vfsStream/examples/ExampleTestCaseOldWay.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 'Example.php';
12
+ /**
13
+ * Test case for class Example.
14
+ */
15
+ class ExampleTestCaseOldWay 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
+ /**
28
+ * clear up test environment
29
+ */
30
+ public function tearDown()
31
+ {
32
+ if (file_exists(__DIR__ . '/id') === true) {
33
+ rmdir(__DIR__ . '/id');
34
+ }
35
+ }
36
+
37
+ /**
38
+ * @test
39
+ */
40
+ public function directoryIsCreated()
41
+ {
42
+ $example = new Example('id');
43
+ $this->assertFalse(file_exists(__DIR__ . '/id'));
44
+ $example->setDirectory(__DIR__);
45
+ $this->assertTrue(file_exists(__DIR__ . '/id'));
46
+ }
47
+ }
48
+ ?>
vendor/mikey179/vfsStream/examples/ExampleTestCaseWithVfsStream.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ use org\bovigo\vfs\vfsStream;
12
+ require_once 'Example.php';
13
+ /**
14
+ * Test case for class Example.
15
+ *
16
+ * @package bovigo_vfs
17
+ * @subpackage examples
18
+ */
19
+ class ExampleTestCaseWithVfsStream extends \PHPUnit_Framework_TestCase
20
+ {
21
+ /**
22
+ * root directory
23
+ *
24
+ * @type vfsStreamDirectory
25
+ */
26
+ protected $root;
27
+
28
+ /**
29
+ * set up test environmemt
30
+ */
31
+ public function setUp()
32
+ {
33
+ $this->root = vfsStream::setup('exampleDir');
34
+ }
35
+
36
+ /**
37
+ * @test
38
+ */
39
+ public function directoryIsCreated()
40
+ {
41
+ $example = new Example('id');
42
+ $this->assertFalse($this->root->hasChild('id'));
43
+ $example->setDirectory(vfsStream::url('exampleDir'));
44
+ $this->assertTrue($this->root->hasChild('id'));
45
+ }
46
+ }
47
+ ?>
vendor/mikey179/vfsStream/examples/FailureExample.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
12
+ * Example class to demonstrate testing of failure behaviour with vfsStream.
13
+ */
14
+ class FailureExample
15
+ {
16
+ /**
17
+ * filename to write data
18
+ *
19
+ * @type string
20
+ */
21
+ protected $filename;
22
+
23
+ /**
24
+ * constructor
25
+ *
26
+ * @param string $id
27
+ */
28
+ public function __construct($filename)
29
+ {
30
+ $this->filename = $filename;
31
+ }
32
+
33
+ /**
34
+ * sets the directory
35
+ *
36
+ * @param string $directory
37
+ */
38
+ public function writeData($data)
39
+ {
40
+ $bytes = @file_put_contents($this->filename, $data);
41
+ if (false === $bytes) {
42
+ return 'could not write data';
43
+ }
44
+
45
+ return 'ok';
46
+ }
47
+
48
+ // more source code here...
49
+ }
50
+ ?>
vendor/mikey179/vfsStream/examples/FailureExampleTestCase.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ use org\bovigo\vfs\vfsStream;
12
+ require_once 'FailureExample.php';
13
+ /**
14
+ * Test case for class FailureExample.
15
+ */
16
+ class FailureExampleTestCase extends \PHPUnit_Framework_TestCase
17
+ {
18
+ /**
19
+ * root directory
20
+ *
21
+ * @type vfsStreamDirectory
22
+ */
23
+ protected $root;
24
+
25
+ /**
26
+ * set up test environmemt
27
+ */
28
+ public function setUp()
29
+ {
30
+ $this->root = vfsStream::setup('exampleDir');
31
+ }
32
+
33
+ /**
34
+ * @test
35
+ */
36
+ public function returnsOkOnNoFailure()
37
+ {
38
+ $example = new FailureExample(vfsStream::url('exampleDir/test.txt'));
39
+ $this->assertSame('ok', $example->writeData('testdata'));
40
+ $this->assertTrue($this->root->hasChild('test.txt'));
41
+ $this->assertSame('testdata', $this->root->getChild('test.txt')->getContent());
42
+ }
43
+
44
+ /**
45
+ * @test
46
+ */
47
+ public function returnsErrorMessageIfWritingToFileFails()
48
+ {
49
+ $file = vfsStream::newFile('test.txt', 0000)
50
+ ->withContent('notoverwritten')
51
+ ->at($this->root);
52
+ $example = new FailureExample(vfsStream::url('exampleDir/test.txt'));
53
+ $this->assertSame('could not write data', $example->writeData('testdata'));
54
+ $this->assertTrue($this->root->hasChild('test.txt'));
55
+ $this->assertSame('notoverwritten', $this->root->getChild('test.txt')->getContent());
56
+ }
57
+ }
58
+ ?>
vendor/mikey179/vfsStream/examples/FileModeExampleTestCaseOldWay.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
28
+ * clear up test environment
29
+ */
30
+ public function tearDown()
31
+ {
32
+ if (file_exists(__DIR__ . '/id') === true) {
33
+ rmdir(__DIR__ . '/id');
34
+ }
35
+ }
36
+
37
+ /**
38
+ * test correct file mode for created directory
39
+ */
40
+ public function testDirectoryHasCorrectDefaultFilePermissions()
41
+ {
42
+ $example = new FilemodeExample('id');
43
+ $example->setDirectory(__DIR__);
44
+ if (DIRECTORY_SEPARATOR === '\\') {
45
+ // can not really test on windows, filemode from mkdir() is ignored
46
+ $this->assertEquals(40777, decoct(fileperms(__DIR__ . '/id')));
47
+ } else {
48
+ $this->assertEquals(40700, decoct(fileperms(__DIR__ . '/id')));
49
+ }
50
+ }
51
+
52
+ /**
53
+ * test correct file mode for created directory
54
+ */
55
+ public function testDirectoryHasCorrectDifferentFilePermissions()
56
+ {
57
+ $example = new FilemodeExample('id', 0755);
58
+ $example->setDirectory(__DIR__);
59
+ if (DIRECTORY_SEPARATOR === '\\') {
60
+ // can not really test on windows, filemode from mkdir() is ignored
61
+ $this->assertEquals(40777, decoct(fileperms(__DIR__ . '/id')));
62
+ } else {
63
+ $this->assertEquals(40755, decoct(fileperms(__DIR__ . '/id')));
64
+ }
65
+ }
66
+ }
67
+ ?>
vendor/mikey179/vfsStream/examples/FilePermissionsExample.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
12
+ * Example showing correct file permission support introduced with 0.7.0.
13
+ */
14
+ class FilePermissionsExample
15
+ {
16
+ /**
17
+ * reads configuration from given config file
18
+ *
19
+ * @param mixed $config
20
+ * @param string $configFile
21
+ */
22
+ public function writeConfig($config, $configFile)
23
+ {
24
+ @file_put_contents($configFile, serialize($config));
25
+ }
26
+
27
+ // more methods here
28
+ }
29
+ ?>
vendor/mikey179/vfsStream/examples/FilePermissionsExampleTestCase.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ use org\bovigo\vfs\vfsStream;
12
+ require_once 'FilePermissionsExample.php';
13
+ /**
14
+ * Test for FilePermissionsExample.
15
+ */
16
+ class FilePermissionsExampleTestCase extends \PHPUnit_Framework_TestCase
17
+ {
18
+ /**
19
+ * @test
20
+ */
21
+ public function directoryWritable()
22
+ {
23
+ vfsStream::setup('exampleDir');
24
+ $example = new FilePermissionsExample();
25
+ $example->writeConfig(array('foo' => 'bar'),
26
+ vfsStream::url('exampleDir/writable.ini')
27
+ );
28
+
29
+ // assertions here
30
+ }
31
+
32
+ /**
33
+ * @test
34
+ */
35
+ public function directoryNotWritable()
36
+ {
37
+ vfsStream::setup('exampleDir', 0444);
38
+ $example = new FilePermissionsExample();
39
+ $example->writeConfig(array('foo' => 'bar'),
40
+ vfsStream::url('exampleDir/notWritable.ini')
41
+ );
42
+ }
43
+ }
44
+ ?>
vendor/mikey179/vfsStream/examples/FilemodeExample.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
12
+ * Example class.
13
+ */
14
+ class FilemodeExample
15
+ {
16
+ /**
17
+ * id of the example
18
+ *
19
+ * @type string
20
+ */
21
+ protected $id;
22
+ /**
23
+ * a directory where we do something..
24
+ *
25
+ * @type string
26
+ */
27
+ protected $directory;
28
+ /**
29
+ * file mode for newly created directories
30
+ *
31
+ * @type int
32
+ */
33
+ protected $fileMode;
34
+
35
+ /**
36
+ * constructor
37
+ *
38
+ * @param string $id
39
+ * @param int $fileMode optional
40
+ */
41
+ public function __construct($id, $fileMode = 0700)
42
+ {
43
+ $this->id = $id;
44
+ $this->fileMode = $fileMode;
45
+ }
46
+
47
+ /**
48
+ * sets the directory
49
+ *
50
+ * @param string $directory
51
+ */
52
+ public function setDirectory($directory)
53
+ {
54
+ $this->directory = $directory . DIRECTORY_SEPARATOR . $this->id;
55
+ if (file_exists($this->directory) === false) {
56
+ mkdir($this->directory, $this->fileMode, true);
57
+ }
58
+ }
59
+
60
+ // more source code here...
61
+ }
62
+ ?>
vendor/mikey179/vfsStream/examples/FilemodeExampleTestCaseWithVfsStream.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ use org\bovigo\vfs\vfsStream;
12
+ require_once 'FilemodeExample.php';
13
+ /**
14
+ * Test case for class FilemodeExample.
15
+ */
16
+ class FilemodeExampleTestCaseWithVfsStream extends \PHPUnit_Framework_TestCase
17
+ {
18
+ /**
19
+ * root directory
20
+ *
21
+ * @type vfsStreamDirectory
22
+ */
23
+ protected $root;
24
+
25
+ /**
26
+ * set up test environmemt
27
+ */
28
+ public function setUp()
29
+ {
30
+ $this->root = vfsStream::setup('exampleDir');
31
+ }
32
+
33
+ /**
34
+ * test that the directory is created
35
+ */
36
+ public function testDirectoryIsCreatedWithDefaultPermissions()
37
+ {
38
+ $example = new FilemodeExample('id');
39
+ $example->setDirectory(vfsStream::url('exampleDir'));
40
+ $this->assertEquals(0700, $this->root->getChild('id')->getPermissions());
41
+ }
42
+
43
+ /**
44
+ * test that the directory is created
45
+ */
46
+ public function testDirectoryIsCreatedWithGivenPermissions()
47
+ {
48
+ $example = new FilemodeExample('id', 0755);
49
+ $example->setDirectory(vfsStream::url('exampleDir'));
50
+ $this->assertEquals(0755, $this->root->getChild('id')->getPermissions());
51
+ }
52
+ }
53
+ ?>
vendor/mikey179/vfsStream/examples/bootstrap.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ require __DIR__ . '/../vendor/.composer/autoload.php';
3
+ ?>
vendor/mikey179/vfsStream/phpdoc.dist.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <phpdoc>
3
+ <title>vfsStream API Doc</title>
4
+ <parser>
5
+ <target>docs/api</target>
6
+ <default-package-name>org\bovigo\vfs</default-package-name>
7
+ </parser>
8
+ <transformer>
9
+ <target>docs/api</target>
10
+ </transformer>
11
+ <files>
12
+ <directory>src/main/php</directory>
13
+ </files>
14
+ </phpdoc>
vendor/mikey179/vfsStream/phpunit.xml.dist ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <phpunit backupGlobals="false"
3
+ backupStaticAttributes="false"
4
+ bootstrap="vendor/autoload.php"
5
+ colors="true"
6
+ convertErrorsToExceptions="true"
7
+ convertNoticesToExceptions="true"
8
+ convertWarningsToExceptions="true"
9
+ forceCoversAnnotation="false"
10
+ mapTestClassNameToCoveredClassName="false"
11
+ printerClass="PHPUnit_TextUI_ResultPrinter"
12
+ processIsolation="false"
13
+ stopOnError="false"
14
+ stopOnFailure="false"
15
+ stopOnIncomplete="false"
16
+ stopOnSkipped="false"
17
+ verbose="true">
18
+ <testsuites>
19
+ <testsuite>
20
+ <directory suffix="TestCase.php">./src/test/php</directory>
21
+ </testsuite>
22
+ </testsuites>
23
+
24
+ <filter>
25
+ <whitelist>
26
+ <directory>src/main/php</directory>
27
+ </whitelist>
28
+ </filter>
29
+
30
+ <logging>
31
+ <log type="coverage-html" target="docs/coverage" charset="UTF-8"
32
+ yui="true" highlight="false"
33
+ lowUpperBound="35" highLowerBound="70"/>
34
+ <log type="coverage-clover" target="docs/phpunit/clover.xml"/>
35
+ <log type="junit" target="docs/phpunit/junit.xml" logIncompleteSkipped="false"/>
36
+ <log type="testdox-html" target="docs/phpunit/testdox.html"/>
37
+ </logging>
38
+
39
+ <php>
40
+ <ini name="memory_limit" value="-1"/>
41
+ </php>
42
+ </phpunit>
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/DotDirectory.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Directory container.
13
+ */
14
+ class DotDirectory extends vfsStreamDirectory
15
+ {
16
+ /**
17
+ * returns iterator for the children
18
+ *
19
+ * @return vfsStreamContainerIterator
20
+ */
21
+ public function getIterator()
22
+ {
23
+ return new \ArrayIterator(array());
24
+ }
25
+
26
+ /**
27
+ * checks whether dir is a dot dir
28
+ *
29
+ * @return bool
30
+ */
31
+ public function isDot()
32
+ {
33
+ return true;
34
+ }
35
+ }
36
+ ?>
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/Quota.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Represents a quota for disk space.
13
+ *
14
+ * @since 1.1.0
15
+ * @internal
16
+ */
17
+ class Quota
18
+ {
19
+ /**
20
+ * unlimited quota
21
+ */
22
+ const UNLIMITED = -1;
23
+ /**
24
+ * quota in bytes
25
+ *
26
+ * A value of -1 is treated as unlimited.
27
+ *
28
+ * @type int
29
+ */
30
+ private $amount;
31
+
32
+ /**
33
+ * constructor
34
+ *
35
+ * @param int $amount quota in bytes
36
+ */
37
+ public function __construct($amount)
38
+ {
39
+ $this->amount = $amount;
40
+ }
41
+
42
+ /**
43
+ * create with unlimited space
44
+ *
45
+ * @return Quota
46
+ */
47
+ public static function unlimited()
48
+ {
49
+ return new self(self::UNLIMITED);
50
+ }
51
+
52
+ /**
53
+ * checks if a quota is set
54
+ *
55
+ * @return bool
56
+ */
57
+ public function isLimited()
58
+ {
59
+ return self::UNLIMITED < $this->amount;
60
+ }
61
+
62
+ /**
63
+ * checks if given used space exceeda quota limit
64
+ *
65
+ *
66
+ * @param int $usedSpace
67
+ * @return int
68
+ */
69
+ public function spaceLeft($usedSpace)
70
+ {
71
+ if (self::UNLIMITED === $this->amount) {
72
+ return $usedSpace;
73
+ }
74
+
75
+ if ($usedSpace >= $this->amount) {
76
+ return 0;
77
+ }
78
+
79
+ $spaceLeft = $this->amount - $usedSpace;
80
+ if (0 >= $spaceLeft) {
81
+ return 0;
82
+ }
83
+
84
+ return $spaceLeft;
85
+ }
86
+ }
87
+ ?>
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/FileContent.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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\content;
11
+ /**
12
+ * Interface for actual file contents.
13
+ *
14
+ * @since 1.3.0
15
+ */
16
+ interface FileContent
17
+ {
18
+ /**
19
+ * returns actual content
20
+ *
21
+ * @return string
22
+ */
23
+ public function content();
24
+
25
+ /**
26
+ * returns size of content
27
+ *
28
+ * @return int
29
+ */
30
+ public function size();
31
+
32
+ /**
33
+ * reads the given amount of bytes from content
34
+ *
35
+ * @param int $count
36
+ * @return string
37
+ */
38
+ public function read($count);
39
+
40
+ /**
41
+ * seeks to the given offset
42
+ *
43
+ * @param int $offset
44
+ * @param int $whence
45
+ * @return bool
46
+ */
47
+ public function seek($offset, $whence);
48
+
49
+ /**
50
+ * checks whether pointer is at end of file
51
+ *
52
+ * @return bool
53
+ */
54
+ public function eof();
55
+
56
+ /**
57
+ * writes an amount of data
58
+ *
59
+ * @param string $data
60
+ * @return amount of written bytes
61
+ */
62
+ public function write($data);
63
+
64
+ /**
65
+ * Truncates a file to a given length
66
+ *
67
+ * @param int $size length to truncate file to
68
+ * @return bool
69
+ */
70
+ public function truncate($size);
71
+ }
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/LargeFileContent.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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\content;
11
+ /**
12
+ * File content implementation to mock large files.
13
+ *
14
+ * When content is written via write() the data will be written into the
15
+ * positions according to the current offset.
16
+ * When content is read via read() it will use the already written data. If no
17
+ * data is written at the offsets to read those offsets will be filled with
18
+ * spaces.
19
+ * Please note that accessing the whole content via content() will deliver a
20
+ * string with the length of the originally defined size. It is not advisable to
21
+ * do so with large sizes, except you have enough memory and time. :-)
22
+ *
23
+ * @since 1.3.0
24
+ */
25
+ class LargeFileContent extends SeekableFileContent implements FileContent
26
+ {
27
+ /**
28
+ * byte array of written content
29
+ *
30
+ * @type char[]
31
+ */
32
+ private $content = array();
33
+ /**
34
+ * file size in bytes
35
+ *
36
+ * @type int
37
+ */
38
+ private $size;
39
+
40
+ /**
41
+ * constructor
42
+ *
43
+ * @param int $size file size in bytes
44
+ */
45
+ public function __construct($size)
46
+ {
47
+ $this->size = $size;
48
+ }
49
+
50
+ /**
51
+ * create large file with given size in kilobyte
52
+ *
53
+ * @param int $kilobyte
54
+ * @return LargeFileContent
55
+ */
56
+ public static function withKilobytes($kilobyte)
57
+ {
58
+ return new self($kilobyte * 1024);
59
+ }
60
+
61
+ /**
62
+ * create large file with given size in megabyte
63
+ *
64
+ * @param int $megabyte
65
+ * @return LargeFileContent
66
+ */
67
+ public static function withMegabytes($megabyte)
68
+ {
69
+ return self::withKilobytes($megabyte * 1024);
70
+ }
71
+
72
+ /**
73
+ * create large file with given size in gigabyte
74
+ *
75
+ * @param int $gigabyte
76
+ * @return LargeFileContent
77
+ */
78
+ public static function withGigabytes($gigabyte)
79
+ {
80
+ return self::withMegabytes($gigabyte * 1024);
81
+ }
82
+
83
+ /**
84
+ * returns actual content
85
+ *
86
+ * @return string
87
+ */
88
+ public function content()
89
+ {
90
+ return $this->doRead(0, $this->size);
91
+ }
92
+
93
+ /**
94
+ * returns size of content
95
+ *
96
+ * @return int
97
+ */
98
+ public function size()
99
+ {
100
+ return $this->size;
101
+ }
102
+
103
+ /**
104
+ * actual reading of given byte count starting at given offset
105
+ *
106
+ * @param int $offset
107
+ * @param int $count
108
+ */
109
+ protected function doRead($offset, $count)
110
+ {
111
+ if (($offset + $count) > $this->size) {
112
+ $count = $this->size - $offset;
113
+ }
114
+
115
+ $result = '';
116
+ for ($i = 0; $i < $count; $i++) {
117
+ if (isset($this->content[$i + $offset])) {
118
+ $result .= $this->content[$i + $offset];
119
+ } else {
120
+ $result .= ' ';
121
+ }
122
+ }
123
+
124
+ return $result;
125
+ }
126
+
127
+ /**
128
+ * actual writing of data with specified length at given offset
129
+ *
130
+ * @param string $data
131
+ * @param int $offset
132
+ * @param int $length
133
+ */
134
+ protected function doWrite($data, $offset, $length)
135
+ {
136
+ for ($i = 0; $i < $length; $i++) {
137
+ $this->content[$i + $offset] = $data{$i};
138
+ }
139
+
140
+ if ($offset >= $this->size) {
141
+ $this->size += $length;
142
+ } elseif (($offset + $length) > $this->size) {
143
+ $this->size = $offset + $length;
144
+ }
145
+ }
146
+
147
+ /**
148
+ * Truncates a file to a given length
149
+ *
150
+ * @param int $size length to truncate file to
151
+ * @return bool
152
+ */
153
+ public function truncate($size)
154
+ {
155
+ $this->size = $size;
156
+ foreach (array_filter(array_keys($this->content),
157
+ function($pos) use ($size)
158
+ {
159
+ return $pos >= $size;
160
+ }
161
+ ) as $removePos) {
162
+ unset($this->content[$removePos]);
163
+ }
164
+
165
+ return true;
166
+ }
167
+ }
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/SeekableFileContent.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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\content;
11
+ /**
12
+ * Default implementation for file contents based on simple strings.
13
+ *
14
+ * @since 1.3.0
15
+ */
16
+ abstract class SeekableFileContent implements FileContent
17
+ {
18
+ /**
19
+ * current position within content
20
+ *
21
+ * @type int
22
+ */
23
+ private $offset = 0;
24
+
25
+ /**
26
+ * reads the given amount of bytes from content
27
+ *
28
+ * @param int $count
29
+ * @return string
30
+ */
31
+ public function read($count)
32
+ {
33
+ $data = $this->doRead($this->offset, $count);
34
+ $this->offset += $count;
35
+ return $data;
36
+ }
37
+
38
+ /**
39
+ * actual reading of given byte count starting at given offset
40
+ *
41
+ * @param int $offset
42
+ * @param int $count
43
+ */
44
+ protected abstract function doRead($offset, $count);
45
+
46
+ /**
47
+ * seeks to the given offset
48
+ *
49
+ * @param int $offset
50
+ * @param int $whence
51
+ * @return bool
52
+ */
53
+ public function seek($offset, $whence)
54
+ {
55
+ switch ($whence) {
56
+ case SEEK_CUR:
57
+ $this->offset += $offset;
58
+ return true;
59
+
60
+ case SEEK_END:
61
+ $this->offset = $this->size() + $offset;
62
+ return true;
63
+
64
+ case SEEK_SET:
65
+ $this->offset = $offset;
66
+ return true;
67
+
68
+ default:
69
+ return false;
70
+ }
71
+
72
+ return false;
73
+ }
74
+
75
+ /**
76
+ * checks whether pointer is at end of file
77
+ *
78
+ * @return bool
79
+ */
80
+ public function eof()
81
+ {
82
+ return $this->size() <= $this->offset;
83
+ }
84
+
85
+ /**
86
+ * writes an amount of data
87
+ *
88
+ * @param string $data
89
+ * @return amount of written bytes
90
+ */
91
+ public function write($data)
92
+ {
93
+ $dataLength = strlen($data);
94
+ $this->doWrite($data, $this->offset, $dataLength);
95
+ $this->offset += $dataLength;
96
+ return $dataLength;
97
+ }
98
+
99
+ /**
100
+ * actual writing of data with specified length at given offset
101
+ *
102
+ * @param string $data
103
+ * @param int $offset
104
+ * @param int $length
105
+ */
106
+ protected abstract function doWrite($data, $offset, $length);
107
+
108
+ /**
109
+ * for backwards compatibility with vfsStreamFile::bytesRead()
110
+ *
111
+ * @return int
112
+ * @deprecated
113
+ */
114
+ public function bytesRead()
115
+ {
116
+ return $this->offset;
117
+ }
118
+
119
+ /**
120
+ * for backwards compatibility with vfsStreamFile::readUntilEnd()
121
+ *
122
+ * @return string
123
+ * @deprecated
124
+ */
125
+ public function readUntilEnd()
126
+ {
127
+ return substr($this->content(), $this->offset);
128
+ }
129
+ }
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/content/StringBasedFileContent.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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\content;
11
+ /**
12
+ * Default implementation for file contents based on simple strings.
13
+ *
14
+ * @since 1.3.0
15
+ */
16
+ class StringBasedFileContent extends SeekableFileContent implements FileContent
17
+ {
18
+ /**
19
+ * actual content
20
+ *
21
+ * @type string
22
+ */
23
+ private $content;
24
+
25
+ /**
26
+ * constructor
27
+ *
28
+ * @param string $content
29
+ */
30
+ public function __construct($content)
31
+ {
32
+ $this->content = $content;
33
+ }
34
+
35
+ /**
36
+ * returns actual content
37
+ *
38
+ * @return string
39
+ */
40
+ public function content()
41
+ {
42
+ return $this->content;
43
+ }
44
+
45
+ /**
46
+ * returns size of content
47
+ *
48
+ * @return int
49
+ */
50
+ public function size()
51
+ {
52
+ return strlen($this->content);
53
+ }
54
+
55
+ /**
56
+ * actual reading of length starting at given offset
57
+ *
58
+ * @param int $offset
59
+ * @param int $count
60
+ */
61
+ protected function doRead($offset, $count)
62
+ {
63
+ return substr($this->content, $offset, $count);
64
+ }
65
+
66
+ /**
67
+ * actual writing of data with specified length at given offset
68
+ *
69
+ * @param string $data
70
+ * @param int $offset
71
+ * @param int $length
72
+ */
73
+ protected function doWrite($data, $offset, $length)
74
+ {
75
+ $this->content = substr($this->content, 0, $offset)
76
+ . $data
77
+ . substr($this->content, $offset + $length);
78
+ }
79
+
80
+ /**
81
+ * Truncates a file to a given length
82
+ *
83
+ * @param int $size length to truncate file to
84
+ * @return bool
85
+ */
86
+ public function truncate($size)
87
+ {
88
+ if ($size > $this->size()) {
89
+ // Pad with null-chars if we're "truncating up"
90
+ $this->content .= str_repeat("\0", $size - $this->size());
91
+ } else {
92
+ $this->content = substr($this->content, 0, $size);
93
+ }
94
+
95
+ return true;
96
+ }
97
+ }
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStream.php ADDED
@@ -0,0 +1,462 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ use org\bovigo\vfs\content\LargeFileContent;
12
+ use org\bovigo\vfs\visitor\vfsStreamVisitor;
13
+ /**
14
+ * Some utility methods for vfsStream.
15
+ *
16
+ * @api
17
+ */
18
+ class vfsStream
19
+ {
20
+ /**
21
+ * url scheme
22
+ */
23
+ const SCHEME = 'vfs';
24
+ /**
25
+ * owner: root
26
+ */
27
+ const OWNER_ROOT = 0;
28
+ /**
29
+ * owner: user 1
30
+ */
31
+ const OWNER_USER_1 = 1;
32
+ /**
33
+ * owner: user 2
34
+ */
35
+ const OWNER_USER_2 = 2;
36
+ /**
37
+ * group: root
38
+ */
39
+ const GROUP_ROOT = 0;
40
+ /**
41
+ * group: user 1
42
+ */
43
+ const GROUP_USER_1 = 1;
44
+ /**
45
+ * group: user 2
46
+ */
47
+ const GROUP_USER_2 = 2;
48
+ /**
49
+ * initial umask setting
50
+ *
51
+ * @type int
52
+ */
53
+ protected static $umask = 0000;
54
+ /**
55
+ * switch whether dotfiles are enabled in directory listings
56
+ *
57
+ * @type bool
58
+ */
59
+ private static $dotFiles = true;
60
+
61
+ /**
62
+ * prepends the scheme to the given URL
63
+ *
64
+ * @param string $path path to translate to vfsStream url
65
+ * @return string
66
+ */
67
+ public static function url($path)
68
+ {
69
+ return self::SCHEME . '://' . str_replace('\\', '/', $path);
70
+ }
71
+
72
+ /**
73
+ * restores the path from the url
74
+ *
75
+ * @param string $url vfsStream url to translate into path
76
+ * @return string
77
+ */
78
+ public static function path($url)
79
+ {
80
+ // remove line feeds and trailing whitespaces and path separators
81
+ $path = trim($url, " \t\r\n\0\x0B/\\");
82
+ $path = substr($path, strlen(self::SCHEME . '://'));
83
+ $path = str_replace('\\', '/', $path);
84
+ // replace double slashes with single slashes
85
+ $path = str_replace('//', '/', $path);
86
+ return urldecode($path);
87
+ }
88
+
89
+ /**
90
+ * sets new umask setting and returns previous umask setting
91
+ *
92
+ * If no value is given only the current umask setting is returned.
93
+ *
94
+ * @param int $umask new umask setting
95
+ * @return int
96
+ * @since 0.8.0
97
+ */
98
+ public static function umask($umask = null)
99
+ {
100
+ $oldUmask = self::$umask;
101
+ if (null !== $umask) {
102
+ self::$umask = $umask;
103
+ }
104
+
105
+ return $oldUmask;
106
+ }
107
+
108
+ /**
109
+ * helper method for setting up vfsStream in unit tests
110
+ *
111
+ * Instead of
112
+ * vfsStreamWrapper::register();
113
+ * vfsStreamWrapper::setRoot(vfsStream::newDirectory('root'));
114
+ * you can simply do
115
+ * vfsStream::setup()
116
+ * which yields the same result. Additionally, the method returns the
117
+ * freshly created root directory which you can use to make further
118
+ * adjustments to it.
119
+ *
120
+ * Assumed $structure contains an array like this:
121
+ * <code>
122
+ * array('Core' = array('AbstractFactory' => array('test.php' => 'some text content',
123
+ * 'other.php' => 'Some more text content',
124
+ * 'Invalid.csv' => 'Something else',
125
+ * ),
126
+ * 'AnEmptyFolder' => array(),
127
+ * 'badlocation.php' => 'some bad content',
128
+ * )
129
+ * )
130
+ * </code>
131
+ * the resulting directory tree will look like this:
132
+ * <pre>
133
+ * root
134
+ * \- Core
135
+ * |- badlocation.php
136
+ * |- AbstractFactory
137
+ * | |- test.php
138
+ * | |- other.php
139
+ * | \- Invalid.csv
140
+ * \- AnEmptyFolder
141
+ * </pre>
142
+ * Arrays will become directories with their key as directory name, and
143
+ * strings becomes files with their key as file name and their value as file
144
+ * content.
145
+ *
146
+ * @param string $rootDirName name of root directory
147
+ * @param int $permissions file permissions of root directory
148
+ * @param array $structure directory structure to add under root directory
149
+ * @return \org\bovigo\vfs\vfsStreamDirectory
150
+ * @since 0.7.0
151
+ * @see https://github.com/mikey179/vfsStream/issues/14
152
+ * @see https://github.com/mikey179/vfsStream/issues/20
153
+ */
154
+ public static function setup($rootDirName = 'root', $permissions = null, array $structure = array())
155
+ {
156
+ vfsStreamWrapper::register();
157
+ return self::create($structure, vfsStreamWrapper::setRoot(self::newDirectory($rootDirName, $permissions)));
158
+ }
159
+
160
+ /**
161
+ * creates vfsStream directory structure from an array and adds it to given base dir
162
+ *
163
+ * Assumed $structure contains an array like this:
164
+ * <code>
165
+ * array('Core' = array('AbstractFactory' => array('test.php' => 'some text content',
166
+ * 'other.php' => 'Some more text content',
167
+ * 'Invalid.csv' => 'Something else',
168
+ * ),
169
+ * 'AnEmptyFolder' => array(),
170
+ * 'badlocation.php' => 'some bad content',
171
+ * )
172
+ * )
173
+ * </code>
174
+ * the resulting directory tree will look like this:
175
+ * <pre>
176
+ * baseDir
177
+ * \- Core
178
+ * |- badlocation.php
179
+ * |- AbstractFactory
180
+ * | |- test.php
181
+ * | |- other.php
182
+ * | \- Invalid.csv
183
+ * \- AnEmptyFolder
184
+ * </pre>
185
+ * Arrays will become directories with their key as directory name, and
186
+ * strings becomes files with their key as file name and their value as file
187
+ * content.
188
+ *
189
+ * If no baseDir is given it will try to add the structure to the existing
190
+ * root directory without replacing existing childs except those with equal
191
+ * names.
192
+ *
193
+ * @param array $structure directory structure to add under root directory
194
+ * @param vfsStreamDirectory $baseDir base directory to add structure to
195
+ * @return vfsStreamDirectory
196
+ * @throws \InvalidArgumentException
197
+ * @since 0.10.0
198
+ * @see https://github.com/mikey179/vfsStream/issues/14
199
+ * @see https://github.com/mikey179/vfsStream/issues/20
200
+ */
201
+ public static function create(array $structure, vfsStreamDirectory $baseDir = null)
202
+ {
203
+ if (null === $baseDir) {
204
+ $baseDir = vfsStreamWrapper::getRoot();
205
+ }
206
+
207
+ if (null === $baseDir) {
208
+ throw new \InvalidArgumentException('No baseDir given and no root directory set.');
209
+ }
210
+
211
+ return self::addStructure($structure, $baseDir);
212
+ }
213
+
214
+ /**
215
+ * helper method to create subdirectories recursively
216
+ *
217
+ * @param array $structure subdirectory structure to add
218
+ * @param vfsStreamDirectory $baseDir directory to add the structure to
219
+ * @return vfsStreamDirectory
220
+ */
221
+ protected static function addStructure(array $structure, vfsStreamDirectory $baseDir)
222
+ {
223
+ foreach ($structure as $name => $data) {
224
+ $name = (string) $name;
225
+ if (is_array($data) === true) {
226
+ self::addStructure($data, self::newDirectory($name)->at($baseDir));
227
+ } elseif (is_string($data) === true) {
228
+ $matches = null;
229
+ preg_match('/^\[(.*)\]$/', $name, $matches);
230
+ if ($matches !== array()) {
231
+ self::newBlock($matches[1])->withContent($data)->at($baseDir);
232
+ } else {
233
+ self::newFile($name)->withContent($data)->at($baseDir);
234
+ }
235
+ }
236
+ }
237
+
238
+ return $baseDir;
239
+ }
240
+
241
+ /**
242
+ * copies the file system structure from given path into the base dir
243
+ *
244
+ * If no baseDir is given it will try to add the structure to the existing
245
+ * root directory without replacing existing childs except those with equal
246
+ * names.
247
+ * File permissions are copied as well.
248
+ * Please note that file contents will only be copied if their file size
249
+ * does not exceed the given $maxFileSize which defaults to 1024 KB. In case
250
+ * the file is larger file content will be mocked, see
251
+ * https://github.com/mikey179/vfsStream/wiki/MockingLargeFiles.
252
+ *
253
+ * @param string $path path to copy the structure from
254
+ * @param vfsStreamDirectory $baseDir directory to add the structure to
255
+ * @param int $maxFileSize maximum file size of files to copy content from
256
+ * @return vfsStreamDirectory
257
+ * @throws \InvalidArgumentException
258
+ * @since 0.11.0
259
+ * @see https://github.com/mikey179/vfsStream/issues/4
260
+ */
261
+ public static function copyFromFileSystem($path, vfsStreamDirectory $baseDir = null, $maxFileSize = 1048576)
262
+ {
263
+ if (null === $baseDir) {
264
+ $baseDir = vfsStreamWrapper::getRoot();
265
+ }
266
+
267
+ if (null === $baseDir) {
268
+ throw new \InvalidArgumentException('No baseDir given and no root directory set.');
269
+ }
270
+
271
+ $dir = new \DirectoryIterator($path);
272
+ foreach ($dir as $fileinfo) {
273
+ switch (filetype($fileinfo->getPathname())) {
274
+ case 'file':
275
+ if ($fileinfo->getSize() <= $maxFileSize) {
276
+ $content = file_get_contents($fileinfo->getPathname());
277
+ } else {
278
+ $content = new LargeFileContent($fileinfo->getSize());
279
+ }
280
+
281
+ self::newFile(
282
+ $fileinfo->getFilename(),
283
+ octdec(substr(sprintf('%o', $fileinfo->getPerms()), -4))
284
+ )
285
+ ->withContent($content)
286
+ ->at($baseDir);
287
+ break;
288
+
289
+ case 'dir':
290
+ if (!$fileinfo->isDot()) {
291
+ self::copyFromFileSystem(
292
+ $fileinfo->getPathname(),
293
+ self::newDirectory(
294
+ $fileinfo->getFilename(),
295
+ octdec(substr(sprintf('%o', $fileinfo->getPerms()), -4))
296
+ )->at($baseDir),
297
+ $maxFileSize
298
+ );
299
+ }
300
+
301
+ break;
302
+
303
+ case 'block':
304
+ self::newBlock(
305
+ $fileinfo->getFilename(),
306
+ octdec(substr(sprintf('%o', $fileinfo->getPerms()), -4))
307
+ )->at($baseDir);
308
+ break;
309
+ }
310
+ }
311
+
312
+ return $baseDir;
313
+ }
314
+
315
+ /**
316
+ * returns a new file with given name
317
+ *
318
+ * @param string $name name of file to create
319
+ * @param int $permissions permissions of file to create
320
+ * @return vfsStreamFile
321
+ */
322
+ public static function newFile($name, $permissions = null)
323
+ {
324
+ return new vfsStreamFile($name, $permissions);
325
+ }
326
+
327
+ /**
328
+ * returns a new directory with given name
329
+ *
330
+ * If the name contains slashes, a new directory structure will be created.
331
+ * The returned directory will always be the parent directory of this
332
+ * directory structure.
333
+ *
334
+ * @param string $name name of directory to create
335
+ * @param int $permissions permissions of directory to create
336
+ * @return vfsStreamDirectory
337
+ */
338
+ public static function newDirectory($name, $permissions = null)
339
+ {
340
+ if ('/' === $name{0}) {
341
+ $name = substr($name, 1);
342
+ }
343
+
344
+ $firstSlash = strpos($name, '/');
345
+ if (false === $firstSlash) {
346
+ return new vfsStreamDirectory($name, $permissions);
347
+ }
348
+
349
+ $ownName = substr($name, 0, $firstSlash);
350
+ $subDirs = substr($name, $firstSlash + 1);
351
+ $directory = new vfsStreamDirectory($ownName, $permissions);
352
+ self::newDirectory($subDirs, $permissions)->at($directory);
353
+ return $directory;
354
+ }
355
+
356
+ /**
357
+ * returns a new block with the given name
358
+ *
359
+ * @param string $name name of the block device
360
+ * @param int $permissions permissions of block to create
361
+ * @return vfsStreamBlock
362
+ */
363
+ public static function newBlock($name, $permissions = null)
364
+ {
365
+ return new vfsStreamBlock($name, $permissions);
366
+ }
367
+
368
+ /**
369
+ * returns current user
370
+ *
371
+ * If the system does not support posix_getuid() the current user will be root (0).
372
+ *
373
+ * @return int
374
+ */
375
+ public static function getCurrentUser()
376
+ {
377
+ return function_exists('posix_getuid') ? posix_getuid() : self::OWNER_ROOT;
378
+ }
379
+
380
+ /**
381
+ * returns current group
382
+ *
383
+ * If the system does not support posix_getgid() the current group will be root (0).
384
+ *
385
+ * @return int
386
+ */
387
+ public static function getCurrentGroup()
388
+ {
389
+ return function_exists('posix_getgid') ? posix_getgid() : self::GROUP_ROOT;
390
+ }
391
+
392
+ /**
393
+ * use visitor to inspect a content structure
394
+ *
395
+ * If the given content is null it will fall back to use the current root
396
+ * directory of the stream wrapper.
397
+ *
398
+ * Returns given visitor for method chaining comfort.
399
+ *
400
+ * @param vfsStreamVisitor $visitor the visitor who inspects
401
+ * @param vfsStreamContent $content directory structure to inspect
402
+ * @return vfsStreamVisitor
403
+ * @throws \InvalidArgumentException
404
+ * @since 0.10.0
405
+ * @see https://github.com/mikey179/vfsStream/issues/10
406
+ */
407
+ public static function inspect(vfsStreamVisitor $visitor, vfsStreamContent $content = null)
408
+ {
409
+ if (null !== $content) {
410
+ return $visitor->visit($content);
411
+ }
412
+
413
+ $root = vfsStreamWrapper::getRoot();
414
+ if (null === $root) {
415
+ throw new \InvalidArgumentException('No content given and no root directory set.');
416
+ }
417
+
418
+ return $visitor->visitDirectory($root);
419
+ }
420
+
421
+ /**
422
+ * sets quota to given amount of bytes
423
+ *
424
+ * @param int $bytes
425
+ * @since 1.1.0
426
+ */
427
+ public static function setQuota($bytes)
428
+ {
429
+ vfsStreamWrapper::setQuota(new Quota($bytes));
430
+ }
431
+
432
+ /**
433
+ * checks if vfsStream lists dotfiles in directory listings
434
+ *
435
+ * @return bool
436
+ * @since 1.3.0
437
+ */
438
+ public static function useDotfiles()
439
+ {
440
+ return self::$dotFiles;
441
+ }
442
+
443
+ /**
444
+ * disable dotfiles in directory listings
445
+ *
446
+ * @since 1.3.0
447
+ */
448
+ public static function disableDotfiles()
449
+ {
450
+ self::$dotFiles = false;
451
+ }
452
+
453
+ /**
454
+ * enable dotfiles in directory listings
455
+ *
456
+ * @since 1.3.0
457
+ */
458
+ public static function enableDotfiles()
459
+ {
460
+ self::$dotFiles = true;
461
+ }
462
+ }
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamAbstractContent.php ADDED
@@ -0,0 +1,419 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Base stream contents container.
13
+ */
14
+ abstract class vfsStreamAbstractContent implements vfsStreamContent
15
+ {
16
+ /**
17
+ * name of the container
18
+ *
19
+ * @type string
20
+ */
21
+ protected $name;
22
+ /**
23
+ * type of the container
24
+ *
25
+ * @type string
26
+ */
27
+ protected $type;
28
+ /**
29
+ * timestamp of last access
30
+ *
31
+ * @type int
32
+ */
33
+ protected $lastAccessed;
34
+ /**
35
+ * timestamp of last attribute modification
36
+ *
37
+ * @type int
38
+ */
39
+ protected $lastAttributeModified;
40
+ /**
41
+ * timestamp of last modification
42
+ *
43
+ * @type int
44
+ */
45
+ protected $lastModified;
46
+ /**
47
+ * permissions for content
48
+ *
49
+ * @type int
50
+ */
51
+ protected $permissions;
52
+ /**
53
+ * owner of the file
54
+ *
55
+ * @type int
56
+ */
57
+ protected $user;
58
+ /**
59
+ * owner group of the file
60
+ *
61
+ * @type int
62
+ */
63
+ protected $group;
64
+ /**
65
+ * path to to this content
66
+ *
67
+ * @type string
68
+ */
69
+ private $parentPath;
70
+
71
+ /**
72
+ * constructor
73
+ *
74
+ * @param string $name
75
+ * @param int $permissions optional
76
+ */
77
+ public function __construct($name, $permissions = null)
78
+ {
79
+ $this->name = $name;
80
+ $time = time();
81
+ if (null === $permissions) {
82
+ $permissions = $this->getDefaultPermissions() & ~vfsStream::umask();
83
+ }
84
+
85
+ $this->lastAccessed = $time;
86
+ $this->lastAttributeModified = $time;
87
+ $this->lastModified = $time;
88
+ $this->permissions = $permissions;
89
+ $this->user = vfsStream::getCurrentUser();
90
+ $this->group = vfsStream::getCurrentGroup();
91
+ }
92
+
93
+ /**
94
+ * returns default permissions for concrete implementation
95
+ *
96
+ * @return int
97
+ * @since 0.8.0
98
+ */
99
+ protected abstract function getDefaultPermissions();
100
+
101
+ /**
102
+ * returns the file name of the content
103
+ *
104
+ * @return string
105
+ */
106
+ public function getName()
107
+ {
108
+ return $this->name;
109
+ }
110
+
111
+ /**
112
+ * renames the content
113
+ *
114
+ * @param string $newName
115
+ */
116
+ public function rename($newName)
117
+ {
118
+ $this->name = $newName;
119
+ }
120
+
121
+ /**
122
+ * checks whether the container can be applied to given name
123
+ *
124
+ * @param string $name
125
+ * @return bool
126
+ */
127
+ public function appliesTo($name)
128
+ {
129
+ if ($name === $this->name) {
130
+ return true;
131
+ }
132
+
133
+ $segment_name = $this->name.'/';
134
+ return (strncmp($segment_name, $name, strlen($segment_name)) == 0);
135
+ }
136
+
137
+ /**
138
+ * returns the type of the container
139
+ *
140
+ * @return int
141
+ */
142
+ public function getType()
143
+ {
144
+ return $this->type;
145
+ }
146
+
147
+ /**
148
+ * sets the last modification time of the stream content
149
+ *
150
+ * @param int $filemtime
151
+ * @return $this
152
+ */
153
+ public function lastModified($filemtime)
154
+ {
155
+ $this->lastModified = $filemtime;
156
+ return $this;
157
+ }
158
+
159
+ /**
160
+ * returns the last modification time of the stream content
161
+ *
162
+ * @return int
163
+ */
164
+ public function filemtime()
165
+ {
166
+ return $this->lastModified;
167
+ }
168
+
169
+ /**
170
+ * sets last access time of the stream content
171
+ *
172
+ * @param int $fileatime
173
+ * @return $this
174
+ * @since 0.9
175
+ */
176
+ public function lastAccessed($fileatime)
177
+ {
178
+ $this->lastAccessed = $fileatime;
179
+ return $this;
180
+ }
181
+
182
+ /**
183
+ * returns the last access time of the stream content
184
+ *
185
+ * @return int
186
+ * @since 0.9
187
+ */
188
+ public function fileatime()
189
+ {
190
+ return $this->lastAccessed;
191
+ }
192
+
193
+ /**
194
+ * sets the last attribute modification time of the stream content
195
+ *
196
+ * @param int $filectime
197
+ * @return $this
198
+ * @since 0.9
199
+ */
200
+ public function lastAttributeModified($filectime)
201
+ {
202
+ $this->lastAttributeModified = $filectime;
203
+ return $this;
204
+ }
205
+
206
+ /**
207
+ * returns the last attribute modification time of the stream content
208
+ *
209
+ * @return int
210
+ * @since 0.9
211
+ */
212
+ public function filectime()
213
+ {
214
+ return $this->lastAttributeModified;
215
+ }
216
+
217
+ /**
218
+ * adds content to given container
219
+ *
220
+ * @param vfsStreamContainer $container
221
+ * @return $this
222
+ */
223
+ public function at(vfsStreamContainer $container)
224
+ {
225
+ $container->addChild($this);
226
+ return $this;
227
+ }
228
+
229
+ /**
230
+ * change file mode to given permissions
231
+ *
232
+ * @param int $permissions
233
+ * @return $this
234
+ */
235
+ public function chmod($permissions)
236
+ {
237
+ $this->permissions = $permissions;
238
+ $this->lastAttributeModified = time();
239
+ clearstatcache();
240
+ return $this;
241
+ }
242
+
243
+ /**
244
+ * returns permissions
245
+ *
246
+ * @return int
247
+ */
248
+ public function getPermissions()
249
+ {
250
+ return $this->permissions;
251
+ }
252
+
253
+ /**
254
+ * checks whether content is readable
255
+ *
256
+ * @param int $user id of user to check for
257
+ * @param int $group id of group to check for
258
+ * @return bool
259
+ */
260
+ public function isReadable($user, $group)
261
+ {
262
+ if ($this->user === $user) {
263
+ $check = 0400;
264
+ } elseif ($this->group === $group) {
265
+ $check = 0040;
266
+ } else {
267
+ $check = 0004;
268
+ }
269
+
270
+ return (bool) ($this->permissions & $check);
271
+ }
272
+
273
+ /**
274
+ * checks whether content is writable
275
+ *
276
+ * @param int $user id of user to check for
277
+ * @param int $group id of group to check for
278
+ * @return bool
279
+ */
280
+ public function isWritable($user, $group)
281
+ {
282
+ if ($this->user === $user) {
283
+ $check = 0200;
284
+ } elseif ($this->group === $group) {
285
+ $check = 0020;
286
+ } else {
287
+ $check = 0002;
288
+ }
289
+
290
+ return (bool) ($this->permissions & $check);
291
+ }
292
+
293
+ /**
294
+ * checks whether content is executable
295
+ *
296
+ * @param int $user id of user to check for
297
+ * @param int $group id of group to check for
298
+ * @return bool
299
+ */
300
+ public function isExecutable($user, $group)
301
+ {
302
+ if ($this->user === $user) {
303
+ $check = 0100;
304
+ } elseif ($this->group === $group) {
305
+ $check = 0010;
306
+ } else {
307
+ $check = 0001;
308
+ }
309
+
310
+ return (bool) ($this->permissions & $check);
311
+ }
312
+
313
+ /**
314
+ * change owner of file to given user
315
+ *
316
+ * @param int $user
317
+ * @return $this
318
+ */
319
+ public function chown($user)
320
+ {
321
+ $this->user = $user;
322
+ $this->lastAttributeModified = time();
323
+ return $this;
324
+ }
325
+
326
+ /**
327
+ * checks whether file is owned by given user
328
+ *
329
+ * @param int $user
330
+ * @return bool
331
+ */
332
+ public function isOwnedByUser($user)
333
+ {
334
+ return $this->user === $user;
335
+ }
336
+
337
+ /**
338
+ * returns owner of file
339
+ *
340
+ * @return int
341
+ */
342
+ public function getUser()
343
+ {
344
+ return $this->user;
345
+ }
346
+
347
+ /**
348
+ * change owner group of file to given group
349
+ *
350
+ * @param int $group
351
+ * @return $this
352
+ */
353
+ public function chgrp($group)
354
+ {
355
+ $this->group = $group;
356
+ $this->lastAttributeModified = time();
357
+ return $this;
358
+ }
359
+
360
+ /**
361
+ * checks whether file is owned by group
362
+ *
363
+ * @param int $group
364
+ * @return bool
365
+ */
366
+ public function isOwnedByGroup($group)
367
+ {
368
+ return $this->group === $group;
369
+ }
370
+
371
+ /**
372
+ * returns owner group of file
373
+ *
374
+ * @return int
375
+ */
376
+ public function getGroup()
377
+ {
378
+ return $this->group;
379
+ }
380
+
381
+ /**
382
+ * sets parent path
383
+ *
384
+ * @param string $parentPath
385
+ * @internal only to be set by parent
386
+ * @since 1.2.0
387
+ */
388
+ public function setParentPath($parentPath)
389
+ {
390
+ $this->parentPath = $parentPath;
391
+ }
392
+
393
+ /**
394
+ * returns path to this content
395
+ *
396
+ * @return string
397
+ * @since 1.2.0
398
+ */
399
+ public function path()
400
+ {
401
+ if (null === $this->parentPath) {
402
+ return $this->name;
403
+ }
404
+
405
+ return $this->parentPath . '/' . $this->name;
406
+ }
407
+
408
+ /**
409
+ * returns complete vfsStream url for this content
410
+ *
411
+ * @return string
412
+ * @since 1.2.0
413
+ */
414
+ public function url()
415
+ {
416
+ return vfsStream::url($this->path());
417
+ }
418
+ }
419
+ ?>
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamBlock.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+
12
+ /**
13
+ * Block container.
14
+ *
15
+ * @api
16
+ */
17
+ class vfsStreamBlock extends vfsStreamFile
18
+ {
19
+ /**
20
+ * constructor
21
+ *
22
+ * @param string $name
23
+ * @param int $permissions optional
24
+ */
25
+ public function __construct($name, $permissions = null)
26
+ {
27
+ if (empty($name)) {
28
+ throw new vfsStreamException('Name of Block device was empty');
29
+ }
30
+ parent::__construct($name, $permissions);
31
+
32
+ $this->type = vfsStreamContent::TYPE_BLOCK;
33
+ }
34
+ }
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamContainer.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Interface for stream contents that are able to store other stream contents.
13
+ */
14
+ interface vfsStreamContainer extends \IteratorAggregate
15
+ {
16
+ /**
17
+ * adds child to the directory
18
+ *
19
+ * @param vfsStreamContent $child
20
+ */
21
+ public function addChild(vfsStreamContent $child);
22
+
23
+ /**
24
+ * removes child from the directory
25
+ *
26
+ * @param string $name
27
+ * @return bool
28
+ */
29
+ public function removeChild($name);
30
+
31
+ /**
32
+ * checks whether the container contains a child with the given name
33
+ *
34
+ * @param string $name
35
+ * @return bool
36
+ */
37
+ public function hasChild($name);
38
+
39
+ /**
40
+ * returns the child with the given name
41
+ *
42
+ * @param string $name
43
+ * @return vfsStreamContent
44
+ */
45
+ public function getChild($name);
46
+
47
+ /**
48
+ * checks whether directory contains any children
49
+ *
50
+ * @return bool
51
+ * @since 0.10.0
52
+ */
53
+ public function hasChildren();
54
+
55
+ /**
56
+ * returns a list of children for this directory
57
+ *
58
+ * @return vfsStreamContent[]
59
+ */
60
+ public function getChildren();
61
+ }
62
+ ?>
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamContainerIterator.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Iterator for children of a directory container.
13
+ */
14
+ class vfsStreamContainerIterator implements \Iterator
15
+ {
16
+ /**
17
+ * list of children from container to iterate over
18
+ *
19
+ * @type vfsStreamContent[]
20
+ */
21
+ protected $children;
22
+
23
+ /**
24
+ * constructor
25
+ *
26
+ * @param vfsStreamContent[] $children
27
+ */
28
+ public function __construct(array $children)
29
+ {
30
+ $this->children = $children;
31
+ if (vfsStream::useDotfiles()) {
32
+ array_unshift($this->children, new DotDirectory('.'), new DotDirectory('..'));
33
+ }
34
+
35
+ reset($this->children);
36
+ }
37
+
38
+ /**
39
+ * resets children pointer
40
+ */
41
+ public function rewind()
42
+ {
43
+ reset($this->children);
44
+ }
45
+
46
+ /**
47
+ * returns the current child
48
+ *
49
+ * @return vfsStreamContent
50
+ */
51
+ public function current()
52
+ {
53
+ $child = current($this->children);
54
+ if (false === $child) {
55
+ return null;
56
+ }
57
+
58
+ return $child;
59
+ }
60
+
61
+ /**
62
+ * returns the name of the current child
63
+ *
64
+ * @return string
65
+ */
66
+ public function key()
67
+ {
68
+ $child = current($this->children);
69
+ if (false === $child) {
70
+ return null;
71
+ }
72
+
73
+ return $child->getName();
74
+ }
75
+
76
+ /**
77
+ * iterates to next child
78
+ */
79
+ public function next()
80
+ {
81
+ next($this->children);
82
+ }
83
+
84
+ /**
85
+ * checks if the current value is valid
86
+ *
87
+ * @return bool
88
+ */
89
+ public function valid()
90
+ {
91
+ return (false !== current($this->children));
92
+ }
93
+ }
94
+ ?>
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamContent.php ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Interface for stream contents.
13
+ */
14
+ interface vfsStreamContent
15
+ {
16
+ /**
17
+ * stream content type: file
18
+ *
19
+ * @see getType()
20
+ */
21
+ const TYPE_FILE = 0100000;
22
+ /**
23
+ * stream content type: directory
24
+ *
25
+ * @see getType()
26
+ */
27
+ const TYPE_DIR = 0040000;
28
+ /**
29
+ * stream content type: symbolic link
30
+ *
31
+ * @see getType();
32
+ */
33
+ #const TYPE_LINK = 0120000;
34
+
35
+ /**
36
+ * stream content type: block
37
+ *
38
+ * @see getType()
39
+ */
40
+ const TYPE_BLOCK = 0060000;
41
+
42
+ /**
43
+ * returns the file name of the content
44
+ *
45
+ * @return string
46
+ */
47
+ public function getName();
48
+
49
+ /**
50
+ * renames the content
51
+ *
52
+ * @param string $newName
53
+ */
54
+ public function rename($newName);
55
+
56
+ /**
57
+ * checks whether the container can be applied to given name
58
+ *
59
+ * @param string $name
60
+ * @return bool
61
+ */
62
+ public function appliesTo($name);
63
+
64
+ /**
65
+ * returns the type of the container
66
+ *
67
+ * @return int
68
+ */
69
+ public function getType();
70
+
71
+ /**
72
+ * returns size of content
73
+ *
74
+ * @return int
75
+ */
76
+ public function size();
77
+
78
+ /**
79
+ * sets the last modification time of the stream content
80
+ *
81
+ * @param int $filemtime
82
+ * @return vfsStreamContent
83
+ */
84
+ public function lastModified($filemtime);
85
+
86
+ /**
87
+ * returns the last modification time of the stream content
88
+ *
89
+ * @return int
90
+ */
91
+ public function filemtime();
92
+
93
+ /**
94
+ * adds content to given container
95
+ *
96
+ * @param vfsStreamContainer $container
97
+ * @return vfsStreamContent
98
+ */
99
+ public function at(vfsStreamContainer $container);
100
+
101
+ /**
102
+ * change file mode to given permissions
103
+ *
104
+ * @param int $permissions
105
+ * @return vfsStreamContent
106
+ */
107
+ public function chmod($permissions);
108
+
109
+ /**
110
+ * returns permissions
111
+ *
112
+ * @return int
113
+ */
114
+ public function getPermissions();
115
+
116
+ /**
117
+ * checks whether content is readable
118
+ *
119
+ * @param int $user id of user to check for
120
+ * @param int $group id of group to check for
121
+ * @return bool
122
+ */
123
+ public function isReadable($user, $group);
124
+
125
+ /**
126
+ * checks whether content is writable
127
+ *
128
+ * @param int $user id of user to check for
129
+ * @param int $group id of group to check for
130
+ * @return bool
131
+ */
132
+ public function isWritable($user, $group);
133
+
134
+ /**
135
+ * checks whether content is executable
136
+ *
137
+ * @param int $user id of user to check for
138
+ * @param int $group id of group to check for
139
+ * @return bool
140
+ */
141
+ public function isExecutable($user, $group);
142
+
143
+ /**
144
+ * change owner of file to given user
145
+ *
146
+ * @param int $user
147
+ * @return vfsStreamContent
148
+ */
149
+ public function chown($user);
150
+
151
+ /**
152
+ * checks whether file is owned by given user
153
+ *
154
+ * @param int $user
155
+ * @return bool
156
+ */
157
+ public function isOwnedByUser($user);
158
+
159
+ /**
160
+ * returns owner of file
161
+ *
162
+ * @return int
163
+ */
164
+ public function getUser();
165
+
166
+ /**
167
+ * change owner group of file to given group
168
+ *
169
+ * @param int $group
170
+ * @return vfsStreamContent
171
+ */
172
+ public function chgrp($group);
173
+
174
+ /**
175
+ * checks whether file is owned by group
176
+ *
177
+ * @param int $group
178
+ * @return bool
179
+ */
180
+ public function isOwnedByGroup($group);
181
+
182
+ /**
183
+ * returns owner group of file
184
+ *
185
+ * @return int
186
+ */
187
+ public function getGroup();
188
+
189
+ /**
190
+ * sets parent path
191
+ *
192
+ * @param string $parentPath
193
+ * @internal only to be set by parent
194
+ * @since 1.2.0
195
+ */
196
+ public function setParentPath($parentPath);
197
+
198
+ /**
199
+ * returns path to this content
200
+ *
201
+ * @return string
202
+ * @since 1.2.0
203
+ */
204
+ public function path();
205
+
206
+ /**
207
+ * returns complete vfsStream url for this content
208
+ *
209
+ * @return string
210
+ * @since 1.2.0
211
+ */
212
+ public function url();
213
+ }
214
+ ?>
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamDirectory.php ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Directory container.
13
+ *
14
+ * @api
15
+ */
16
+ class vfsStreamDirectory extends vfsStreamAbstractContent implements vfsStreamContainer
17
+ {
18
+ /**
19
+ * list of directory children
20
+ *
21
+ * @type vfsStreamContent[]
22
+ */
23
+ protected $children = array();
24
+
25
+ /**
26
+ * constructor
27
+ *
28
+ * @param string $name
29
+ * @param int $permissions optional
30
+ * @throws vfsStreamException
31
+ */
32
+ public function __construct($name, $permissions = null)
33
+ {
34
+ if (strstr($name, '/') !== false) {
35
+ throw new vfsStreamException('Directory name can not contain /.');
36
+ }
37
+
38
+ $this->type = vfsStreamContent::TYPE_DIR;
39
+ parent::__construct($name, $permissions);
40
+ }
41
+
42
+ /**
43
+ * returns default permissions for concrete implementation
44
+ *
45
+ * @return int
46
+ * @since 0.8.0
47
+ */
48
+ protected function getDefaultPermissions()
49
+ {
50
+ return 0777;
51
+ }
52
+
53
+ /**
54
+ * returns size of directory
55
+ *
56
+ * The size of a directory is always 0 bytes. To calculate the summarized
57
+ * size of all children in the directory use sizeSummarized().
58
+ *
59
+ * @return int
60
+ */
61
+ public function size()
62
+ {
63
+ return 0;
64
+ }
65
+
66
+ /**
67
+ * returns summarized size of directory and its children
68
+ *
69
+ * @return int
70
+ */
71
+ public function sizeSummarized()
72
+ {
73
+ $size = 0;
74
+ foreach ($this->children as $child) {
75
+ if ($child->getType() === vfsStreamContent::TYPE_DIR) {
76
+ $size += $child->sizeSummarized();
77
+ } else {
78
+ $size += $child->size();
79
+ }
80
+ }
81
+
82
+ return $size;
83
+ }
84
+
85
+ /**
86
+ * renames the content
87
+ *
88
+ * @param string $newName
89
+ * @throws vfsStreamException
90
+ */
91
+ public function rename($newName)
92
+ {
93
+ if (strstr($newName, '/') !== false) {
94
+ throw new vfsStreamException('Directory name can not contain /.');
95
+ }
96
+
97
+ parent::rename($newName);
98
+ }
99
+
100
+
101
+ /**
102
+ * sets parent path
103
+ *
104
+ * @param string $parentPath
105
+ * @internal only to be set by parent
106
+ * @since 1.2.0
107
+ */
108
+ public function setParentPath($parentPath)
109
+ {
110
+ parent::setParentPath($parentPath);
111
+ foreach ($this->children as $child) {
112
+ $child->setParentPath($this->path());
113
+ }
114
+ }
115
+
116
+ /**
117
+ * adds child to the directory
118
+ *
119
+ * @param vfsStreamContent $child
120
+ */
121
+ public function addChild(vfsStreamContent $child)
122
+ {
123
+ $child->setParentPath($this->path());
124
+ $this->children[$child->getName()] = $child;
125
+ $this->updateModifications();
126
+ }
127
+
128
+ /**
129
+ * removes child from the directory
130
+ *
131
+ * @param string $name
132
+ * @return bool
133
+ */
134
+ public function removeChild($name)
135
+ {
136
+ foreach ($this->children as $key => $child) {
137
+ if ($child->appliesTo($name)) {
138
+ $child->setParentPath(null);
139
+ unset($this->children[$key]);
140
+ $this->updateModifications();
141
+ return true;
142
+ }
143
+ }
144
+
145
+ return false;
146
+ }
147
+
148
+ /**
149
+ * updates internal timestamps
150
+ */
151
+ protected function updateModifications()
152
+ {
153
+ $time = time();
154
+ $this->lastAttributeModified = $time;
155
+ $this->lastModified = $time;
156
+ }
157
+
158
+ /**
159
+ * checks whether the container contains a child with the given name
160
+ *
161
+ * @param string $name
162
+ * @return bool
163
+ */
164
+ public function hasChild($name)
165
+ {
166
+ return ($this->getChild($name) !== null);
167
+ }
168
+
169
+ /**
170
+ * returns the child with the given name
171
+ *
172
+ * @param string $name
173
+ * @return vfsStreamContent
174
+ */
175
+ public function getChild($name)
176
+ {
177
+ $childName = $this->getRealChildName($name);
178
+ foreach ($this->children as $child) {
179
+ if ($child->getName() === $childName) {
180
+ return $child;
181
+ }
182
+
183
+ if ($child->appliesTo($childName) === true && $child->hasChild($childName) === true) {
184
+ return $child->getChild($childName);
185
+ }
186
+ }
187
+
188
+ return null;
189
+ }
190
+
191
+ /**
192
+ * helper method to detect the real child name
193
+ *
194
+ * @param string $name
195
+ * @return string
196
+ */
197
+ protected function getRealChildName($name)
198
+ {
199
+ if ($this->appliesTo($name) === true) {
200
+ return self::getChildName($name, $this->name);
201
+ }
202
+
203
+ return $name;
204
+ }
205
+
206
+ /**
207
+ * helper method to calculate the child name
208
+ *
209
+ * @param string $name
210
+ * @param string $ownName
211
+ * @return string
212
+ */
213
+ protected static function getChildName($name, $ownName)
214
+ {
215
+ if ($name === $ownName) {
216
+ return $name;
217
+ }
218
+
219
+ return substr($name, strlen($ownName) + 1);
220
+ }
221
+
222
+ /**
223
+ * checks whether directory contains any children
224
+ *
225
+ * @return bool
226
+ * @since 0.10.0
227
+ */
228
+ public function hasChildren()
229
+ {
230
+ return (count($this->children) > 0);
231
+ }
232
+
233
+ /**
234
+ * returns a list of children for this directory
235
+ *
236
+ * @return vfsStreamContent[]
237
+ */
238
+ public function getChildren()
239
+ {
240
+ return array_values($this->children);
241
+ }
242
+
243
+ /**
244
+ * returns iterator for the children
245
+ *
246
+ * @return vfsStreamContainerIterator
247
+ */
248
+ public function getIterator()
249
+ {
250
+ return new vfsStreamContainerIterator($this->children);
251
+ }
252
+
253
+ /**
254
+ * checks whether dir is a dot dir
255
+ *
256
+ * @return bool
257
+ */
258
+ public function isDot()
259
+ {
260
+ if ('.' === $this->name || '..' === $this->name) {
261
+ return true;
262
+ }
263
+
264
+ return false;
265
+ }
266
+ }
267
+ ?>
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamException.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Exception for vfsStream errors.
13
+ *
14
+ * @api
15
+ */
16
+ class vfsStreamException extends \Exception
17
+ {
18
+ // intentionally empty
19
+ }
20
+ ?>
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamFile.php ADDED
@@ -0,0 +1,394 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ use org\bovigo\vfs\content\FileContent;
12
+ use org\bovigo\vfs\content\StringBasedFileContent;
13
+ /**
14
+ * File container.
15
+ *
16
+ * @api
17
+ */
18
+ class vfsStreamFile extends vfsStreamAbstractContent
19
+ {
20
+ /**
21
+ * content of the file
22
+ *
23
+ * @type FileContent
24
+ */
25
+ private $content;
26
+ /**
27
+ * Resource id which exclusively locked this file
28
+ *
29
+ * @type string
30
+ */
31
+ protected $exclusiveLock;
32
+ /**
33
+ * Resources ids which currently holds shared lock to this file
34
+ *
35
+ * @type bool[string]
36
+ */
37
+ protected $sharedLock = array();
38
+
39
+ /**
40
+ * constructor
41
+ *
42
+ * @param string $name
43
+ * @param int $permissions optional
44
+ */
45
+ public function __construct($name, $permissions = null)
46
+ {
47
+ $this->content = new StringBasedFileContent(null);
48
+ $this->type = vfsStreamContent::TYPE_FILE;
49
+ parent::__construct($name, $permissions);
50
+ }
51
+
52
+ /**
53
+ * returns default permissions for concrete implementation
54
+ *
55
+ * @return int
56
+ * @since 0.8.0
57
+ */
58
+ protected function getDefaultPermissions()
59
+ {
60
+ return 0666;
61
+ }
62
+
63
+ /**
64
+ * checks whether the container can be applied to given name
65
+ *
66
+ * @param string $name
67
+ * @return bool
68
+ */
69
+ public function appliesTo($name)
70
+ {
71
+ return ($name === $this->name);
72
+ }
73
+
74
+ /**
75
+ * alias for withContent()
76
+ *
77
+ * @param string $content
78
+ * @return vfsStreamFile
79
+ * @see withContent()
80
+ */
81
+ public function setContent($content)
82
+ {
83
+ return $this->withContent($content);
84
+ }
85
+
86
+ /**
87
+ * sets the contents of the file
88
+ *
89
+ * Setting content with this method does not change the time when the file
90
+ * was last modified.
91
+ *
92
+ * @param string]FileContent $content
93
+ * @return vfsStreamFile
94
+ * @throws \InvalidArgumentException
95
+ */
96
+ public function withContent($content)
97
+ {
98
+ if (is_string($content)) {
99
+ $this->content = new StringBasedFileContent($content);
100
+ } elseif ($content instanceof FileContent) {
101
+ $this->content = $content;
102
+ } else {
103
+ throw new \InvalidArgumentException('Given content must either be a string or an instance of org\bovigo\vfs\content\FileContent');
104
+ }
105
+
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * returns the contents of the file
111
+ *
112
+ * Getting content does not change the time when the file
113
+ * was last accessed.
114
+ *
115
+ * @return string
116
+ */
117
+ public function getContent()
118
+ {
119
+ return $this->content->content();
120
+ }
121
+
122
+ /**
123
+ * simply open the file
124
+ *
125
+ * @since 0.9
126
+ */
127
+ public function open()
128
+ {
129
+ $this->content->seek(0, SEEK_SET);
130
+ $this->lastAccessed = time();
131
+ }
132
+
133
+ /**
134
+ * open file and set pointer to end of file
135
+ *
136
+ * @since 0.9
137
+ */
138
+ public function openForAppend()
139
+ {
140
+ $this->content->seek(0, SEEK_END);
141
+ $this->lastAccessed = time();
142
+ }
143
+
144
+ /**
145
+ * open file and truncate content
146
+ *
147
+ * @since 0.9
148
+ */
149
+ public function openWithTruncate()
150
+ {
151
+ $this->open();
152
+ $this->content->truncate(0);
153
+ $time = time();
154
+ $this->lastAccessed = $time;
155
+ $this->lastModified = $time;
156
+ }
157
+
158
+ /**
159
+ * reads the given amount of bytes from content
160
+ *
161
+ * Using this method changes the time when the file was last accessed.
162
+ *
163
+ * @param int $count
164
+ * @return string
165
+ */
166
+ public function read($count)
167
+ {
168
+ $this->lastAccessed = time();
169
+ return $this->content->read($count);
170
+ }
171
+
172
+ /**
173
+ * returns the content until its end from current offset
174
+ *
175
+ * Using this method changes the time when the file was last accessed.
176
+ *
177
+ * @return string
178
+ * @deprecated since 1.3.0
179
+ */
180
+ public function readUntilEnd()
181
+ {
182
+ $this->lastAccessed = time();
183
+ return $this->content->readUntilEnd();
184
+ }
185
+
186
+ /**
187
+ * writes an amount of data
188
+ *
189
+ * Using this method changes the time when the file was last modified.
190
+ *
191
+ * @param string $data
192
+ * @return amount of written bytes
193
+ */
194
+ public function write($data)
195
+ {
196
+ $this->lastModified = time();
197
+ return $this->content->write($data);
198
+ }
199
+
200
+ /**
201
+ * Truncates a file to a given length
202
+ *
203
+ * @param int $size length to truncate file to
204
+ * @return bool
205
+ * @since 1.1.0
206
+ */
207
+ public function truncate($size)
208
+ {
209
+ $this->content->truncate($size);
210
+ $this->lastModified = time();
211
+ return true;
212
+ }
213
+
214
+ /**
215
+ * checks whether pointer is at end of file
216
+ *
217
+ * @return bool
218
+ */
219
+ public function eof()
220
+ {
221
+ return $this->content->eof();
222
+ }
223
+
224
+ /**
225
+ * returns the current position within the file
226
+ *
227
+ * @return int
228
+ * @deprecated since 1.3.0
229
+ */
230
+ public function getBytesRead()
231
+ {
232
+ return $this->content->bytesRead();
233
+ }
234
+
235
+ /**
236
+ * seeks to the given offset
237
+ *
238
+ * @param int $offset
239
+ * @param int $whence
240
+ * @return bool
241
+ */
242
+ public function seek($offset, $whence)
243
+ {
244
+ return $this->content->seek($offset, $whence);
245
+ }
246
+
247
+ /**
248
+ * returns size of content
249
+ *
250
+ * @return int
251
+ */
252
+ public function size()
253
+ {
254
+ return $this->content->size();
255
+ }
256
+
257
+
258
+ /**
259
+ * locks file for
260
+ *
261
+ * @param resource|vfsStreamWrapper $resource
262
+ * @param int $operation
263
+ * @return bool
264
+ * @since 0.10.0
265
+ * @see https://github.com/mikey179/vfsStream/issues/6
266
+ * @see https://github.com/mikey179/vfsStream/issues/40
267
+ */
268
+ public function lock($resource, $operation)
269
+ {
270
+ if ((LOCK_NB & $operation) == LOCK_NB) {
271
+ $operation = $operation - LOCK_NB;
272
+ }
273
+
274
+ // call to lock file on the same file handler firstly releases the lock
275
+ $this->unlock($resource);
276
+
277
+ if (LOCK_EX === $operation) {
278
+ if ($this->isLocked()) {
279
+ return false;
280
+ }
281
+
282
+ $this->setExclusiveLock($resource);
283
+ } elseif(LOCK_SH === $operation) {
284
+ if ($this->hasExclusiveLock()) {
285
+ return false;
286
+ }
287
+
288
+ $this->addSharedLock($resource);
289
+ }
290
+
291
+ return true;
292
+ }
293
+
294
+ /**
295
+ * Removes lock from file acquired by given resource
296
+ *
297
+ * @param resource|vfsStreamWrapper $resource
298
+ * @see https://github.com/mikey179/vfsStream/issues/40
299
+ */
300
+ public function unlock($resource) {
301
+ if ($this->hasExclusiveLock($resource)) {
302
+ $this->exclusiveLock = null;
303
+ }
304
+ if ($this->hasSharedLock($resource)) {
305
+ unset($this->sharedLock[$this->getResourceId($resource)]);
306
+ }
307
+ }
308
+
309
+ /**
310
+ * Set exlusive lock on file by given resource
311
+ *
312
+ * @param resource|vfsStreamWrapper $resource
313
+ * @see https://github.com/mikey179/vfsStream/issues/40
314
+ */
315
+ protected function setExclusiveLock($resource) {
316
+ $this->exclusiveLock = $this->getResourceId($resource);
317
+ }
318
+
319
+ /**
320
+ * Add shared lock on file by given resource
321
+ *
322
+ * @param resource|vfsStreamWrapper $resource
323
+ * @see https://github.com/mikey179/vfsStream/issues/40
324
+ */
325
+ protected function addSharedLock($resource) {
326
+ $this->sharedLock[$this->getResourceId($resource)] = true;
327
+ }
328
+
329
+ /**
330
+ * checks whether file is locked
331
+ *
332
+ * @param resource|vfsStreamWrapper $resource
333
+ * @return bool
334
+ * @since 0.10.0
335
+ * @see https://github.com/mikey179/vfsStream/issues/6
336
+ * @see https://github.com/mikey179/vfsStream/issues/40
337
+ */
338
+ public function isLocked($resource = null)
339
+ {
340
+ return $this->hasSharedLock($resource) || $this->hasExclusiveLock($resource);
341
+ }
342
+
343
+ /**
344
+ * checks whether file is locked in shared mode
345
+ *
346
+ * @param resource|vfsStreamWrapper $resource
347
+ * @return bool
348
+ * @since 0.10.0
349
+ * @see https://github.com/mikey179/vfsStream/issues/6
350
+ * @see https://github.com/mikey179/vfsStream/issues/40
351
+ */
352
+ public function hasSharedLock($resource = null)
353
+ {
354
+ if (null !== $resource) {
355
+ return isset($this->sharedLock[$this->getResourceId($resource)]);
356
+ }
357
+
358
+ return !empty($this->sharedLock);
359
+ }
360
+
361
+ /**
362
+ * Returns unique resource id
363
+ *
364
+ * @param resource|vfsStreamWrapper $resource
365
+ * @return string
366
+ * @see https://github.com/mikey179/vfsStream/issues/40
367
+ */
368
+ public function getResourceId($resource) {
369
+ if (is_resource($resource)) {
370
+ $data = stream_get_meta_data($resource);
371
+ $resource = $data['wrapper_data'];
372
+ }
373
+
374
+ return spl_object_hash($resource);
375
+ }
376
+
377
+ /**
378
+ * checks whether file is locked in exclusive mode
379
+ *
380
+ * @param resource|vfsStreamWrapper $resource
381
+ * @return bool
382
+ * @since 0.10.0
383
+ * @see https://github.com/mikey179/vfsStream/issues/6
384
+ * @see https://github.com/mikey179/vfsStream/issues/40
385
+ */
386
+ public function hasExclusiveLock($resource = null)
387
+ {
388
+ if (null !== $resource) {
389
+ return $this->exclusiveLock === $this->getResourceId($resource);
390
+ }
391
+
392
+ return null !== $this->exclusiveLock;
393
+ }
394
+ }
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/vfsStreamWrapper.php ADDED
@@ -0,0 +1,986 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Stream wrapper to mock file system requests.
13
+ */
14
+ class vfsStreamWrapper
15
+ {
16
+ /**
17
+ * open file for reading
18
+ */
19
+ const READ = 'r';
20
+ /**
21
+ * truncate file
22
+ */
23
+ const TRUNCATE = 'w';
24
+ /**
25
+ * set file pointer to end, append new data
26
+ */
27
+ const APPEND = 'a';
28
+ /**
29
+ * set file pointer to start, overwrite existing data
30
+ */
31
+ const WRITE = 'x';
32
+ /**
33
+ * set file pointer to start, overwrite existing data; or create file if
34
+ * does not exist
35
+ */
36
+ const WRITE_NEW = 'c';
37
+ /**
38
+ * file mode: read only
39
+ */
40
+ const READONLY = 0;
41
+ /**
42
+ * file mode: write only
43
+ */
44
+ const WRITEONLY = 1;
45
+ /**
46
+ * file mode: read and write
47
+ */
48
+ const ALL = 2;
49
+ /**
50
+ * switch whether class has already been registered as stream wrapper or not
51
+ *
52
+ * @type bool
53
+ */
54
+ protected static $registered = false;
55
+ /**
56
+ * root content
57
+ *
58
+ * @type vfsStreamContent
59
+ */
60
+ protected static $root;
61
+ /**
62
+ * disk space quota
63
+ *
64
+ * @type Quota
65
+ */
66
+ private static $quota;
67
+ /**
68
+ * file mode: read only, write only, all
69
+ *
70
+ * @type int
71
+ */
72
+ protected $mode;
73
+ /**
74
+ * shortcut to file container
75
+ *
76
+ * @type vfsStreamFile
77
+ */
78
+ protected $content;
79
+ /**
80
+ * shortcut to directory container
81
+ *
82
+ * @type vfsStreamDirectory
83
+ */
84
+ protected $dir;
85
+ /**
86
+ * shortcut to directory container iterator
87
+ *
88
+ * @type vfsStreamDirectory
89
+ */
90
+ protected $dirIterator;
91
+
92
+ /**
93
+ * method to register the stream wrapper
94
+ *
95
+ * Please be aware that a call to this method will reset the root element
96
+ * to null.
97
+ * If the stream is already registered the method returns silently. If there
98
+ * is already another stream wrapper registered for the scheme used by
99
+ * vfsStream a vfsStreamException will be thrown.
100
+ *
101
+ * @throws vfsStreamException
102
+ */
103
+ public static function register()
104
+ {
105
+ self::$root = null;
106
+ self::$quota = Quota::unlimited();
107
+ if (true === self::$registered) {
108
+ return;
109
+ }
110
+
111
+ if (@stream_wrapper_register(vfsStream::SCHEME, __CLASS__) === false) {
112
+ throw new vfsStreamException('A handler has already been registered for the ' . vfsStream::SCHEME . ' protocol.');
113
+ }
114
+
115
+ self::$registered = true;
116
+ }
117
+
118
+ /**
119
+ * sets the root content
120
+ *
121
+ * @param vfsStreamContainer $root
122
+ * @return vfsStreamContainer
123
+ */
124
+ public static function setRoot(vfsStreamContainer $root)
125
+ {
126
+ self::$root = $root;
127
+ clearstatcache();
128
+ return self::$root;
129
+ }
130
+
131
+ /**
132
+ * returns the root content
133
+ *
134
+ * @return vfsStreamContainer
135
+ */
136
+ public static function getRoot()
137
+ {
138
+ return self::$root;
139
+ }
140
+
141
+ /**
142
+ * sets quota for disk space
143
+ *
144
+ * @param Quota $quota
145
+ * @since 1.1.0
146
+ */
147
+ public static function setQuota(Quota $quota)
148
+ {
149
+ self::$quota = $quota;
150
+ }
151
+
152
+ /**
153
+ * returns content for given path
154
+ *
155
+ * @param string $path
156
+ * @return vfsStreamContent
157
+ */
158
+ protected function getContent($path)
159
+ {
160
+ if (null === self::$root) {
161
+ return null;
162
+ }
163
+
164
+ if (self::$root->getName() === $path) {
165
+ return self::$root;
166
+ }
167
+
168
+ if ($this->isInRoot($path) && self::$root->hasChild($path) === true) {
169
+ return self::$root->getChild($path);
170
+ }
171
+
172
+ return null;
173
+ }
174
+
175
+ /**
176
+ * helper method to detect whether given path is in root path
177
+ *
178
+ * @param string $path
179
+ * @return bool
180
+ */
181
+ private function isInRoot($path)
182
+ {
183
+ return substr($path, 0, strlen(self::$root->getName())) === self::$root->getName();
184
+ }
185
+
186
+ /**
187
+ * returns content for given path but only when it is of given type
188
+ *
189
+ * @param string $path
190
+ * @param int $type
191
+ * @return vfsStreamContent
192
+ */
193
+ protected function getContentOfType($path, $type)
194
+ {
195
+ $content = $this->getContent($path);
196
+ if (null !== $content && $content->getType() === $type) {
197
+ return $content;
198
+ }
199
+
200
+ return null;
201
+ }
202
+
203
+ /**
204
+ * splits path into its dirname and the basename
205
+ *
206
+ * @param string $path
207
+ * @return string[]
208
+ */
209
+ protected function splitPath($path)
210
+ {
211
+ $lastSlashPos = strrpos($path, '/');
212
+ if (false === $lastSlashPos) {
213
+ return array('dirname' => '', 'basename' => $path);
214
+ }
215
+
216
+ return array('dirname' => substr($path, 0, $lastSlashPos),
217
+ 'basename' => substr($path, $lastSlashPos + 1)
218
+ );
219
+ }
220
+
221
+ /**
222
+ * helper method to resolve a path from /foo/bar/. to /foo/bar
223
+ *
224
+ * @param string $path
225
+ * @return string
226
+ */
227
+ protected function resolvePath($path)
228
+ {
229
+ $newPath = array();
230
+ foreach (explode('/', $path) as $pathPart) {
231
+ if ('.' !== $pathPart) {
232
+ if ('..' !== $pathPart) {
233
+ $newPath[] = $pathPart;
234
+ } else {
235
+ array_pop($newPath);
236
+ }
237
+ }
238
+ }
239
+
240
+ return implode('/', $newPath);
241
+ }
242
+
243
+ /**
244
+ * open the stream
245
+ *
246
+ * @param string $path the path to open
247
+ * @param string $mode mode for opening
248
+ * @param string $options options for opening
249
+ * @param string $opened_path full path that was actually opened
250
+ * @return bool
251
+ */
252
+ public function stream_open($path, $mode, $options, $opened_path)
253
+ {
254
+ $extended = ((strstr($mode, '+') !== false) ? (true) : (false));
255
+ $mode = str_replace(array('t', 'b', '+'), '', $mode);
256
+ if (in_array($mode, array('r', 'w', 'a', 'x', 'c')) === false) {
257
+ if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
258
+ trigger_error('Illegal mode ' . $mode . ', use r, w, a, x or c, flavoured with t, b and/or +', E_USER_WARNING);
259
+ }
260
+
261
+ return false;
262
+ }
263
+
264
+ $this->mode = $this->calculateMode($mode, $extended);
265
+ $path = $this->resolvePath(vfsStream::path($path));
266
+ $this->content = $this->getContentOfType($path, vfsStreamContent::TYPE_FILE);
267
+ if (null !== $this->content) {
268
+ if (self::WRITE === $mode) {
269
+ if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
270
+ trigger_error('File ' . $path . ' already exists, can not open with mode x', E_USER_WARNING);
271
+ }
272
+
273
+ return false;
274
+ }
275
+
276
+ if (
277
+ (self::TRUNCATE === $mode || self::APPEND === $mode) &&
278
+ $this->content->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false
279
+ ) {
280
+ return false;
281
+ }
282
+
283
+ if (self::TRUNCATE === $mode) {
284
+ $this->content->openWithTruncate();
285
+ } elseif (self::APPEND === $mode) {
286
+ $this->content->openForAppend();
287
+ } else {
288
+ if (!$this->content->isReadable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup())) {
289
+ if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
290
+ trigger_error('Permission denied', E_USER_WARNING);
291
+ }
292
+ return false;
293
+ }
294
+ $this->content->open();
295
+ }
296
+
297
+ return true;
298
+ }
299
+
300
+ $content = $this->createFile($path, $mode, $options);
301
+ if (false === $content) {
302
+ return false;
303
+ }
304
+
305
+ $this->content = $content;
306
+ return true;
307
+ }
308
+
309
+ /**
310
+ * creates a file at given path
311
+ *
312
+ * @param string $path the path to open
313
+ * @param string $mode mode for opening
314
+ * @param string $options options for opening
315
+ * @return bool
316
+ */
317
+ private function createFile($path, $mode = null, $options = null)
318
+ {
319
+ $names = $this->splitPath($path);
320
+ if (empty($names['dirname']) === true) {
321
+ if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
322
+ trigger_error('File ' . $names['basename'] . ' does not exist', E_USER_WARNING);
323
+ }
324
+
325
+ return false;
326
+ }
327
+
328
+ $dir = $this->getContentOfType($names['dirname'], vfsStreamContent::TYPE_DIR);
329
+ if (null === $dir) {
330
+ if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
331
+ trigger_error('Directory ' . $names['dirname'] . ' does not exist', E_USER_WARNING);
332
+ }
333
+
334
+ return false;
335
+ } elseif ($dir->hasChild($names['basename']) === true) {
336
+ if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
337
+ trigger_error('Directory ' . $names['dirname'] . ' already contains a director named ' . $names['basename'], E_USER_WARNING);
338
+ }
339
+
340
+ return false;
341
+ }
342
+
343
+ if (self::READ === $mode) {
344
+ if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
345
+ trigger_error('Can not open non-existing file ' . $path . ' for reading', E_USER_WARNING);
346
+ }
347
+
348
+ return false;
349
+ }
350
+
351
+ if ($dir->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
352
+ if (($options & STREAM_REPORT_ERRORS) === STREAM_REPORT_ERRORS) {
353
+ trigger_error('Can not create new file in non-writable path ' . $names['dirname'], E_USER_WARNING);
354
+ }
355
+
356
+ return false;
357
+ }
358
+
359
+ return vfsStream::newFile($names['basename'])->at($dir);
360
+ }
361
+
362
+ /**
363
+ * calculates the file mode
364
+ *
365
+ * @param string $mode opening mode: r, w, a or x
366
+ * @param bool $extended true if + was set with opening mode
367
+ * @return int
368
+ */
369
+ protected function calculateMode($mode, $extended)
370
+ {
371
+ if (true === $extended) {
372
+ return self::ALL;
373
+ }
374
+
375
+ if (self::READ === $mode) {
376
+ return self::READONLY;
377
+ }
378
+
379
+ return self::WRITEONLY;
380
+ }
381
+
382
+ /**
383
+ * closes the stream
384
+ *
385
+ * @see https://github.com/mikey179/vfsStream/issues/40
386
+ */
387
+ public function stream_close()
388
+ {
389
+ $this->content->lock($this, LOCK_UN);
390
+ }
391
+
392
+ /**
393
+ * read the stream up to $count bytes
394
+ *
395
+ * @param int $count amount of bytes to read
396
+ * @return string
397
+ */
398
+ public function stream_read($count)
399
+ {
400
+ if (self::WRITEONLY === $this->mode) {
401
+ return '';
402
+ }
403
+
404
+ if ($this->content->isReadable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
405
+ return '';
406
+ }
407
+
408
+ return $this->content->read($count);
409
+ }
410
+
411
+ /**
412
+ * writes data into the stream
413
+ *
414
+ * @param string $data
415
+ * @return int amount of bytes written
416
+ */
417
+ public function stream_write($data)
418
+ {
419
+ if (self::READONLY === $this->mode) {
420
+ return 0;
421
+ }
422
+
423
+ if ($this->content->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
424
+ return 0;
425
+ }
426
+
427
+ if (self::$quota->isLimited()) {
428
+ $data = substr($data, 0, self::$quota->spaceLeft(self::$root->sizeSummarized()));
429
+ }
430
+
431
+ return $this->content->write($data);
432
+ }
433
+
434
+ /**
435
+ * truncates a file to a given length
436
+ *
437
+ * @param int $size length to truncate file to
438
+ * @return bool
439
+ * @since 1.1.0
440
+ */
441
+ public function stream_truncate($size)
442
+ {
443
+ if (self::READONLY === $this->mode) {
444
+ return false;
445
+ }
446
+
447
+ if ($this->content->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
448
+ return false;
449
+ }
450
+
451
+ if ($this->content->getType() !== vfsStreamContent::TYPE_FILE) {
452
+ return false;
453
+ }
454
+
455
+ if (self::$quota->isLimited() && $this->content->size() < $size) {
456
+ $maxSize = self::$quota->spaceLeft(self::$root->sizeSummarized());
457
+ if (0 === $maxSize) {
458
+ return false;
459
+ }
460
+
461
+ if ($size > $maxSize) {
462
+ $size = $maxSize;
463
+ }
464
+ }
465
+
466
+ return $this->content->truncate($size);
467
+ }
468
+
469
+ /**
470
+ * sets metadata like owner, user or permissions
471
+ *
472
+ * @param string $path
473
+ * @param int $option
474
+ * @param mixed $var
475
+ * @return bool
476
+ * @since 1.1.0
477
+ */
478
+ public function stream_metadata($path, $option, $var)
479
+ {
480
+ $path = $this->resolvePath(vfsStream::path($path));
481
+ $content = $this->getContent($path);
482
+ switch ($option) {
483
+ case STREAM_META_TOUCH:
484
+ if (null === $content) {
485
+ $content = $this->createFile($path, null, STREAM_REPORT_ERRORS);
486
+ // file creation may not be allowed at provided path
487
+ if (false === $content) {
488
+ return false;
489
+ }
490
+ }
491
+
492
+ $currentTime = time();
493
+ $content->lastModified(((isset($var[0])) ? ($var[0]) : ($currentTime)))
494
+ ->lastAccessed(((isset($var[1])) ? ($var[1]) : ($currentTime)));
495
+ return true;
496
+
497
+ case STREAM_META_OWNER_NAME:
498
+ return false;
499
+
500
+ case STREAM_META_OWNER:
501
+ if (null === $content) {
502
+ return false;
503
+ }
504
+
505
+ return $this->doPermChange($path,
506
+ $content,
507
+ function() use ($content, $var)
508
+ {
509
+ $content->chown($var);
510
+ }
511
+ );
512
+
513
+ case STREAM_META_GROUP_NAME:
514
+ return false;
515
+
516
+ case STREAM_META_GROUP:
517
+ if (null === $content) {
518
+ return false;
519
+ }
520
+
521
+ return $this->doPermChange($path,
522
+ $content,
523
+ function() use ($content, $var)
524
+ {
525
+ $content->chgrp($var);
526
+ }
527
+ );
528
+
529
+ case STREAM_META_ACCESS:
530
+ if (null === $content) {
531
+ return false;
532
+ }
533
+
534
+ return $this->doPermChange($path,
535
+ $content,
536
+ function() use ($content, $var)
537
+ {
538
+ $content->chmod($var);
539
+ }
540
+ );
541
+
542
+ default:
543
+ return false;
544
+ }
545
+ }
546
+
547
+ /**
548
+ * executes given permission change when necessary rights allow such a change
549
+ *
550
+ * @param string $path
551
+ * @param vfsStreamAbstractContent $content
552
+ * @param \Closure $change
553
+ * @return bool
554
+ */
555
+ private function doPermChange($path, vfsStreamAbstractContent $content, \Closure $change)
556
+ {
557
+ if (!$content->isOwnedByUser(vfsStream::getCurrentUser())) {
558
+ return false;
559
+ }
560
+
561
+ if (self::$root->getName() !== $path) {
562
+ $names = $this->splitPath($path);
563
+ $parent = $this->getContent($names['dirname']);
564
+ if (!$parent->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup())) {
565
+ return false;
566
+ }
567
+ }
568
+
569
+ $change();
570
+ return true;
571
+ }
572
+
573
+ /**
574
+ * checks whether stream is at end of file
575
+ *
576
+ * @return bool
577
+ */
578
+ public function stream_eof()
579
+ {
580
+ return $this->content->eof();
581
+ }
582
+
583
+ /**
584
+ * returns the current position of the stream
585
+ *
586
+ * @return int
587
+ */
588
+ public function stream_tell()
589
+ {
590
+ return $this->content->getBytesRead();
591
+ }
592
+
593
+ /**
594
+ * seeks to the given offset
595
+ *
596
+ * @param int $offset
597
+ * @param int $whence
598
+ * @return bool
599
+ */
600
+ public function stream_seek($offset, $whence)
601
+ {
602
+ return $this->content->seek($offset, $whence);
603
+ }
604
+
605
+ /**
606
+ * flushes unstored data into storage
607
+ *
608
+ * @return bool
609
+ */
610
+ public function stream_flush()
611
+ {
612
+ return true;
613
+ }
614
+
615
+ /**
616
+ * returns status of stream
617
+ *
618
+ * @return array
619
+ */
620
+ public function stream_stat()
621
+ {
622
+ $fileStat = array('dev' => 0,
623
+ 'ino' => 0,
624
+ 'mode' => $this->content->getType() | $this->content->getPermissions(),
625
+ 'nlink' => 0,
626
+ 'uid' => $this->content->getUser(),
627
+ 'gid' => $this->content->getGroup(),
628
+ 'rdev' => 0,
629
+ 'size' => $this->content->size(),
630
+ 'atime' => $this->content->fileatime(),
631
+ 'mtime' => $this->content->filemtime(),
632
+ 'ctime' => $this->content->filectime(),
633
+ 'blksize' => -1,
634
+ 'blocks' => -1
635
+ );
636
+ return array_merge(array_values($fileStat), $fileStat);
637
+ }
638
+
639
+ /**
640
+ * retrieve the underlaying resource
641
+ *
642
+ * Please note that this method always returns false as there is no
643
+ * underlaying resource to return.
644
+ *
645
+ * @param int $cast_as
646
+ * @since 0.9.0
647
+ * @see https://github.com/mikey179/vfsStream/issues/3
648
+ * @return bool
649
+ */
650
+ public function stream_cast($cast_as)
651
+ {
652
+ return false;
653
+ }
654
+
655
+ /**
656
+ * set lock status for stream
657
+ *
658
+ * @param int $operation
659
+ * @return bool
660
+ * @since 0.10.0
661
+ * @see https://github.com/mikey179/vfsStream/issues/6
662
+ * @see https://github.com/mikey179/vfsStream/issues/31
663
+ * @see https://github.com/mikey179/vfsStream/issues/40
664
+ */
665
+ public function stream_lock($operation)
666
+ {
667
+ if ((LOCK_NB & $operation) == LOCK_NB) {
668
+ $operation = $operation - LOCK_NB;
669
+ }
670
+
671
+ return $this->content->lock($this, $operation);
672
+ }
673
+
674
+ /**
675
+ * sets options on the stream
676
+ *
677
+ * @param int $option key of option to set
678
+ * @param int $arg1
679
+ * @param int $arg2
680
+ * @return bool
681
+ * @since 0.10.0
682
+ * @see https://github.com/mikey179/vfsStream/issues/15
683
+ * @see http://www.php.net/manual/streamwrapper.stream-set-option.php
684
+ */
685
+ public function stream_set_option($option, $arg1, $arg2)
686
+ {
687
+ switch ($option) {
688
+ case STREAM_OPTION_BLOCKING:
689
+ // break omitted
690
+
691
+ case STREAM_OPTION_READ_TIMEOUT:
692
+ // break omitted
693
+
694
+ case STREAM_OPTION_WRITE_BUFFER:
695
+ // break omitted
696
+
697
+ default:
698
+ // nothing to do here
699
+ }
700
+
701
+ return false;
702
+ }
703
+
704
+ /**
705
+ * remove the data under the given path
706
+ *
707
+ * @param string $path
708
+ * @return bool
709
+ */
710
+ public function unlink($path)
711
+ {
712
+ $realPath = $this->resolvePath(vfsStream::path($path));
713
+ $content = $this->getContent($realPath);
714
+ if (null === $content) {
715
+ trigger_error('unlink(' . $path . '): No such file or directory', E_USER_WARNING);
716
+ return false;
717
+ }
718
+
719
+ if ($content->getType() !== vfsStreamContent::TYPE_FILE) {
720
+ trigger_error('unlink(' . $path . '): Operation not permitted', E_USER_WARNING);
721
+ return false;
722
+ }
723
+
724
+ return $this->doUnlink($realPath);
725
+ }
726
+
727
+ /**
728
+ * removes a path
729
+ *
730
+ * @param string $path
731
+ * @return bool
732
+ */
733
+ protected function doUnlink($path)
734
+ {
735
+ if (self::$root->getName() === $path) {
736
+ // delete root? very brave. :)
737
+ self::$root = null;
738
+ clearstatcache();
739
+ return true;
740
+ }
741
+
742
+ $names = $this->splitPath($path);
743
+ $content = $this->getContent($names['dirname']);
744
+ if (!$content->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup())) {
745
+ return false;
746
+ }
747
+
748
+ clearstatcache();
749
+ return $content->removeChild($names['basename']);
750
+ }
751
+
752
+ /**
753
+ * rename from one path to another
754
+ *
755
+ * @param string $path_from
756
+ * @param string $path_to
757
+ * @return bool
758
+ * @author Benoit Aubuchon
759
+ */
760
+ public function rename($path_from, $path_to)
761
+ {
762
+ $srcRealPath = $this->resolvePath(vfsStream::path($path_from));
763
+ $dstRealPath = $this->resolvePath(vfsStream::path($path_to));
764
+ $srcContent = $this->getContent($srcRealPath);
765
+ if (null == $srcContent) {
766
+ trigger_error(' No such file or directory', E_USER_WARNING);
767
+ return false;
768
+ }
769
+ $dstNames = $this->splitPath($dstRealPath);
770
+ $dstParentContent = $this->getContent($dstNames['dirname']);
771
+ if (null == $dstParentContent) {
772
+ trigger_error('No such file or directory', E_USER_WARNING);
773
+ return false;
774
+ }
775
+ if (!$dstParentContent->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup())) {
776
+ trigger_error('Permission denied', E_USER_WARNING);
777
+ return false;
778
+ }
779
+ if ($dstParentContent->getType() !== vfsStreamContent::TYPE_DIR) {
780
+ trigger_error('Target is not a directory', E_USER_WARNING);
781
+ return false;
782
+ }
783
+
784
+ // remove old source first, so we can rename later
785
+ // (renaming first would lead to not being able to remove the old path)
786
+ if (!$this->doUnlink($srcRealPath)) {
787
+ return false;
788
+ }
789
+
790
+ $dstContent = $srcContent;
791
+ // Renaming the filename
792
+ $dstContent->rename($dstNames['basename']);
793
+ // Copying to the destination
794
+ $dstParentContent->addChild($dstContent);
795
+ return true;
796
+ }
797
+
798
+ /**
799
+ * creates a new directory
800
+ *
801
+ * @param string $path
802
+ * @param int $mode
803
+ * @param int $options
804
+ * @return bool
805
+ */
806
+ public function mkdir($path, $mode, $options)
807
+ {
808
+ $umask = vfsStream::umask();
809
+ if (0 < $umask) {
810
+ $permissions = $mode & ~$umask;
811
+ } else {
812
+ $permissions = $mode;
813
+ }
814
+
815
+ $path = $this->resolvePath(vfsStream::path($path));
816
+ if (null !== $this->getContent($path)) {
817
+ trigger_error('mkdir(): Path vfs://' . $path . ' exists', E_USER_WARNING);
818
+ return false;
819
+ }
820
+
821
+ if (null === self::$root) {
822
+ self::$root = vfsStream::newDirectory($path, $permissions);
823
+ return true;
824
+ }
825
+
826
+ $maxDepth = count(explode('/', $path));
827
+ $names = $this->splitPath($path);
828
+ $newDirs = $names['basename'];
829
+ $dir = null;
830
+ $i = 0;
831
+ while ($dir === null && $i < $maxDepth) {
832
+ $dir = $this->getContent($names['dirname']);
833
+ $names = $this->splitPath($names['dirname']);
834
+ if (null == $dir) {
835
+ $newDirs = $names['basename'] . '/' . $newDirs;
836
+ }
837
+
838
+ $i++;
839
+ }
840
+
841
+ if (null === $dir
842
+ || $dir->getType() !== vfsStreamContent::TYPE_DIR
843
+ || $dir->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
844
+ return false;
845
+ }
846
+
847
+ $recursive = ((STREAM_MKDIR_RECURSIVE & $options) !== 0) ? (true) : (false);
848
+ if (strpos($newDirs, '/') !== false && false === $recursive) {
849
+ return false;
850
+ }
851
+
852
+ vfsStream::newDirectory($newDirs, $permissions)->at($dir);
853
+ return true;
854
+ }
855
+
856
+ /**
857
+ * removes a directory
858
+ *
859
+ * @param string $path
860
+ * @param int $options
861
+ * @return bool
862
+ * @todo consider $options with STREAM_MKDIR_RECURSIVE
863
+ */
864
+ public function rmdir($path, $options)
865
+ {
866
+ $path = $this->resolvePath(vfsStream::path($path));
867
+ $child = $this->getContentOfType($path, vfsStreamContent::TYPE_DIR);
868
+ if (null === $child) {
869
+ return false;
870
+ }
871
+
872
+ // can only remove empty directories
873
+ if (count($child->getChildren()) > 0) {
874
+ return false;
875
+ }
876
+
877
+ if (self::$root->getName() === $path) {
878
+ // delete root? very brave. :)
879
+ self::$root = null;
880
+ clearstatcache();
881
+ return true;
882
+ }
883
+
884
+ $names = $this->splitPath($path);
885
+ $dir = $this->getContentOfType($names['dirname'], vfsStreamContent::TYPE_DIR);
886
+ if ($dir->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
887
+ return false;
888
+ }
889
+
890
+ clearstatcache();
891
+ return $dir->removeChild($child->getName());
892
+ }
893
+
894
+ /**
895
+ * opens a directory
896
+ *
897
+ * @param string $path
898
+ * @param int $options
899
+ * @return bool
900
+ */
901
+ public function dir_opendir($path, $options)
902
+ {
903
+ $path = $this->resolvePath(vfsStream::path($path));
904
+ $this->dir = $this->getContentOfType($path, vfsStreamContent::TYPE_DIR);
905
+ if (null === $this->dir || $this->dir->isReadable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
906
+ return false;
907
+ }
908
+
909
+ $this->dirIterator = $this->dir->getIterator();
910
+ return true;
911
+ }
912
+
913
+ /**
914
+ * reads directory contents
915
+ *
916
+ * @return string
917
+ */
918
+ public function dir_readdir()
919
+ {
920
+ $dir = $this->dirIterator->current();
921
+ if (null === $dir) {
922
+ return false;
923
+ }
924
+
925
+ $this->dirIterator->next();
926
+ return $dir->getName();
927
+ }
928
+
929
+ /**
930
+ * reset directory iteration
931
+ *
932
+ * @return bool
933
+ */
934
+ public function dir_rewinddir()
935
+ {
936
+ return $this->dirIterator->rewind();
937
+ }
938
+
939
+ /**
940
+ * closes directory
941
+ *
942
+ * @return bool
943
+ */
944
+ public function dir_closedir()
945
+ {
946
+ $this->dirIterator = null;
947
+ return true;
948
+ }
949
+
950
+ /**
951
+ * returns status of url
952
+ *
953
+ * @param string $path path of url to return status for
954
+ * @param int $flags flags set by the stream API
955
+ * @return array
956
+ */
957
+ public function url_stat($path, $flags)
958
+ {
959
+ $content = $this->getContent($this->resolvePath(vfsStream::path($path)));
960
+ if (null === $content) {
961
+ if (($flags & STREAM_URL_STAT_QUIET) != STREAM_URL_STAT_QUIET) {
962
+ trigger_error(' No such file or directory: ' . $path, E_USER_WARNING);
963
+ }
964
+
965
+ return false;
966
+
967
+ }
968
+
969
+ $fileStat = array('dev' => 0,
970
+ 'ino' => 0,
971
+ 'mode' => $content->getType() | $content->getPermissions(),
972
+ 'nlink' => 0,
973
+ 'uid' => $content->getUser(),
974
+ 'gid' => $content->getGroup(),
975
+ 'rdev' => 0,
976
+ 'size' => $content->size(),
977
+ 'atime' => $content->fileatime(),
978
+ 'mtime' => $content->filemtime(),
979
+ 'ctime' => $content->filectime(),
980
+ 'blksize' => -1,
981
+ 'blocks' => -1
982
+ );
983
+ return array_merge(array_values($fileStat), $fileStat);
984
+ }
985
+ }
986
+ ?>
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamAbstractVisitor.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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\visitor;
11
+ use org\bovigo\vfs\vfsStreamContent;
12
+ use org\bovigo\vfs\vfsStreamBlock;
13
+
14
+ /**
15
+ * Abstract base class providing an implementation for the visit() method.
16
+ *
17
+ * @since 0.10.0
18
+ * @see https://github.com/mikey179/vfsStream/issues/10
19
+ */
20
+ abstract class vfsStreamAbstractVisitor implements vfsStreamVisitor
21
+ {
22
+ /**
23
+ * visit a content and process it
24
+ *
25
+ * @param vfsStreamContent $content
26
+ * @return vfsStreamVisitor
27
+ * @throws \InvalidArgumentException
28
+ */
29
+ public function visit(vfsStreamContent $content)
30
+ {
31
+ switch ($content->getType()) {
32
+ case vfsStreamContent::TYPE_BLOCK:
33
+ $this->visitBlockDevice($content);
34
+ break;
35
+
36
+ case vfsStreamContent::TYPE_FILE:
37
+ $this->visitFile($content);
38
+ break;
39
+
40
+ case vfsStreamContent::TYPE_DIR:
41
+ if (!$content->isDot()) {
42
+ $this->visitDirectory($content);
43
+ }
44
+
45
+ break;
46
+
47
+ default:
48
+ throw new \InvalidArgumentException('Unknown content type ' . $content->getType() . ' for ' . $content->getName());
49
+ }
50
+
51
+ return $this;
52
+ }
53
+
54
+ /**
55
+ * visit a block device and process it
56
+ *
57
+ * @param vfsStreamBlock $block
58
+ * @return vfsStreamVisitor
59
+ */
60
+ public function visitBlockDevice(vfsStreamBlock $block)
61
+ {
62
+ return $this->visitFile($block);
63
+ }
64
+ }
65
+ ?>
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitor.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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\visitor;
11
+ use org\bovigo\vfs\vfsStreamContent;
12
+ use org\bovigo\vfs\vfsStreamDirectory;
13
+ use org\bovigo\vfs\vfsStreamFile;
14
+ use org\bovigo\vfs\vfsStreamBlock;
15
+
16
+ /**
17
+ * Visitor which traverses a content structure recursively to print it to an output stream.
18
+ *
19
+ * @since 0.10.0
20
+ * @see https://github.com/mikey179/vfsStream/issues/10
21
+ */
22
+ class vfsStreamPrintVisitor extends vfsStreamAbstractVisitor
23
+ {
24
+ /**
25
+ * target to write output to
26
+ *
27
+ * @type resource
28
+ */
29
+ protected $out;
30
+ /**
31
+ * current depth in directory tree
32
+ *
33
+ * @type int
34
+ */
35
+ protected $depth;
36
+
37
+ /**
38
+ * constructor
39
+ *
40
+ * If no file pointer given it will fall back to STDOUT.
41
+ *
42
+ * @param resource $out optional
43
+ * @throws \InvalidArgumentException
44
+ * @api
45
+ */
46
+ public function __construct($out = STDOUT)
47
+ {
48
+ if (is_resource($out) === false || get_resource_type($out) !== 'stream') {
49
+ throw new \InvalidArgumentException('Given filepointer is not a resource of type stream');
50
+ }
51
+
52
+ $this->out = $out;
53
+ }
54
+
55
+ /**
56
+ * visit a file and process it
57
+ *
58
+ * @param vfsStreamFile $file
59
+ * @return vfsStreamPrintVisitor
60
+ */
61
+ public function visitFile(vfsStreamFile $file)
62
+ {
63
+ $this->printContent($file->getName());
64
+ return $this;
65
+ }
66
+
67
+ /**
68
+ * visit a block device and process it
69
+ *
70
+ * @param vfsStreamBlock $block
71
+ * @return vfsStreamPrintVisitor
72
+ */
73
+ public function visitBlockDevice(vfsStreamBlock $block)
74
+ {
75
+ $name = '[' . $block->getName() . ']';
76
+ $this->printContent($name);
77
+ return $this;
78
+ }
79
+
80
+ /**
81
+ * visit a directory and process it
82
+ *
83
+ * @param vfsStreamDirectory $dir
84
+ * @return vfsStreamPrintVisitor
85
+ */
86
+ public function visitDirectory(vfsStreamDirectory $dir)
87
+ {
88
+ $this->printContent($dir->getName());
89
+ $this->depth++;
90
+ foreach ($dir as $child) {
91
+ $this->visit($child);
92
+ }
93
+
94
+ $this->depth--;
95
+ return $this;
96
+ }
97
+
98
+ /**
99
+ * helper method to print the content
100
+ *
101
+ * @param string $name
102
+ */
103
+ protected function printContent($name)
104
+ {
105
+ fwrite($this->out, str_repeat(' ', $this->depth) . '- ' . $name . "\n");
106
+ }
107
+ }
108
+ ?>
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamStructureVisitor.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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\visitor;
11
+ use org\bovigo\vfs\vfsStreamDirectory;
12
+ use org\bovigo\vfs\vfsStreamFile;
13
+ use org\bovigo\vfs\vfsStreamBlock;
14
+
15
+ /**
16
+ * Visitor which traverses a content structure recursively to create an array structure from it.
17
+ *
18
+ * @since 0.10.0
19
+ * @see https://github.com/mikey179/vfsStream/issues/10
20
+ */
21
+ class vfsStreamStructureVisitor extends vfsStreamAbstractVisitor
22
+ {
23
+ /**
24
+ * collected structure
25
+ *
26
+ * @type array
27
+ */
28
+ protected $structure = array();
29
+ /**
30
+ * poiting to currently iterated directory
31
+ *
32
+ * @type array
33
+ */
34
+ protected $current;
35
+
36
+ /**
37
+ * constructor
38
+ *
39
+ * @api
40
+ */
41
+ public function __construct()
42
+ {
43
+ $this->reset();
44
+ }
45
+
46
+ /**
47
+ * visit a file and process it
48
+ *
49
+ * @param vfsStreamFile $file
50
+ * @return vfsStreamStructureVisitor
51
+ */
52
+ public function visitFile(vfsStreamFile $file)
53
+ {
54
+ $this->current[$file->getName()] = $file->getContent();
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * visit a block device and process it
60
+ *
61
+ * @param vfsStreamBlock $block
62
+ * @return vfsStreamStructureVisitor
63
+ */
64
+ public function visitBlockDevice(vfsStreamBlock $block)
65
+ {
66
+ $this->current['[' . $block->getName() . ']'] = $block->getContent();
67
+ return $this;
68
+ }
69
+
70
+ /**
71
+ * visit a directory and process it
72
+ *
73
+ * @param vfsStreamDirectory $dir
74
+ * @return vfsStreamStructureVisitor
75
+ */
76
+ public function visitDirectory(vfsStreamDirectory $dir)
77
+ {
78
+ $this->current[$dir->getName()] = array();
79
+ $tmp =& $this->current;
80
+ $this->current =& $tmp[$dir->getName()];
81
+ foreach ($dir as $child) {
82
+ $this->visit($child);
83
+ }
84
+
85
+ $this->current =& $tmp;
86
+ return $this;
87
+ }
88
+
89
+ /**
90
+ * returns structure of visited contents
91
+ *
92
+ * @return array
93
+ * @api
94
+ */
95
+ public function getStructure()
96
+ {
97
+ return $this->structure;
98
+ }
99
+
100
+ /**
101
+ * resets structure so visitor could be reused
102
+ *
103
+ * @return vfsStreamStructureVisitor
104
+ */
105
+ public function reset()
106
+ {
107
+ $this->structure = array();
108
+ $this->current =& $this->structure;
109
+ return $this;
110
+ }
111
+ }
112
+ ?>
vendor/mikey179/vfsStream/src/main/php/org/bovigo/vfs/visitor/vfsStreamVisitor.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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\visitor;
11
+ use org\bovigo\vfs\vfsStreamContent;
12
+ use org\bovigo\vfs\vfsStreamDirectory;
13
+ use org\bovigo\vfs\vfsStreamFile;
14
+ use org\bovigo\vfs\vfsStreamBlock;
15
+
16
+ /**
17
+ * Interface for a visitor to work on a vfsStream content structure.
18
+ *
19
+ * @since 0.10.0
20
+ * @see https://github.com/mikey179/vfsStream/issues/10
21
+ */
22
+ interface vfsStreamVisitor
23
+ {
24
+ /**
25
+ * visit a content and process it
26
+ *
27
+ * @param vfsStreamContent $content
28
+ * @return vfsStreamVisitor
29
+ */
30
+ public function visit(vfsStreamContent $content);
31
+
32
+ /**
33
+ * visit a file and process it
34
+ *
35
+ * @param vfsStreamFile $file
36
+ * @return vfsStreamVisitor
37
+ */
38
+ public function visitFile(vfsStreamFile $file);
39
+
40
+ /**
41
+ * visit a directory and process it
42
+ *
43
+ * @param vfsStreamDirectory $dir
44
+ * @return vfsStreamVisitor
45
+ */
46
+ public function visitDirectory(vfsStreamDirectory $dir);
47
+
48
+ /**
49
+ * visit a block device and process it
50
+ *
51
+ * @param vfsStreamBlock $block
52
+ * @return vfsStreamVisitor
53
+ */
54
+ public function visitBlockDevice(vfsStreamBlock $block);
55
+ }
56
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/DirectoryIterationTestCase.php ADDED
@@ -0,0 +1,318 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ require_once __DIR__ . '/vfsStreamWrapperBaseTestCase.php';
12
+ /**
13
+ * Test for directory iteration.
14
+ *
15
+ * @group dir
16
+ * @group iteration
17
+ */
18
+ class DirectoryIterationTestCase extends vfsStreamWrapperBaseTestCase
19
+ {
20
+ /**
21
+ * clean up test environment
22
+ */
23
+ public function tearDown()
24
+ {
25
+ vfsStream::enableDotfiles();
26
+ }
27
+
28
+ /**
29
+ * @return array
30
+ */
31
+ public function provideSwitchWithExpectations()
32
+ {
33
+ return array(array(function() { vfsStream::disableDotfiles(); }, array('bar', 'baz2')),
34
+ array(function() { vfsStream::enableDotfiles(); }, array('.', '..', 'bar', 'baz2'))
35
+ );
36
+ }
37
+
38
+ /**
39
+ * assertion for directoy count
40
+ *
41
+ * @param int $expectedCount
42
+ * @param int $actualCount
43
+ */
44
+ private function assertDirectoryCount($expectedCount, $actualCount)
45
+ {
46
+ $this->assertEquals($expectedCount,
47
+ $actualCount,
48
+ 'Directory foo contains ' . $expectedCount . ' children, but got ' . $actualCount . ' children while iterating over directory contents'
49
+ );
50
+ }
51
+
52
+ /**
53
+ * @param \Closure $dotFilesSwitch
54
+ * @param string[] $expectedDirectories
55
+ * @test
56
+ * @dataProvider provideSwitchWithExpectations
57
+ */
58
+ public function directoryIteration(\Closure $dotFilesSwitch, array $expectedDirectories)
59
+ {
60
+ $dotFilesSwitch();
61
+ $dir = dir($this->fooURL);
62
+ $i = 0;
63
+ while (false !== ($entry = $dir->read())) {
64
+ $i++;
65
+ $this->assertTrue(in_array($entry, $expectedDirectories));
66
+ }
67
+
68
+ $this->assertDirectoryCount(count($expectedDirectories), $i);
69
+ $dir->rewind();
70
+ $i = 0;
71
+ while (false !== ($entry = $dir->read())) {
72
+ $i++;
73
+ $this->assertTrue(in_array($entry, $expectedDirectories));
74
+ }
75
+
76
+ $this->assertDirectoryCount(count($expectedDirectories), $i);
77
+ $dir->close();
78
+ }
79
+
80
+ /**
81
+ * @param \Closure $dotFilesSwitch
82
+ * @param string[] $expectedDirectories
83
+ * @test
84
+ * @dataProvider provideSwitchWithExpectations
85
+ */
86
+ public function directoryIterationWithDot(\Closure $dotFilesSwitch, array $expectedDirectories)
87
+ {
88
+ $dotFilesSwitch();
89
+ $dir = dir($this->fooURL . '/.');
90
+ $i = 0;
91
+ while (false !== ($entry = $dir->read())) {
92
+ $i++;
93
+ $this->assertTrue(in_array($entry, $expectedDirectories));
94
+ }
95
+
96
+ $this->assertDirectoryCount(count($expectedDirectories), $i);
97
+ $dir->rewind();
98
+ $i = 0;
99
+ while (false !== ($entry = $dir->read())) {
100
+ $i++;
101
+ $this->assertTrue(in_array($entry, $expectedDirectories));
102
+ }
103
+
104
+ $this->assertDirectoryCount(count($expectedDirectories), $i);
105
+ $dir->close();
106
+ }
107
+
108
+ /**
109
+ * assure that a directory iteration works as expected
110
+ *
111
+ * @param \Closure $dotFilesSwitch
112
+ * @param string[] $expectedDirectories
113
+ * @test
114
+ * @dataProvider provideSwitchWithExpectations
115
+ * @group regression
116
+ * @group bug_2
117
+ */
118
+ public function directoryIterationWithOpenDir_Bug_2(\Closure $dotFilesSwitch, array $expectedDirectories)
119
+ {
120
+ $dotFilesSwitch();
121
+ $handle = opendir($this->fooURL);
122
+ $i = 0;
123
+ while (false !== ($entry = readdir($handle))) {
124
+ $i++;
125
+ $this->assertTrue(in_array($entry, $expectedDirectories));
126
+ }
127
+
128
+ $this->assertDirectoryCount(count($expectedDirectories), $i);
129
+
130
+ rewinddir($handle);
131
+ $i = 0;
132
+ while (false !== ($entry = readdir($handle))) {
133
+ $i++;
134
+ $this->assertTrue(in_array($entry, $expectedDirectories));
135
+ }
136
+
137
+ $this->assertDirectoryCount(count($expectedDirectories), $i);
138
+ closedir($handle);
139
+ }
140
+
141
+ /**
142
+ * assure that a directory iteration works as expected
143
+ *
144
+ * @author Christoph Bloemer
145
+ * @param \Closure $dotFilesSwitch
146
+ * @param string[] $expectedDirectories
147
+ * @test
148
+ * @dataProvider provideSwitchWithExpectations
149
+ * @group regression
150
+ * @group bug_4
151
+ */
152
+ public function directoryIteration_Bug_4(\Closure $dotFilesSwitch, array $expectedDirectories)
153
+ {
154
+ $dotFilesSwitch();
155
+ $dir = $this->fooURL;
156
+ $list1 = array();
157
+ if ($handle = opendir($dir)) {
158
+ while (false !== ($listItem = readdir($handle))) {
159
+ if ('.' != $listItem && '..' != $listItem) {
160
+ if (is_file($dir . '/' . $listItem) === true) {
161
+ $list1[] = 'File:[' . $listItem . ']';
162
+ } elseif (is_dir($dir . '/' . $listItem) === true) {
163
+ $list1[] = 'Folder:[' . $listItem . ']';
164
+ }
165
+ }
166
+ }
167
+
168
+ closedir($handle);
169
+ }
170
+
171
+ $list2 = array();
172
+ if ($handle = opendir($dir)) {
173
+ while (false !== ($listItem = readdir($handle))) {
174
+ if ('.' != $listItem && '..' != $listItem) {
175
+ if (is_file($dir . '/' . $listItem) === true) {
176
+ $list2[] = 'File:[' . $listItem . ']';
177
+ } elseif (is_dir($dir . '/' . $listItem) === true) {
178
+ $list2[] = 'Folder:[' . $listItem . ']';
179
+ }
180
+ }
181
+ }
182
+
183
+ closedir($handle);
184
+ }
185
+
186
+ $this->assertEquals($list1, $list2);
187
+ $this->assertEquals(2, count($list1));
188
+ $this->assertEquals(2, count($list2));
189
+ }
190
+
191
+ /**
192
+ * assure that a directory iteration works as expected
193
+ *
194
+ * @param \Closure $dotFilesSwitch
195
+ * @param string[] $expectedDirectories
196
+ * @test
197
+ * @dataProvider provideSwitchWithExpectations
198
+ */
199
+ public function directoryIterationShouldBeIndependent(\Closure $dotFilesSwitch, array $expectedDirectories)
200
+ {
201
+ $dotFilesSwitch();
202
+ $list1 = array();
203
+ $list2 = array();
204
+ $handle1 = opendir($this->fooURL);
205
+ if (false !== ($listItem = readdir($handle1))) {
206
+ $list1[] = $listItem;
207
+ }
208
+
209
+ $handle2 = opendir($this->fooURL);
210
+ if (false !== ($listItem = readdir($handle2))) {
211
+ $list2[] = $listItem;
212
+ }
213
+
214
+ if (false !== ($listItem = readdir($handle1))) {
215
+ $list1[] = $listItem;
216
+ }
217
+
218
+ if (false !== ($listItem = readdir($handle2))) {
219
+ $list2[] = $listItem;
220
+ }
221
+
222
+ closedir($handle1);
223
+ closedir($handle2);
224
+ $this->assertEquals($list1, $list2);
225
+ $this->assertEquals(2, count($list1));
226
+ $this->assertEquals(2, count($list2));
227
+ }
228
+
229
+ /**
230
+ * @test
231
+ * @group issue_50
232
+ */
233
+ public function recursiveDirectoryIterationWithDotsEnabled()
234
+ {
235
+ vfsStream::enableDotfiles();
236
+ vfsStream::setup();
237
+ $structure = array(
238
+ 'Core' => array(
239
+ 'AbstractFactory' => array(
240
+ 'test.php' => 'some text content',
241
+ 'other.php' => 'Some more text content',
242
+ 'Invalid.csv' => 'Something else',
243
+ ),
244
+ 'AnEmptyFolder' => array(),
245
+ 'badlocation.php' => 'some bad content',
246
+ )
247
+ );
248
+ $root = vfsStream::create($structure);
249
+ $rootPath = vfsStream::url($root->getName());
250
+
251
+ $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($rootPath),
252
+ \RecursiveIteratorIterator::CHILD_FIRST);
253
+ $pathes = array();
254
+ foreach ($iterator as $fullFileName => $fileSPLObject) {
255
+ $pathes[] = $fullFileName;
256
+ }
257
+
258
+ $this->assertEquals(array('vfs://root'.DIRECTORY_SEPARATOR.'.',
259
+ 'vfs://root'.DIRECTORY_SEPARATOR.'..',
260
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'.',
261
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'..',
262
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'AbstractFactory'.DIRECTORY_SEPARATOR.'.',
263
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'AbstractFactory'.DIRECTORY_SEPARATOR.'..',
264
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'AbstractFactory'.DIRECTORY_SEPARATOR.'test.php',
265
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'AbstractFactory'.DIRECTORY_SEPARATOR.'other.php',
266
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'AbstractFactory'.DIRECTORY_SEPARATOR.'Invalid.csv',
267
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'AbstractFactory',
268
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'AnEmptyFolder'.DIRECTORY_SEPARATOR.'.',
269
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'AnEmptyFolder'.DIRECTORY_SEPARATOR.'..',
270
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'AnEmptyFolder',
271
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'badlocation.php',
272
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'
273
+ ),
274
+ $pathes
275
+ );
276
+ }
277
+
278
+ /**
279
+ * @test
280
+ * @group issue_50
281
+ */
282
+ public function recursiveDirectoryIterationWithDotsDisabled()
283
+ {
284
+ vfsStream::disableDotfiles();
285
+ vfsStream::setup();
286
+ $structure = array(
287
+ 'Core' => array(
288
+ 'AbstractFactory' => array(
289
+ 'test.php' => 'some text content',
290
+ 'other.php' => 'Some more text content',
291
+ 'Invalid.csv' => 'Something else',
292
+ ),
293
+ 'AnEmptyFolder' => array(),
294
+ 'badlocation.php' => 'some bad content',
295
+ )
296
+ );
297
+ $root = vfsStream::create($structure);
298
+ $rootPath = vfsStream::url($root->getName());
299
+
300
+ $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($rootPath),
301
+ \RecursiveIteratorIterator::CHILD_FIRST);
302
+ $pathes = array();
303
+ foreach ($iterator as $fullFileName => $fileSPLObject) {
304
+ $pathes[] = $fullFileName;
305
+ }
306
+
307
+ $this->assertEquals(array('vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'AbstractFactory'.DIRECTORY_SEPARATOR.'test.php',
308
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'AbstractFactory'.DIRECTORY_SEPARATOR.'other.php',
309
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'AbstractFactory'.DIRECTORY_SEPARATOR.'Invalid.csv',
310
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'AbstractFactory',
311
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'AnEmptyFolder',
312
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'.DIRECTORY_SEPARATOR.'badlocation.php',
313
+ 'vfs://root'.DIRECTORY_SEPARATOR.'Core'
314
+ ),
315
+ $pathes
316
+ );
317
+ }
318
+ }
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/Issue104TestCase.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * @group issue_104
13
+ * @since 1.5.0
14
+ */
15
+ class Issue104TestCase extends \PHPUnit_Framework_TestCase
16
+ {
17
+ /**
18
+ * @test
19
+ */
20
+ public function vfsStreamCanHandleUrlEncodedPathPassedByInternalPhpCode()
21
+ {
22
+ $structure = array('foo bar' => array(
23
+ 'schema.xsd' => '<xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
24
+ <xs:complexType name="myType"></xs:complexType>
25
+ </xs:schema>',
26
+ )
27
+ );
28
+ vfsStream::setup('root', null, $structure);
29
+ $doc = new \DOMDocument();
30
+ $this->assertTrue($doc->load(vfsStream::url('root/foo bar/schema.xsd')));
31
+ }
32
+
33
+ /**
34
+ * @test
35
+ */
36
+ public function vfsStreamCanHandleUrlEncodedPath()
37
+ {
38
+ $content = '<xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
39
+ <xs:complexType name="myType"></xs:complexType>
40
+ </xs:schema>';
41
+ $structure = array('foo bar' => array(
42
+ 'schema.xsd' => $content,
43
+ )
44
+ );
45
+ vfsStream::setup('root', null, $structure);
46
+ $this->assertEquals(
47
+ $content,
48
+ file_get_contents(vfsStream::url('root/foo%20bar/schema.xsd'))
49
+ );
50
+ }
51
+ }
52
+
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/PermissionsTestCase.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for permissions related functionality.
13
+ *
14
+ * @group permissions
15
+ */
16
+ class PermissionsTestCase extends \PHPUnit_Framework_TestCase
17
+ {
18
+ /**
19
+ * @type vfsStreamDirectory
20
+ */
21
+ private $root;
22
+
23
+ /**
24
+ * set up test environment
25
+ */
26
+ public function setup()
27
+ {
28
+ $structure = array('test_directory' => array('test.file' => ''));
29
+ $this->root = vfsStream::setup('root', null, $structure);
30
+ }
31
+
32
+ /**
33
+ * @test
34
+ * @group issue_52
35
+ */
36
+ public function canNotChangePermissionWhenDirectoryNotWriteable()
37
+ {
38
+ $this->root->getChild('test_directory')->chmod(0444);
39
+ $this->assertFalse(@chmod(vfsStream::url('root/test_directory/test.file'), 0777));
40
+ }
41
+
42
+ /**
43
+ * @test
44
+ * @group issue_53
45
+ */
46
+ public function canNotChangePermissionWhenFileNotOwned()
47
+ {
48
+ $this->root->getChild('test_directory')->getChild('test.file')->chown(vfsStream::OWNER_USER_1);
49
+ $this->assertFalse(@chmod(vfsStream::url('root/test_directory/test.file'), 0777));
50
+ }
51
+
52
+ /**
53
+ * @test
54
+ * @group issue_52
55
+ */
56
+ public function canNotChangeOwnerWhenDirectoryNotWriteable()
57
+ {
58
+ $this->root->getChild('test_directory')->chmod(0444);
59
+ $this->assertFalse(@chown(vfsStream::url('root/test_directory/test.file'), vfsStream::OWNER_USER_2));
60
+ }
61
+
62
+ /**
63
+ * @test
64
+ * @group issue_53
65
+ */
66
+ public function canNotChangeOwnerWhenFileNotOwned()
67
+ {
68
+ $this->root->getChild('test_directory')->getChild('test.file')->chown(vfsStream::OWNER_USER_1);
69
+ $this->assertFalse(@chown(vfsStream::url('root/test_directory/test.file'), vfsStream::OWNER_USER_2));
70
+ }
71
+
72
+ /**
73
+ * @test
74
+ * @group issue_52
75
+ */
76
+ public function canNotChangeGroupWhenDirectoryNotWriteable()
77
+ {
78
+ $this->root->getChild('test_directory')->chmod(0444);
79
+ $this->assertFalse(@chgrp(vfsStream::url('root/test_directory/test.file'), vfsStream::GROUP_USER_2));
80
+ }
81
+
82
+ /**
83
+ * @test
84
+ * @group issue_53
85
+ */
86
+ public function canNotChangeGroupWhenFileNotOwned()
87
+ {
88
+ $this->root->getChild('test_directory')->getChild('test.file')->chown(vfsStream::OWNER_USER_1);
89
+ $this->assertFalse(@chgrp(vfsStream::url('root/test_directory/test.file'), vfsStream::GROUP_USER_2));
90
+ }
91
+
92
+ /**
93
+ * @test
94
+ * @group issue_107
95
+ * @expectedException PHPUnit_Framework_Error
96
+ * @expectedExceptionMessage Can not create new file in non-writable path root
97
+ * @requires PHP 5.4
98
+ * @since 1.5.0
99
+ */
100
+ public function touchOnNonWriteableDirectoryTriggersError()
101
+ {
102
+ $this->root->chmod(0555);
103
+ touch($this->root->url() . '/touch.txt');
104
+ }
105
+
106
+ /**
107
+ * @test
108
+ * @group issue_107
109
+ * @requires PHP 5.4
110
+ * @since 1.5.0
111
+ */
112
+ public function touchOnNonWriteableDirectoryDoesNotCreateFile()
113
+ {
114
+ $this->root->chmod(0555);
115
+ $this->assertFalse(@touch($this->root->url() . '/touch.txt'));
116
+ $this->assertFalse($this->root->hasChild('touch.txt'));
117
+ }
118
+ }
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/QuotaTestCase.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for org\bovigo\vfs\Quota.
13
+ *
14
+ * @group issue_35
15
+ */
16
+ class QuotaTestCase extends \PHPUnit_Framework_TestCase
17
+ {
18
+ /**
19
+ * instance to test
20
+ *
21
+ * @type Quota
22
+ */
23
+ private $quota;
24
+
25
+ /**
26
+ * set up test environment
27
+ */
28
+ public function setUp()
29
+ {
30
+ $this->quota = new Quota(10);
31
+ }
32
+
33
+ /**
34
+ * @test
35
+ */
36
+ public function unlimitedQuotaIsNotLimited()
37
+ {
38
+ $this->assertFalse(Quota::unlimited()->isLimited());
39
+ }
40
+
41
+ /**
42
+ * @test
43
+ */
44
+ public function limitedQuotaIsLimited()
45
+ {
46
+ $this->assertTrue($this->quota->isLimited());
47
+ }
48
+
49
+ /**
50
+ * @test
51
+ */
52
+ public function unlimitedQuotaHasAlwaysSpaceLeft()
53
+ {
54
+ $this->assertEquals(303, Quota::unlimited()->spaceLeft(303));
55
+ }
56
+
57
+ /**
58
+ * @test
59
+ */
60
+ public function hasNoSpaceLeftWhenUsedSpaceIsLargerThanQuota()
61
+ {
62
+ $this->assertEquals(0, $this->quota->spaceLeft(11));
63
+ }
64
+
65
+ /**
66
+ * @test
67
+ */
68
+ public function hasNoSpaceLeftWhenUsedSpaceIsEqualToQuota()
69
+ {
70
+ $this->assertEquals(0, $this->quota->spaceLeft(10));
71
+ }
72
+
73
+ /**
74
+ * @test
75
+ */
76
+ public function hasSpaceLeftWhenUsedSpaceIsLowerThanQuota()
77
+ {
78
+ $this->assertEquals(1, $this->quota->spaceLeft(9));
79
+ }
80
+ }
81
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/UnlinkTestCase.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for unlink() functionality.
13
+ *
14
+ * @group unlink
15
+ */
16
+ class UnlinkTestCase extends \PHPUnit_Framework_TestCase
17
+ {
18
+ /**
19
+ * @test
20
+ * @group issue_51
21
+ */
22
+ public function canRemoveNonWritableFileFromWritableDirectory()
23
+ {
24
+ $structure = array('test_directory' => array('test.file' => ''));
25
+ $root = vfsStream::setup('root', null, $structure);
26
+ $root->getChild('test_directory')->chmod(0777);
27
+ $root->getChild('test_directory')->getChild('test.file')->chmod(0444);
28
+ $this->assertTrue(@unlink(vfsStream::url('root/test_directory/test.file')));
29
+ }
30
+
31
+ /**
32
+ * @test
33
+ * @group issue_51
34
+ */
35
+ public function canNotRemoveWritableFileFromNonWritableDirectory()
36
+ {
37
+ $structure = array('test_directory' => array('test.file' => ''));
38
+ $root = vfsStream::setup('root', null, $structure);
39
+ $root->getChild('test_directory')->chmod(0444);
40
+ $root->getChild('test_directory')->getChild('test.file')->chmod(0777);
41
+ $this->assertFalse(@unlink(vfsStream::url('root/test_directory/test.file')));
42
+ }
43
+
44
+ /**
45
+ * @test
46
+ * @since 1.4.0
47
+ * @group issue_68
48
+ */
49
+ public function unlinkNonExistingFileTriggersError()
50
+ {
51
+ vfsStream::setup();
52
+ try {
53
+ $this->assertFalse(unlink('vfs://root/foo.txt'));
54
+ } catch (\PHPUnit_Framework_Error $fe) {
55
+ $this->assertEquals('unlink(vfs://root/foo.txt): No such file or directory', $fe->getMessage());
56
+ }
57
+ }
58
+ }
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/content/LargeFileContentTestCase.php ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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\content;
11
+ /**
12
+ * Test for org\bovigo\vfs\content\LargeFileContent.
13
+ *
14
+ * @since 1.3.0
15
+ * @group issue_79
16
+ */
17
+ class LargeFileContentTestCase extends \PHPUnit_Framework_TestCase
18
+ {
19
+ /**
20
+ * instance to test
21
+ *
22
+ * @type LargeFileContent
23
+ */
24
+ private $largeFileContent;
25
+
26
+ /**
27
+ * set up test environment
28
+ */
29
+ public function setUp()
30
+ {
31
+ $this->largeFileContent = new LargeFileContent(100);
32
+ }
33
+
34
+ /**
35
+ * @test
36
+ */
37
+ public function hasSizeOriginallyGiven()
38
+ {
39
+ $this->assertEquals(100, $this->largeFileContent->size());
40
+ }
41
+
42
+ /**
43
+ * @test
44
+ */
45
+ public function contentIsFilledUpWithSpacesIfNoDataWritten()
46
+ {
47
+ $this->assertEquals(
48
+ str_repeat(' ', 100),
49
+ $this->largeFileContent->content()
50
+ );
51
+ }
52
+
53
+ /**
54
+ * @test
55
+ */
56
+ public function readReturnsSpacesWhenNothingWrittenAtOffset()
57
+ {
58
+ $this->assertEquals(
59
+ str_repeat(' ', 10),
60
+ $this->largeFileContent->read(10)
61
+ );
62
+ }
63
+
64
+ /**
65
+ * @test
66
+ */
67
+ public function readReturnsContentFilledWithSpaces()
68
+ {
69
+ $this->largeFileContent->write('foobarbaz');
70
+ $this->largeFileContent->seek(0, SEEK_SET);
71
+ $this->assertEquals(
72
+ 'foobarbaz ',
73
+ $this->largeFileContent->read(10)
74
+ );
75
+ }
76
+
77
+ /**
78
+ * @test
79
+ */
80
+ public function writesDataAtStartWhenOffsetNotMoved()
81
+ {
82
+ $this->assertEquals(9, $this->largeFileContent->write('foobarbaz'));
83
+ $this->assertEquals(
84
+ 'foobarbaz' . str_repeat(' ', 91),
85
+ $this->largeFileContent->content()
86
+ );
87
+ }
88
+
89
+ /**
90
+ * @test
91
+ */
92
+ public function writeDataAtStartDoesNotIncreaseSize()
93
+ {
94
+ $this->assertEquals(9, $this->largeFileContent->write('foobarbaz'));
95
+ $this->assertEquals(100, $this->largeFileContent->size());
96
+ }
97
+
98
+ /**
99
+ * @test
100
+ */
101
+ public function writesDataAtOffsetWhenOffsetMoved()
102
+ {
103
+ $this->largeFileContent->seek(50, SEEK_SET);
104
+ $this->assertEquals(9, $this->largeFileContent->write('foobarbaz'));
105
+ $this->assertEquals(
106
+ str_repeat(' ', 50) . 'foobarbaz' . str_repeat(' ', 41),
107
+ $this->largeFileContent->content()
108
+ );
109
+ }
110
+
111
+ /**
112
+ * @test
113
+ */
114
+ public function writeDataInBetweenDoesNotIncreaseSize()
115
+ {
116
+ $this->largeFileContent->seek(50, SEEK_SET);
117
+ $this->assertEquals(9, $this->largeFileContent->write('foobarbaz'));
118
+ $this->assertEquals(100, $this->largeFileContent->size());
119
+ }
120
+
121
+ /**
122
+ * @test
123
+ */
124
+ public function writesDataOverEndWhenOffsetAndDataLengthLargerThanSize()
125
+ {
126
+ $this->largeFileContent->seek(95, SEEK_SET);
127
+ $this->assertEquals(9, $this->largeFileContent->write('foobarbaz'));
128
+ $this->assertEquals(
129
+ str_repeat(' ', 95) . 'foobarbaz',
130
+ $this->largeFileContent->content()
131
+ );
132
+ }
133
+
134
+ /**
135
+ * @test
136
+ */
137
+ public function writeDataOverLastOffsetIncreasesSize()
138
+ {
139
+ $this->largeFileContent->seek(95, SEEK_SET);
140
+ $this->assertEquals(9, $this->largeFileContent->write('foobarbaz'));
141
+ $this->assertEquals(104, $this->largeFileContent->size());
142
+ }
143
+
144
+ /**
145
+ * @test
146
+ */
147
+ public function writesDataAfterEndWhenOffsetAfterEnd()
148
+ {
149
+ $this->largeFileContent->seek(0, SEEK_END);
150
+ $this->assertEquals(9, $this->largeFileContent->write('foobarbaz'));
151
+ $this->assertEquals(
152
+ str_repeat(' ', 100) . 'foobarbaz',
153
+ $this->largeFileContent->content()
154
+ );
155
+ }
156
+
157
+ /**
158
+ * @test
159
+ */
160
+ public function writeDataAfterLastOffsetIncreasesSize()
161
+ {
162
+ $this->largeFileContent->seek(0, SEEK_END);
163
+ $this->assertEquals(9, $this->largeFileContent->write('foobarbaz'));
164
+ $this->assertEquals(109, $this->largeFileContent->size());
165
+ }
166
+
167
+ /**
168
+ * @test
169
+ */
170
+ public function truncateReducesSize()
171
+ {
172
+ $this->assertTrue($this->largeFileContent->truncate(50));
173
+ $this->assertEquals(50, $this->largeFileContent->size());
174
+ }
175
+
176
+ /**
177
+ * @test
178
+ */
179
+ public function truncateRemovesWrittenContentAfterOffset()
180
+ {
181
+ $this->largeFileContent->seek(45, SEEK_SET);
182
+ $this->largeFileContent->write('foobarbaz');
183
+ $this->assertTrue($this->largeFileContent->truncate(50));
184
+ $this->assertEquals(
185
+ str_repeat(' ', 45) . 'fooba',
186
+ $this->largeFileContent->content()
187
+ );
188
+ }
189
+
190
+ /**
191
+ * @test
192
+ */
193
+ public function createInstanceWithKilobytes()
194
+ {
195
+ $this->assertEquals(
196
+ 100 * 1024,
197
+ LargeFileContent::withKilobytes(100)
198
+ ->size()
199
+ );
200
+ }
201
+
202
+ /**
203
+ * @test
204
+ */
205
+ public function createInstanceWithMegabytes()
206
+ {
207
+ $this->assertEquals(
208
+ 100 * 1024 * 1024,
209
+ LargeFileContent::withMegabytes(100)
210
+ ->size()
211
+ );
212
+ }
213
+
214
+ /**
215
+ * @test
216
+ */
217
+ public function createInstanceWithGigabytes()
218
+ {
219
+ $this->assertEquals(
220
+ 100 * 1024 * 1024 * 1024,
221
+ LargeFileContent::withGigabytes(100)
222
+ ->size()
223
+ );
224
+ }
225
+ }
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/content/StringBasedFileContentTestCase.php ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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\content;
11
+ /**
12
+ * Test for org\bovigo\vfs\content\StringBasedFileContent.
13
+ *
14
+ * @since 1.3.0
15
+ * @group issue_79
16
+ */
17
+ class StringBasedFileContentTestCase extends \PHPUnit_Framework_TestCase
18
+ {
19
+ /**
20
+ * instance to test
21
+ *
22
+ * @type StringBasedFileContent
23
+ */
24
+ private $stringBasedFileContent;
25
+
26
+ /**
27
+ * set up test environment
28
+ */
29
+ public function setUp()
30
+ {
31
+ $this->stringBasedFileContent = new StringBasedFileContent('foobarbaz');
32
+ }
33
+
34
+ /**
35
+ * @test
36
+ */
37
+ public function hasContentOriginallySet()
38
+ {
39
+ $this->assertEquals('foobarbaz', $this->stringBasedFileContent->content());
40
+ }
41
+
42
+ /**
43
+ * @test
44
+ */
45
+ public function hasNotReachedEofAfterCreation()
46
+ {
47
+ $this->assertFalse($this->stringBasedFileContent->eof());
48
+ }
49
+
50
+ /**
51
+ * @test
52
+ */
53
+ public function sizeEqualsLengthOfGivenString()
54
+ {
55
+ $this->assertEquals(9, $this->stringBasedFileContent->size());
56
+ }
57
+
58
+ /**
59
+ * @test
60
+ */
61
+ public function readReturnsSubstringWithRequestedLength()
62
+ {
63
+ $this->assertEquals('foo', $this->stringBasedFileContent->read(3));
64
+ }
65
+
66
+ /**
67
+ * @test
68
+ */
69
+ public function readMovesOffset()
70
+ {
71
+ $this->assertEquals('foo', $this->stringBasedFileContent->read(3));
72
+ $this->assertEquals('bar', $this->stringBasedFileContent->read(3));
73
+ $this->assertEquals('baz', $this->stringBasedFileContent->read(3));
74
+ }
75
+
76
+ /**
77
+ * @test
78
+ */
79
+ public function reaMoreThanSizeReturnsWholeContent()
80
+ {
81
+ $this->assertEquals('foobarbaz', $this->stringBasedFileContent->read(10));
82
+ }
83
+
84
+ /**
85
+ * @test
86
+ */
87
+ public function readAfterEndReturnsEmptyString()
88
+ {
89
+ $this->stringBasedFileContent->read(9);
90
+ $this->assertEquals('', $this->stringBasedFileContent->read(3));
91
+ }
92
+
93
+ /**
94
+ * @test
95
+ */
96
+ public function readDoesNotChangeSize()
97
+ {
98
+ $this->stringBasedFileContent->read(3);
99
+ $this->assertEquals(9, $this->stringBasedFileContent->size());
100
+ }
101
+
102
+ /**
103
+ * @test
104
+ */
105
+ public function readLessThenSizeDoesNotReachEof()
106
+ {
107
+ $this->stringBasedFileContent->read(3);
108
+ $this->assertFalse($this->stringBasedFileContent->eof());
109
+ }
110
+
111
+ /**
112
+ * @test
113
+ */
114
+ public function readSizeReachesEof()
115
+ {
116
+ $this->stringBasedFileContent->read(9);
117
+ $this->assertTrue($this->stringBasedFileContent->eof());
118
+ }
119
+
120
+ /**
121
+ * @test
122
+ */
123
+ public function readMoreThanSizeReachesEof()
124
+ {
125
+ $this->stringBasedFileContent->read(10);
126
+ $this->assertTrue($this->stringBasedFileContent->eof());
127
+ }
128
+
129
+ /**
130
+ * @test
131
+ */
132
+ public function seekWithInvalidOptionReturnsFalse()
133
+ {
134
+ $this->assertFalse($this->stringBasedFileContent->seek(0, 55));
135
+ }
136
+
137
+ /**
138
+ * @test
139
+ */
140
+ public function canSeekToGivenOffset()
141
+ {
142
+ $this->assertTrue($this->stringBasedFileContent->seek(5, SEEK_SET));
143
+ $this->assertEquals('rbaz', $this->stringBasedFileContent->read(10));
144
+ }
145
+
146
+ /**
147
+ * @test
148
+ */
149
+ public function canSeekFromCurrentOffset()
150
+ {
151
+ $this->assertTrue($this->stringBasedFileContent->seek(5, SEEK_SET));
152
+ $this->assertTrue($this->stringBasedFileContent->seek(2, SEEK_CUR));
153
+ $this->assertEquals('az', $this->stringBasedFileContent->read(10));
154
+ }
155
+
156
+ /**
157
+ * @test
158
+ */
159
+ public function canSeekToEnd()
160
+ {
161
+ $this->assertTrue($this->stringBasedFileContent->seek(0, SEEK_END));
162
+ $this->assertEquals('', $this->stringBasedFileContent->read(10));
163
+ }
164
+
165
+ /**
166
+ * @test
167
+ */
168
+ public function writeOverwritesExistingContentWhenOffsetNotAtEof()
169
+ {
170
+ $this->assertEquals(3, $this->stringBasedFileContent->write('bar'));
171
+ $this->assertEquals('barbarbaz', $this->stringBasedFileContent->content());
172
+ }
173
+
174
+ /**
175
+ * @test
176
+ */
177
+ public function writeAppendsContentWhenOffsetAtEof()
178
+ {
179
+ $this->assertTrue($this->stringBasedFileContent->seek(0, SEEK_END));
180
+ $this->assertEquals(3, $this->stringBasedFileContent->write('bar'));
181
+ $this->assertEquals('foobarbazbar', $this->stringBasedFileContent->content());
182
+ }
183
+
184
+ /**
185
+ * @test
186
+ * @group issue_33
187
+ * @since 1.1.0
188
+ */
189
+ public function truncateRemovesSuperflouosContent()
190
+ {
191
+ $this->assertTrue($this->stringBasedFileContent->truncate(6));
192
+ $this->assertEquals('foobar', $this->stringBasedFileContent->content());
193
+ }
194
+
195
+ /**
196
+ * @test
197
+ * @group issue_33
198
+ * @since 1.1.0
199
+ */
200
+ public function truncateDecreasesSize()
201
+ {
202
+ $this->assertTrue($this->stringBasedFileContent->truncate(6));
203
+ $this->assertEquals(6, $this->stringBasedFileContent->size());
204
+ }
205
+
206
+ /**
207
+ * @test
208
+ * @group issue_33
209
+ * @since 1.1.0
210
+ */
211
+ public function truncateToGreaterSizeAddsZeroBytes()
212
+ {
213
+ $this->assertTrue($this->stringBasedFileContent->truncate(25));
214
+ $this->assertEquals(
215
+ "foobarbaz\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
216
+ $this->stringBasedFileContent->content()
217
+ );
218
+ }
219
+
220
+ /**
221
+ * @test
222
+ * @group issue_33
223
+ * @since 1.1.0
224
+ */
225
+ public function truncateToGreaterSizeIncreasesSize()
226
+ {
227
+ $this->assertTrue($this->stringBasedFileContent->truncate(25));
228
+ $this->assertEquals(25, $this->stringBasedFileContent->size());
229
+ }
230
+ }
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/proxy/vfsStreamWrapperRecordingProxy.php ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Stream wrapper to mock file system requests.
13
+ *
14
+ * @since 0.10.0
15
+ */
16
+ class vfsStreamWrapperRecordingProxy extends vfsStreamWrapper
17
+ {
18
+ /**
19
+ * list of called methods for a stream
20
+ *
21
+ * @var array
22
+ */
23
+ protected static $calledMethods = array();
24
+ /**
25
+ * currently opened path
26
+ *
27
+ * @var string
28
+ */
29
+ protected $path;
30
+
31
+ /**
32
+ * records method call for given path
33
+ *
34
+ * @param string $method
35
+ * @param string $path
36
+ */
37
+ protected static function recordMethodCall($method, $path)
38
+ {
39
+ if (isset(self::$calledMethods[$path]) === false) {
40
+ self::$calledMethods[$path] = array();
41
+ }
42
+
43
+ self::$calledMethods[$path][] = $method;
44
+ }
45
+
46
+ /**
47
+ * returns recorded method calls for given path
48
+ *
49
+ * @param string $path
50
+ * @return array<string>
51
+ */
52
+ public static function getMethodCalls($path)
53
+ {
54
+ if (isset(self::$calledMethods[$path]) === true) {
55
+ return self::$calledMethods[$path];
56
+ }
57
+
58
+ return array();
59
+ }
60
+
61
+ /**
62
+ * helper method for setting up vfsStream with the proxy
63
+ *
64
+ * @param string $rootDirName optional name of root directory
65
+ * @param int $permissions optional file permissions of root directory
66
+ * @return vfsStreamDirectory
67
+ * @throws vfsStreamException
68
+ */
69
+ public static function setup($rootDirName = 'root', $permissions = null)
70
+ {
71
+ self::$root = vfsStream::newDirectory($rootDirName, $permissions);
72
+ if (true === self::$registered) {
73
+ return self::$root;
74
+ }
75
+
76
+ if (@stream_wrapper_register(vfsStream::SCHEME, __CLASS__) === false) {
77
+ throw new vfsStreamException('A handler has already been registered for the ' . vfsStream::SCHEME . ' protocol.');
78
+ }
79
+
80
+ self::$registered = true;
81
+ return self::$root;
82
+ }
83
+
84
+ /**
85
+ * open the stream
86
+ *
87
+ * @param string $path the path to open
88
+ * @param string $mode mode for opening
89
+ * @param string $options options for opening
90
+ * @param string $opened_path full path that was actually opened
91
+ * @return bool
92
+ */
93
+ public function stream_open($path, $mode, $options, $opened_path)
94
+ {
95
+ $this->path = $path;
96
+ self::recordMethodCall('stream_open', $this->path);
97
+ return parent::stream_open($path, $mode, $options, $opened_path);
98
+ }
99
+
100
+ /**
101
+ * closes the stream
102
+ */
103
+ public function stream_close()
104
+ {
105
+ self::recordMethodCall('stream_close', $this->path);
106
+ return parent::stream_close();
107
+ }
108
+
109
+ /**
110
+ * read the stream up to $count bytes
111
+ *
112
+ * @param int $count amount of bytes to read
113
+ * @return string
114
+ */
115
+ public function stream_read($count)
116
+ {
117
+ self::recordMethodCall('stream_read', $this->path);
118
+ return parent::stream_read($count);
119
+ }
120
+
121
+ /**
122
+ * writes data into the stream
123
+ *
124
+ * @param string $data
125
+ * @return int amount of bytes written
126
+ */
127
+ public function stream_write($data)
128
+ {
129
+ self::recordMethodCall('stream_write', $this->path);
130
+ return parent::stream_write($data);
131
+ }
132
+
133
+ /**
134
+ * checks whether stream is at end of file
135
+ *
136
+ * @return bool
137
+ */
138
+ public function stream_eof()
139
+ {
140
+ self::recordMethodCall('stream_eof', $this->path);
141
+ return parent::stream_eof();
142
+ }
143
+
144
+ /**
145
+ * returns the current position of the stream
146
+ *
147
+ * @return int
148
+ */
149
+ public function stream_tell()
150
+ {
151
+ self::recordMethodCall('stream_tell', $this->path);
152
+ return parent::stream_tell();
153
+ }
154
+
155
+ /**
156
+ * seeks to the given offset
157
+ *
158
+ * @param int $offset
159
+ * @param int $whence
160
+ * @return bool
161
+ */
162
+ public function stream_seek($offset, $whence)
163
+ {
164
+ self::recordMethodCall('stream_seek', $this->path);
165
+ return parent::stream_seek($offset, $whence);
166
+ }
167
+
168
+ /**
169
+ * flushes unstored data into storage
170
+ *
171
+ * @return bool
172
+ */
173
+ public function stream_flush()
174
+ {
175
+ self::recordMethodCall('stream_flush', $this->path);
176
+ return parent::stream_flush();
177
+ }
178
+
179
+ /**
180
+ * returns status of stream
181
+ *
182
+ * @return array
183
+ */
184
+ public function stream_stat()
185
+ {
186
+ self::recordMethodCall('stream_stat', $this->path);
187
+ return parent::stream_stat();
188
+ }
189
+
190
+ /**
191
+ * retrieve the underlaying resource
192
+ *
193
+ * @param int $cast_as
194
+ * @return bool
195
+ */
196
+ public function stream_cast($cast_as)
197
+ {
198
+ self::recordMethodCall('stream_cast', $this->path);
199
+ return parent::stream_cast($cast_as);
200
+ }
201
+
202
+ /**
203
+ * set lock status for stream
204
+ *
205
+ * @param int $operation
206
+ * @return bool
207
+ */
208
+ public function stream_lock($operation)
209
+ {
210
+ self::recordMethodCall('stream_link', $this->path);
211
+ return parent::stream_lock($operation);
212
+ }
213
+
214
+ /**
215
+ * remove the data under the given path
216
+ *
217
+ * @param string $path
218
+ * @return bool
219
+ */
220
+ public function unlink($path)
221
+ {
222
+ self::recordMethodCall('unlink', $path);
223
+ return parent::unlink($path);
224
+ }
225
+
226
+ /**
227
+ * rename from one path to another
228
+ *
229
+ * @param string $path_from
230
+ * @param string $path_to
231
+ * @return bool
232
+ */
233
+ public function rename($path_from, $path_to)
234
+ {
235
+ self::recordMethodCall('rename', $path_from);
236
+ return parent::rename($path_from, $path_to);
237
+ }
238
+
239
+ /**
240
+ * creates a new directory
241
+ *
242
+ * @param string $path
243
+ * @param int $mode
244
+ * @param int $options
245
+ * @return bool
246
+ */
247
+ public function mkdir($path, $mode, $options)
248
+ {
249
+ self::recordMethodCall('mkdir', $path);
250
+ return parent::mkdir($path, $mode, $options);
251
+ }
252
+
253
+ /**
254
+ * removes a directory
255
+ *
256
+ * @param string $path
257
+ * @param int $options
258
+ * @return bool
259
+ */
260
+ public function rmdir($path, $options)
261
+ {
262
+ self::recordMethodCall('rmdir', $path);
263
+ return parent::rmdir($path, $options);
264
+ }
265
+
266
+ /**
267
+ * opens a directory
268
+ *
269
+ * @param string $path
270
+ * @param int $options
271
+ * @return bool
272
+ */
273
+ public function dir_opendir($path, $options)
274
+ {
275
+ $this->path = $path;
276
+ self::recordMethodCall('dir_opendir', $this->path);
277
+ return parent::dir_opendir($path, $options);
278
+ }
279
+
280
+ /**
281
+ * reads directory contents
282
+ *
283
+ * @return string
284
+ */
285
+ public function dir_readdir()
286
+ {
287
+ self::recordMethodCall('dir_readdir', $this->path);
288
+ return parent::dir_readdir();
289
+ }
290
+
291
+ /**
292
+ * reset directory iteration
293
+ *
294
+ * @return bool
295
+ */
296
+ public function dir_rewinddir()
297
+ {
298
+ self::recordMethodCall('dir_rewinddir', $this->path);
299
+ return parent::dir_rewinddir();
300
+ }
301
+
302
+ /**
303
+ * closes directory
304
+ *
305
+ * @return bool
306
+ */
307
+ public function dir_closedir()
308
+ {
309
+ self::recordMethodCall('dir_closedir', $this->path);
310
+ return parent::dir_closedir();
311
+ }
312
+
313
+ /**
314
+ * returns status of url
315
+ *
316
+ * @param string $path path of url to return status for
317
+ * @param int $flags flags set by the stream API
318
+ * @return array
319
+ */
320
+ public function url_stat($path, $flags)
321
+ {
322
+ self::recordMethodCall('url_stat', $path);
323
+ return parent::url_stat($path, $flags);
324
+ }
325
+ }
326
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamAbstractContentTestCase.php ADDED
@@ -0,0 +1,1054 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Helper class for the test.
13
+ */
14
+ class TestvfsStreamAbstractContent extends vfsStreamAbstractContent
15
+ {
16
+ /**
17
+ * returns default permissions for concrete implementation
18
+ *
19
+ * @return int
20
+ * @since 0.8.0
21
+ */
22
+ protected function getDefaultPermissions()
23
+ {
24
+ return 0777;
25
+ }
26
+
27
+ /**
28
+ * returns size of content
29
+ *
30
+ * @return int
31
+ */
32
+ public function size()
33
+ {
34
+ return 0;
35
+ }
36
+ }
37
+ /**
38
+ * Test for org\bovigo\vfs\vfsStreamAbstractContent.
39
+ */
40
+ class vfsStreamAbstractContentTestCase extends \PHPUnit_Framework_TestCase
41
+ {
42
+ /**
43
+ * @test
44
+ * @group permissions
45
+ * @group bug_15
46
+ */
47
+ public function noPermissionsForEveryone()
48
+ {
49
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0000);
50
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
51
+ vfsStream::getCurrentGroup()
52
+ )
53
+ );
54
+ $this->assertFalse($abstractContent->isReadable(-1,
55
+ vfsStream::getCurrentGroup()
56
+ )
57
+ );
58
+ $this->assertFalse($abstractContent->isReadable(-1,
59
+ -1
60
+ )
61
+ );
62
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
63
+ vfsStream::getCurrentGroup()
64
+ )
65
+ );
66
+ $this->assertFalse($abstractContent->isWritable(-1,
67
+ vfsStream::getCurrentGroup()
68
+ )
69
+ );
70
+ $this->assertFalse($abstractContent->isWritable(-1,
71
+ -1
72
+ )
73
+ );
74
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
75
+ vfsStream::getCurrentGroup()
76
+ )
77
+ );
78
+ $this->assertFalse($abstractContent->isExecutable(-1,
79
+ vfsStream::getCurrentGroup()
80
+ )
81
+ );
82
+ $this->assertFalse($abstractContent->isExecutable(-1,
83
+ -1
84
+ )
85
+ );
86
+ }
87
+
88
+ /**
89
+ * @test
90
+ * @group permissions
91
+ * @group bug_15
92
+ */
93
+ public function executePermissionsForUser()
94
+ {
95
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0100);
96
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
97
+ vfsStream::getCurrentGroup()
98
+ )
99
+ );
100
+ $this->assertFalse($abstractContent->isReadable(-1,
101
+ vfsStream::getCurrentGroup()
102
+ )
103
+ );
104
+ $this->assertFalse($abstractContent->isReadable(-1,
105
+ -1
106
+ )
107
+ );
108
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
109
+ vfsStream::getCurrentGroup()
110
+ )
111
+ );
112
+ $this->assertFalse($abstractContent->isWritable(-1,
113
+ vfsStream::getCurrentGroup()
114
+ )
115
+ );
116
+ $this->assertFalse($abstractContent->isWritable(-1,
117
+ -1
118
+ )
119
+ );
120
+ $this->assertTrue($abstractContent->isExecutable(vfsStream::getCurrentUser(),
121
+ vfsStream::getCurrentGroup()
122
+ )
123
+ );
124
+ $this->assertFalse($abstractContent->isExecutable(-1,
125
+ vfsStream::getCurrentGroup()
126
+ )
127
+ );
128
+ $this->assertFalse($abstractContent->isExecutable(-1,
129
+ -1
130
+ )
131
+ );
132
+ }
133
+
134
+ /**
135
+ * @test
136
+ * @group permissions
137
+ * @group bug_15
138
+ */
139
+ public function executePermissionsForGroup()
140
+ {
141
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0010);
142
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
143
+ vfsStream::getCurrentGroup()
144
+ )
145
+ );
146
+ $this->assertFalse($abstractContent->isReadable(-1,
147
+ vfsStream::getCurrentGroup()
148
+ )
149
+ );
150
+ $this->assertFalse($abstractContent->isReadable(-1,
151
+ -1
152
+ )
153
+ );
154
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
155
+ vfsStream::getCurrentGroup()
156
+ )
157
+ );
158
+ $this->assertFalse($abstractContent->isWritable(-1,
159
+ vfsStream::getCurrentGroup()
160
+ )
161
+ );
162
+ $this->assertFalse($abstractContent->isWritable(-1,
163
+ -1
164
+ )
165
+ );
166
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
167
+ vfsStream::getCurrentGroup()
168
+ )
169
+ );
170
+ $this->assertTrue($abstractContent->isExecutable(-1,
171
+ vfsStream::getCurrentGroup()
172
+ )
173
+ );
174
+ $this->assertFalse($abstractContent->isExecutable(-1,
175
+ -1
176
+ )
177
+ );
178
+ }
179
+
180
+ /**
181
+ * @test
182
+ * @group permissions
183
+ * @group bug_15
184
+ */
185
+ public function executePermissionsForOther()
186
+ {
187
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0001);
188
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
189
+ vfsStream::getCurrentGroup()
190
+ )
191
+ );
192
+ $this->assertFalse($abstractContent->isReadable(-1,
193
+ vfsStream::getCurrentGroup()
194
+ )
195
+ );
196
+ $this->assertFalse($abstractContent->isReadable(-1,
197
+ -1
198
+ )
199
+ );
200
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
201
+ vfsStream::getCurrentGroup()
202
+ )
203
+ );
204
+ $this->assertFalse($abstractContent->isWritable(-1,
205
+ vfsStream::getCurrentGroup()
206
+ )
207
+ );
208
+ $this->assertFalse($abstractContent->isWritable(-1,
209
+ -1
210
+ )
211
+ );
212
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
213
+ vfsStream::getCurrentGroup()
214
+ )
215
+ );
216
+ $this->assertFalse($abstractContent->isExecutable(-1,
217
+ vfsStream::getCurrentGroup()
218
+ )
219
+ );
220
+ $this->assertTrue($abstractContent->isExecutable(-1,
221
+ -1
222
+ )
223
+ );
224
+ }
225
+
226
+ /**
227
+ * @test
228
+ * @group permissions
229
+ * @group bug_15
230
+ */
231
+ public function writePermissionsForUser()
232
+ {
233
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0200);
234
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
235
+ vfsStream::getCurrentGroup()
236
+ )
237
+ );
238
+ $this->assertFalse($abstractContent->isReadable(-1,
239
+ vfsStream::getCurrentGroup()
240
+ )
241
+ );
242
+ $this->assertFalse($abstractContent->isReadable(-1,
243
+ -1
244
+ )
245
+ );
246
+ $this->assertTrue($abstractContent->isWritable(vfsStream::getCurrentUser(),
247
+ vfsStream::getCurrentGroup()
248
+ )
249
+ );
250
+ $this->assertFalse($abstractContent->isWritable(-1,
251
+ vfsStream::getCurrentGroup()
252
+ )
253
+ );
254
+ $this->assertFalse($abstractContent->isWritable(-1,
255
+ -1
256
+ )
257
+ );
258
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
259
+ vfsStream::getCurrentGroup()
260
+ )
261
+ );
262
+ $this->assertFalse($abstractContent->isExecutable(-1,
263
+ vfsStream::getCurrentGroup()
264
+ )
265
+ );
266
+ $this->assertFalse($abstractContent->isExecutable(-1,
267
+ -1
268
+ )
269
+ );
270
+ }
271
+
272
+ /**
273
+ * @test
274
+ * @group permissions
275
+ * @group bug_15
276
+ */
277
+ public function writePermissionsForGroup()
278
+ {
279
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0020);
280
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
281
+ vfsStream::getCurrentGroup()
282
+ )
283
+ );
284
+ $this->assertFalse($abstractContent->isReadable(-1,
285
+ vfsStream::getCurrentGroup()
286
+ )
287
+ );
288
+ $this->assertFalse($abstractContent->isReadable(-1,
289
+ -1
290
+ )
291
+ );
292
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
293
+ vfsStream::getCurrentGroup()
294
+ )
295
+ );
296
+ $this->assertTrue($abstractContent->isWritable(-1,
297
+ vfsStream::getCurrentGroup()
298
+ )
299
+ );
300
+ $this->assertFalse($abstractContent->isWritable(-1,
301
+ -1
302
+ )
303
+ );
304
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
305
+ vfsStream::getCurrentGroup()
306
+ )
307
+ );
308
+ $this->assertFalse($abstractContent->isExecutable(-1,
309
+ vfsStream::getCurrentGroup()
310
+ )
311
+ );
312
+ $this->assertFalse($abstractContent->isExecutable(-1,
313
+ -1
314
+ )
315
+ );
316
+ }
317
+
318
+ /**
319
+ * @test
320
+ * @group permissions
321
+ * @group bug_15
322
+ */
323
+ public function writePermissionsForOther()
324
+ {
325
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0002);
326
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
327
+ vfsStream::getCurrentGroup()
328
+ )
329
+ );
330
+ $this->assertFalse($abstractContent->isReadable(-1,
331
+ vfsStream::getCurrentGroup()
332
+ )
333
+ );
334
+ $this->assertFalse($abstractContent->isReadable(-1,
335
+ -1
336
+ )
337
+ );
338
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
339
+ vfsStream::getCurrentGroup()
340
+ )
341
+ );
342
+ $this->assertFalse($abstractContent->isWritable(-1,
343
+ vfsStream::getCurrentGroup()
344
+ )
345
+ );
346
+ $this->assertTrue($abstractContent->isWritable(-1,
347
+ -1
348
+ )
349
+ );
350
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
351
+ vfsStream::getCurrentGroup()
352
+ )
353
+ );
354
+ $this->assertFalse($abstractContent->isExecutable(-1,
355
+ vfsStream::getCurrentGroup()
356
+ )
357
+ );
358
+ $this->assertFalse($abstractContent->isExecutable(-1,
359
+ -1
360
+ )
361
+ );
362
+ }
363
+
364
+ /**
365
+ * @test
366
+ * @group permissions
367
+ * @group bug_15
368
+ */
369
+ public function executeAndWritePermissionsForUser()
370
+ {
371
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0300);
372
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
373
+ vfsStream::getCurrentGroup()
374
+ )
375
+ );
376
+ $this->assertFalse($abstractContent->isReadable(-1,
377
+ vfsStream::getCurrentGroup()
378
+ )
379
+ );
380
+ $this->assertFalse($abstractContent->isReadable(-1,
381
+ -1
382
+ )
383
+ );
384
+ $this->assertTrue($abstractContent->isWritable(vfsStream::getCurrentUser(),
385
+ vfsStream::getCurrentGroup()
386
+ )
387
+ );
388
+ $this->assertFalse($abstractContent->isWritable(-1,
389
+ vfsStream::getCurrentGroup()
390
+ )
391
+ );
392
+ $this->assertFalse($abstractContent->isWritable(-1,
393
+ -1
394
+ )
395
+ );
396
+ $this->assertTrue($abstractContent->isExecutable(vfsStream::getCurrentUser(),
397
+ vfsStream::getCurrentGroup()
398
+ )
399
+ );
400
+ $this->assertFalse($abstractContent->isExecutable(-1,
401
+ vfsStream::getCurrentGroup()
402
+ )
403
+ );
404
+ $this->assertFalse($abstractContent->isExecutable(-1,
405
+ -1
406
+ )
407
+ );
408
+ }
409
+
410
+ /**
411
+ * @test
412
+ * @group permissions
413
+ * @group bug_15
414
+ */
415
+ public function executeAndWritePermissionsForGroup()
416
+ {
417
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0030);
418
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
419
+ vfsStream::getCurrentGroup()
420
+ )
421
+ );
422
+ $this->assertFalse($abstractContent->isReadable(-1,
423
+ vfsStream::getCurrentGroup()
424
+ )
425
+ );
426
+ $this->assertFalse($abstractContent->isReadable(-1,
427
+ -1
428
+ )
429
+ );
430
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
431
+ vfsStream::getCurrentGroup()
432
+ )
433
+ );
434
+ $this->assertTrue($abstractContent->isWritable(-1,
435
+ vfsStream::getCurrentGroup()
436
+ )
437
+ );
438
+ $this->assertFalse($abstractContent->isWritable(-1,
439
+ -1
440
+ )
441
+ );
442
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
443
+ vfsStream::getCurrentGroup()
444
+ )
445
+ );
446
+ $this->assertTrue($abstractContent->isExecutable(-1,
447
+ vfsStream::getCurrentGroup()
448
+ )
449
+ );
450
+ $this->assertFalse($abstractContent->isExecutable(-1,
451
+ -1
452
+ )
453
+ );
454
+ }
455
+
456
+ /**
457
+ * @test
458
+ * @group permissions
459
+ * @group bug_15
460
+ */
461
+ public function executeAndWritePermissionsForOther()
462
+ {
463
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0003);
464
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
465
+ vfsStream::getCurrentGroup()
466
+ )
467
+ );
468
+ $this->assertFalse($abstractContent->isReadable(-1,
469
+ vfsStream::getCurrentGroup()
470
+ )
471
+ );
472
+ $this->assertFalse($abstractContent->isReadable(-1,
473
+ -1
474
+ )
475
+ );
476
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
477
+ vfsStream::getCurrentGroup()
478
+ )
479
+ );
480
+ $this->assertFalse($abstractContent->isWritable(-1,
481
+ vfsStream::getCurrentGroup()
482
+ )
483
+ );
484
+ $this->assertTrue($abstractContent->isWritable(-1,
485
+ -1
486
+ )
487
+ );
488
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
489
+ vfsStream::getCurrentGroup()
490
+ )
491
+ );
492
+ $this->assertFalse($abstractContent->isExecutable(-1,
493
+ vfsStream::getCurrentGroup()
494
+ )
495
+ );
496
+ $this->assertTrue($abstractContent->isExecutable(-1,
497
+ -1
498
+ )
499
+ );
500
+ }
501
+
502
+ /**
503
+ * @test
504
+ * @group permissions
505
+ * @group bug_15
506
+ */
507
+ public function readPermissionsForUser()
508
+ {
509
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0400);
510
+ $this->assertTrue($abstractContent->isReadable(vfsStream::getCurrentUser(),
511
+ vfsStream::getCurrentGroup()
512
+ )
513
+ );
514
+ $this->assertFalse($abstractContent->isReadable(-1,
515
+ vfsStream::getCurrentGroup()
516
+ )
517
+ );
518
+ $this->assertFalse($abstractContent->isReadable(-1,
519
+ -1
520
+ )
521
+ );
522
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
523
+ vfsStream::getCurrentGroup()
524
+ )
525
+ );
526
+ $this->assertFalse($abstractContent->isWritable(-1,
527
+ vfsStream::getCurrentGroup()
528
+ )
529
+ );
530
+ $this->assertFalse($abstractContent->isWritable(-1,
531
+ -1
532
+ )
533
+ );
534
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
535
+ vfsStream::getCurrentGroup()
536
+ )
537
+ );
538
+ $this->assertFalse($abstractContent->isExecutable(-1,
539
+ vfsStream::getCurrentGroup()
540
+ )
541
+ );
542
+ $this->assertFalse($abstractContent->isExecutable(-1,
543
+ -1
544
+ )
545
+ );
546
+ }
547
+
548
+ /**
549
+ * @test
550
+ * @group permissions
551
+ * @group bug_15
552
+ */
553
+ public function readPermissionsForGroup()
554
+ {
555
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0040);
556
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
557
+ vfsStream::getCurrentGroup()
558
+ )
559
+ );
560
+ $this->assertTrue($abstractContent->isReadable(-1,
561
+ vfsStream::getCurrentGroup()
562
+ )
563
+ );
564
+ $this->assertFalse($abstractContent->isReadable(-1,
565
+ -1
566
+ )
567
+ );
568
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
569
+ vfsStream::getCurrentGroup()
570
+ )
571
+ );
572
+ $this->assertFalse($abstractContent->isWritable(-1,
573
+ vfsStream::getCurrentGroup()
574
+ )
575
+ );
576
+ $this->assertFalse($abstractContent->isWritable(-1,
577
+ -1
578
+ )
579
+ );
580
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
581
+ vfsStream::getCurrentGroup()
582
+ )
583
+ );
584
+ $this->assertFalse($abstractContent->isExecutable(-1,
585
+ vfsStream::getCurrentGroup()
586
+ )
587
+ );
588
+ $this->assertFalse($abstractContent->isExecutable(-1,
589
+ -1
590
+ )
591
+ );
592
+ }
593
+
594
+ /**
595
+ * @test
596
+ * @group permissions
597
+ * @group bug_15
598
+ */
599
+ public function readPermissionsForOther()
600
+ {
601
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0004);
602
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
603
+ vfsStream::getCurrentGroup()
604
+ )
605
+ );
606
+ $this->assertFalse($abstractContent->isReadable(-1,
607
+ vfsStream::getCurrentGroup()
608
+ )
609
+ );
610
+ $this->assertTrue($abstractContent->isReadable(-1,
611
+ -1
612
+ )
613
+ );
614
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
615
+ vfsStream::getCurrentGroup()
616
+ )
617
+ );
618
+ $this->assertFalse($abstractContent->isWritable(-1,
619
+ vfsStream::getCurrentGroup()
620
+ )
621
+ );
622
+ $this->assertFalse($abstractContent->isWritable(-1,
623
+ -1
624
+ )
625
+ );
626
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
627
+ vfsStream::getCurrentGroup()
628
+ )
629
+ );
630
+ $this->assertFalse($abstractContent->isExecutable(-1,
631
+ vfsStream::getCurrentGroup()
632
+ )
633
+ );
634
+ $this->assertFalse($abstractContent->isExecutable(-1,
635
+ -1
636
+ )
637
+ );
638
+ }
639
+
640
+ /**
641
+ * @test
642
+ * @group permissions
643
+ * @group bug_15
644
+ */
645
+ public function readAndExecutePermissionsForUser()
646
+ {
647
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0500);
648
+ $this->assertTrue($abstractContent->isReadable(vfsStream::getCurrentUser(),
649
+ vfsStream::getCurrentGroup()
650
+ )
651
+ );
652
+ $this->assertFalse($abstractContent->isReadable(-1,
653
+ vfsStream::getCurrentGroup()
654
+ )
655
+ );
656
+ $this->assertFalse($abstractContent->isReadable(-1,
657
+ -1
658
+ )
659
+ );
660
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
661
+ vfsStream::getCurrentGroup()
662
+ )
663
+ );
664
+ $this->assertFalse($abstractContent->isWritable(-1,
665
+ vfsStream::getCurrentGroup()
666
+ )
667
+ );
668
+ $this->assertFalse($abstractContent->isWritable(-1,
669
+ -1
670
+ )
671
+ );
672
+ $this->assertTrue($abstractContent->isExecutable(vfsStream::getCurrentUser(),
673
+ vfsStream::getCurrentGroup()
674
+ )
675
+ );
676
+ $this->assertFalse($abstractContent->isExecutable(-1,
677
+ vfsStream::getCurrentGroup()
678
+ )
679
+ );
680
+ $this->assertFalse($abstractContent->isExecutable(-1,
681
+ -1
682
+ )
683
+ );
684
+ }
685
+
686
+ /**
687
+ * @test
688
+ * @group permissions
689
+ * @group bug_15
690
+ */
691
+ public function readAndExecutePermissionsForGroup()
692
+ {
693
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0050);
694
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
695
+ vfsStream::getCurrentGroup()
696
+ )
697
+ );
698
+ $this->assertTrue($abstractContent->isReadable(-1,
699
+ vfsStream::getCurrentGroup()
700
+ )
701
+ );
702
+ $this->assertFalse($abstractContent->isReadable(-1,
703
+ -1
704
+ )
705
+ );
706
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
707
+ vfsStream::getCurrentGroup()
708
+ )
709
+ );
710
+ $this->assertFalse($abstractContent->isWritable(-1,
711
+ vfsStream::getCurrentGroup()
712
+ )
713
+ );
714
+ $this->assertFalse($abstractContent->isWritable(-1,
715
+ -1
716
+ )
717
+ );
718
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
719
+ vfsStream::getCurrentGroup()
720
+ )
721
+ );
722
+ $this->assertTrue($abstractContent->isExecutable(-1,
723
+ vfsStream::getCurrentGroup()
724
+ )
725
+ );
726
+ $this->assertFalse($abstractContent->isExecutable(-1,
727
+ -1
728
+ )
729
+ );
730
+ }
731
+
732
+ /**
733
+ * @test
734
+ * @group permissions
735
+ * @group bug_15
736
+ */
737
+ public function readAndExecutePermissionsForOther()
738
+ {
739
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0005);
740
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
741
+ vfsStream::getCurrentGroup()
742
+ )
743
+ );
744
+ $this->assertFalse($abstractContent->isReadable(-1,
745
+ vfsStream::getCurrentGroup()
746
+ )
747
+ );
748
+ $this->assertTrue($abstractContent->isReadable(-1,
749
+ -1
750
+ )
751
+ );
752
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
753
+ vfsStream::getCurrentGroup()
754
+ )
755
+ );
756
+ $this->assertFalse($abstractContent->isWritable(-1,
757
+ vfsStream::getCurrentGroup()
758
+ )
759
+ );
760
+ $this->assertFalse($abstractContent->isWritable(-1,
761
+ -1
762
+ )
763
+ );
764
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
765
+ vfsStream::getCurrentGroup()
766
+ )
767
+ );
768
+ $this->assertFalse($abstractContent->isExecutable(-1,
769
+ vfsStream::getCurrentGroup()
770
+ )
771
+ );
772
+ $this->assertTrue($abstractContent->isExecutable(-1,
773
+ -1
774
+ )
775
+ );
776
+ }
777
+
778
+ /**
779
+ * @test
780
+ * @group permissions
781
+ * @group bug_15
782
+ */
783
+ public function readAndWritePermissionsForUser()
784
+ {
785
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0600);
786
+ $this->assertTrue($abstractContent->isReadable(vfsStream::getCurrentUser(),
787
+ vfsStream::getCurrentGroup()
788
+ )
789
+ );
790
+ $this->assertFalse($abstractContent->isReadable(-1,
791
+ vfsStream::getCurrentGroup()
792
+ )
793
+ );
794
+ $this->assertFalse($abstractContent->isReadable(-1,
795
+ -1
796
+ )
797
+ );
798
+ $this->assertTrue($abstractContent->isWritable(vfsStream::getCurrentUser(),
799
+ vfsStream::getCurrentGroup()
800
+ )
801
+ );
802
+ $this->assertFalse($abstractContent->isWritable(-1,
803
+ vfsStream::getCurrentGroup()
804
+ )
805
+ );
806
+ $this->assertFalse($abstractContent->isWritable(-1,
807
+ -1
808
+ )
809
+ );
810
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
811
+ vfsStream::getCurrentGroup()
812
+ )
813
+ );
814
+ $this->assertFalse($abstractContent->isExecutable(-1,
815
+ vfsStream::getCurrentGroup()
816
+ )
817
+ );
818
+ $this->assertFalse($abstractContent->isExecutable(-1,
819
+ -1
820
+ )
821
+ );
822
+ }
823
+
824
+ /**
825
+ * @test
826
+ * @group permissions
827
+ * @group bug_15
828
+ */
829
+ public function readAndWritePermissionsForGroup()
830
+ {
831
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0060);
832
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
833
+ vfsStream::getCurrentGroup()
834
+ )
835
+ );
836
+ $this->assertTrue($abstractContent->isReadable(-1,
837
+ vfsStream::getCurrentGroup()
838
+ )
839
+ );
840
+ $this->assertFalse($abstractContent->isReadable(-1,
841
+ -1
842
+ )
843
+ );
844
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
845
+ vfsStream::getCurrentGroup()
846
+ )
847
+ );
848
+ $this->assertTrue($abstractContent->isWritable(-1,
849
+ vfsStream::getCurrentGroup()
850
+ )
851
+ );
852
+ $this->assertFalse($abstractContent->isWritable(-1,
853
+ -1
854
+ )
855
+ );
856
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
857
+ vfsStream::getCurrentGroup()
858
+ )
859
+ );
860
+ $this->assertFalse($abstractContent->isExecutable(-1,
861
+ vfsStream::getCurrentGroup()
862
+ )
863
+ );
864
+ $this->assertFalse($abstractContent->isExecutable(-1,
865
+ -1
866
+ )
867
+ );
868
+ }
869
+
870
+ /**
871
+ * @test
872
+ * @group permissions
873
+ * @group bug_15
874
+ */
875
+ public function readAndWritePermissionsForOther()
876
+ {
877
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0006);
878
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
879
+ vfsStream::getCurrentGroup()
880
+ )
881
+ );
882
+ $this->assertFalse($abstractContent->isReadable(-1,
883
+ vfsStream::getCurrentGroup()
884
+ )
885
+ );
886
+ $this->assertTrue($abstractContent->isReadable(-1,
887
+ -1
888
+ )
889
+ );
890
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
891
+ vfsStream::getCurrentGroup()
892
+ )
893
+ );
894
+ $this->assertFalse($abstractContent->isWritable(-1,
895
+ vfsStream::getCurrentGroup()
896
+ )
897
+ );
898
+ $this->assertTrue($abstractContent->isWritable(-1,
899
+ -1
900
+ )
901
+ );
902
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
903
+ vfsStream::getCurrentGroup()
904
+ )
905
+ );
906
+ $this->assertFalse($abstractContent->isExecutable(-1,
907
+ vfsStream::getCurrentGroup()
908
+ )
909
+ );
910
+ $this->assertFalse($abstractContent->isExecutable(-1,
911
+ -1
912
+ )
913
+ );
914
+ }
915
+
916
+ /**
917
+ * @test
918
+ * @group permissions
919
+ * @group bug_15
920
+ */
921
+ public function allPermissionsForUser()
922
+ {
923
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0700);
924
+ $this->assertTrue($abstractContent->isReadable(vfsStream::getCurrentUser(),
925
+ vfsStream::getCurrentGroup()
926
+ )
927
+ );
928
+ $this->assertFalse($abstractContent->isReadable(-1,
929
+ vfsStream::getCurrentGroup()
930
+ )
931
+ );
932
+ $this->assertFalse($abstractContent->isReadable(-1,
933
+ -1
934
+ )
935
+ );
936
+ $this->assertTrue($abstractContent->isWritable(vfsStream::getCurrentUser(),
937
+ vfsStream::getCurrentGroup()
938
+ )
939
+ );
940
+ $this->assertFalse($abstractContent->isWritable(-1,
941
+ vfsStream::getCurrentGroup()
942
+ )
943
+ );
944
+ $this->assertFalse($abstractContent->isWritable(-1,
945
+ -1
946
+ )
947
+ );
948
+ $this->assertTrue($abstractContent->isExecutable(vfsStream::getCurrentUser(),
949
+ vfsStream::getCurrentGroup()
950
+ )
951
+ );
952
+ $this->assertFalse($abstractContent->isExecutable(-1,
953
+ vfsStream::getCurrentGroup()
954
+ )
955
+ );
956
+ $this->assertFalse($abstractContent->isExecutable(-1,
957
+ -1
958
+ )
959
+ );
960
+ }
961
+
962
+ /**
963
+ * @test
964
+ * @group permissions
965
+ * @group bug_15
966
+ */
967
+ public function allPermissionsForGroup()
968
+ {
969
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0070);
970
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
971
+ vfsStream::getCurrentGroup()
972
+ )
973
+ );
974
+ $this->assertTrue($abstractContent->isReadable(-1,
975
+ vfsStream::getCurrentGroup()
976
+ )
977
+ );
978
+ $this->assertFalse($abstractContent->isReadable(-1,
979
+ -1
980
+ )
981
+ );
982
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
983
+ vfsStream::getCurrentGroup()
984
+ )
985
+ );
986
+ $this->assertTrue($abstractContent->isWritable(-1,
987
+ vfsStream::getCurrentGroup()
988
+ )
989
+ );
990
+ $this->assertFalse($abstractContent->isWritable(-1,
991
+ -1
992
+ )
993
+ );
994
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
995
+ vfsStream::getCurrentGroup()
996
+ )
997
+ );
998
+ $this->assertTrue($abstractContent->isExecutable(-1,
999
+ vfsStream::getCurrentGroup()
1000
+ )
1001
+ );
1002
+ $this->assertFalse($abstractContent->isExecutable(-1,
1003
+ -1
1004
+ )
1005
+ );
1006
+ }
1007
+
1008
+ /**
1009
+ * @test
1010
+ * @group permissions
1011
+ * @group bug_15
1012
+ */
1013
+ public function allPermissionsForOther()
1014
+ {
1015
+ $abstractContent = new TestvfsStreamAbstractContent('foo', 0007);
1016
+ $this->assertFalse($abstractContent->isReadable(vfsStream::getCurrentUser(),
1017
+ vfsStream::getCurrentGroup()
1018
+ )
1019
+ );
1020
+ $this->assertFalse($abstractContent->isReadable(-1,
1021
+ vfsStream::getCurrentGroup()
1022
+ )
1023
+ );
1024
+ $this->assertTrue($abstractContent->isReadable(-1,
1025
+ -1
1026
+ )
1027
+ );
1028
+ $this->assertFalse($abstractContent->isWritable(vfsStream::getCurrentUser(),
1029
+ vfsStream::getCurrentGroup()
1030
+ )
1031
+ );
1032
+ $this->assertFalse($abstractContent->isWritable(-1,
1033
+ vfsStream::getCurrentGroup()
1034
+ )
1035
+ );
1036
+ $this->assertTrue($abstractContent->isWritable(-1,
1037
+ -1
1038
+ )
1039
+ );
1040
+ $this->assertFalse($abstractContent->isExecutable(vfsStream::getCurrentUser(),
1041
+ vfsStream::getCurrentGroup()
1042
+ )
1043
+ );
1044
+ $this->assertFalse($abstractContent->isExecutable(-1,
1045
+ vfsStream::getCurrentGroup()
1046
+ )
1047
+ );
1048
+ $this->assertTrue($abstractContent->isExecutable(-1,
1049
+ -1
1050
+ )
1051
+ );
1052
+ }
1053
+ }
1054
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamBlockTestCase.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for org\bovigo\vfs\vfsStreamBlock.
13
+ */
14
+ class vfsStreamBlockTestCase extends \PHPUnit_Framework_TestCase
15
+ {
16
+ /**
17
+ * The block device being tested.
18
+ *
19
+ * @var vfsStreamBlock $block
20
+ */
21
+ protected $block;
22
+
23
+ public function setUp()
24
+ {
25
+ $this->block = new vfsStreamBlock('foo');
26
+ }
27
+
28
+ /**
29
+ * test default values and methods
30
+ *
31
+ * @test
32
+ */
33
+ public function defaultValues()
34
+ {
35
+ $this->assertEquals(vfsStreamContent::TYPE_BLOCK, $this->block->getType());
36
+ $this->assertEquals('foo', $this->block->getName());
37
+ $this->assertTrue($this->block->appliesTo('foo'));
38
+ $this->assertFalse($this->block->appliesTo('foo/bar'));
39
+ $this->assertFalse($this->block->appliesTo('bar'));
40
+ }
41
+
42
+ /**
43
+ * tests how external functions see this object
44
+ *
45
+ * @test
46
+ */
47
+ public function external()
48
+ {
49
+ $root = vfsStream::setup('root');
50
+ $root->addChild(vfsStream::newBlock('foo'));
51
+ $this->assertEquals('block', filetype(vfsStream::url('root/foo')));
52
+ }
53
+
54
+ /**
55
+ * tests adding a complex structure
56
+ *
57
+ * @test
58
+ */
59
+ public function addStructure()
60
+ {
61
+ $structure = array(
62
+ 'topLevel' => array(
63
+ 'thisIsAFile' => 'file contents',
64
+ '[blockDevice]' => 'block contents'
65
+ )
66
+ );
67
+
68
+ $root = vfsStream::create($structure);
69
+
70
+ $this->assertSame('block', filetype(vfsStream::url('root/topLevel/blockDevice')));
71
+ }
72
+
73
+ /**
74
+ * tests that a blank name for a block device throws an exception
75
+ * @test
76
+ * @expectedException org\bovigo\vfs\vfsStreamException
77
+ */
78
+ public function createWithEmptyName()
79
+ {
80
+ $structure = array(
81
+ 'topLevel' => array(
82
+ 'thisIsAFile' => 'file contents',
83
+ '[]' => 'block contents'
84
+ )
85
+ );
86
+
87
+ $root = vfsStream::create($structure);
88
+ }
89
+ }
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamContainerIteratorTestCase.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for org\bovigo\vfs\vfsStreamContainerIterator.
13
+ */
14
+ class vfsStreamContainerIteratorTestCase extends \PHPUnit_Framework_TestCase
15
+ {
16
+ /**
17
+ * instance to test
18
+ *
19
+ * @type vfsStreamDirectory
20
+ */
21
+ private $dir;
22
+ /**
23
+ * child one
24
+ *
25
+ * @type \PHPUnit_Framework_MockObject_MockObject
26
+ */
27
+ private $mockChild1;
28
+ /**
29
+ * child two
30
+ *
31
+ * @type \PHPUnit_Framework_MockObject_MockObject
32
+ */
33
+ private $mockChild2;
34
+
35
+ /**
36
+ * set up test environment
37
+ */
38
+ public function setUp()
39
+ {
40
+ $this->dir = new vfsStreamDirectory('foo');
41
+ $this->mockChild1 = $this->getMock('org\\bovigo\\vfs\\vfsStreamContent');
42
+ $this->mockChild1->expects($this->any())
43
+ ->method('getName')
44
+ ->will($this->returnValue('bar'));
45
+ $this->dir->addChild($this->mockChild1);
46
+ $this->mockChild2 = $this->getMock('org\\bovigo\\vfs\\vfsStreamContent');
47
+ $this->mockChild2->expects($this->any())
48
+ ->method('getName')
49
+ ->will($this->returnValue('baz'));
50
+ $this->dir->addChild($this->mockChild2);
51
+ }
52
+
53
+ /**
54
+ * clean up test environment
55
+ */
56
+ public function tearDown()
57
+ {
58
+ vfsStream::enableDotfiles();
59
+ }
60
+
61
+ /**
62
+ * @return array
63
+ */
64
+ public function provideSwitchWithExpectations()
65
+ {
66
+ return array(array(function() { vfsStream::disableDotfiles(); },
67
+ array()
68
+ ),
69
+ array(function() { vfsStream::enableDotfiles(); },
70
+ array('.', '..')
71
+ )
72
+ );
73
+ }
74
+
75
+ private function getDirName($dir)
76
+ {
77
+ if (is_string($dir)) {
78
+ return $dir;
79
+ }
80
+
81
+
82
+ return $dir->getName();
83
+ }
84
+
85
+ /**
86
+ * @param \Closure $dotFilesSwitch
87
+ * @param array $dirNames
88
+ * @test
89
+ * @dataProvider provideSwitchWithExpectations
90
+ */
91
+ public function iteration(\Closure $dotFilesSwitch, array $dirs)
92
+ {
93
+ $dirs[] = $this->mockChild1;
94
+ $dirs[] = $this->mockChild2;
95
+ $dotFilesSwitch();
96
+ $dirIterator = $this->dir->getIterator();
97
+ foreach ($dirs as $dir) {
98
+ $this->assertEquals($this->getDirName($dir), $dirIterator->key());
99
+ $this->assertTrue($dirIterator->valid());
100
+ if (!is_string($dir)) {
101
+ $this->assertSame($dir, $dirIterator->current());
102
+ }
103
+
104
+ $dirIterator->next();
105
+ }
106
+
107
+ $this->assertFalse($dirIterator->valid());
108
+ $this->assertNull($dirIterator->key());
109
+ $this->assertNull($dirIterator->current());
110
+ }
111
+ }
112
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamDirectoryIssue18TestCase.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for org\bovigo\vfs\vfsStreamDirectory.
13
+ *
14
+ * @group bug_18
15
+ */
16
+ class vfsStreamDirectoryIssue18TestCase extends \PHPUnit_Framework_TestCase
17
+ {
18
+ /**
19
+ * access to root directory
20
+ *
21
+ * @var vfsStreamDirectory
22
+ */
23
+ protected $rootDirectory;
24
+
25
+ /**
26
+ * set up test environment
27
+ */
28
+ public function setUp()
29
+ {
30
+ $this->rootDirectory = vfsStream::newDirectory('/');
31
+ $this->rootDirectory->addChild(vfsStream::newDirectory('var/log/app'));
32
+ $dir = $this->rootDirectory->getChild('var/log/app');
33
+ $dir->addChild(vfsStream::newDirectory('app1'));
34
+ $dir->addChild(vfsStream::newDirectory('app2'));
35
+ $dir->addChild(vfsStream::newDirectory('foo'));
36
+ }
37
+
38
+ /**
39
+ * @test
40
+ */
41
+ public function shouldContainThreeSubdirectories()
42
+ {
43
+ $this->assertEquals(3,
44
+ count($this->rootDirectory->getChild('var/log/app')->getChildren())
45
+ );
46
+ }
47
+
48
+ /**
49
+ * @test
50
+ */
51
+ public function shouldContainSubdirectoryFoo()
52
+ {
53
+ $this->assertTrue($this->rootDirectory->getChild('var/log/app')->hasChild('foo'));
54
+ $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory',
55
+ $this->rootDirectory->getChild('var/log/app')->getChild('foo')
56
+ );
57
+ }
58
+
59
+ /**
60
+ * @test
61
+ */
62
+ public function shouldContainSubdirectoryApp1()
63
+ {
64
+ $this->assertTrue($this->rootDirectory->getChild('var/log/app')->hasChild('app1'));
65
+ $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory',
66
+ $this->rootDirectory->getChild('var/log/app')->getChild('app1')
67
+ );
68
+ }
69
+
70
+ /**
71
+ * @test
72
+ */
73
+ public function shouldContainSubdirectoryApp2()
74
+ {
75
+ $this->assertTrue($this->rootDirectory->getChild('var/log/app')->hasChild('app2'));
76
+ $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory',
77
+ $this->rootDirectory->getChild('var/log/app')->getChild('app2')
78
+ );
79
+ }
80
+ }
81
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamDirectoryTestCase.php ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for org\bovigo\vfs\vfsStreamDirectory.
13
+ */
14
+ class vfsStreamDirectoryTestCase extends \PHPUnit_Framework_TestCase
15
+ {
16
+ /**
17
+ * instance to test
18
+ *
19
+ * @var vfsStreamDirectory
20
+ */
21
+ protected $dir;
22
+
23
+ /**
24
+ * set up test environment
25
+ */
26
+ public function setUp()
27
+ {
28
+ $this->dir = new vfsStreamDirectory('foo');
29
+ }
30
+
31
+ /**
32
+ * assure that a directory seperator inside the name throws an exception
33
+ *
34
+ * @test
35
+ * @expectedException org\bovigo\vfs\vfsStreamException
36
+ */
37
+ public function invalidCharacterInName()
38
+ {
39
+ $dir = new vfsStreamDirectory('foo/bar');
40
+ }
41
+
42
+ /**
43
+ * test default values and methods
44
+ *
45
+ * @test
46
+ */
47
+ public function defaultValues()
48
+ {
49
+ $this->assertEquals(vfsStreamContent::TYPE_DIR, $this->dir->getType());
50
+ $this->assertEquals('foo', $this->dir->getName());
51
+ $this->assertTrue($this->dir->appliesTo('foo'));
52
+ $this->assertTrue($this->dir->appliesTo('foo/bar'));
53
+ $this->assertFalse($this->dir->appliesTo('bar'));
54
+ $this->assertEquals(array(), $this->dir->getChildren());
55
+ }
56
+
57
+ /**
58
+ * test renaming the directory
59
+ *
60
+ * @test
61
+ */
62
+ public function rename()
63
+ {
64
+ $this->dir->rename('bar');
65
+ $this->assertEquals('bar', $this->dir->getName());
66
+ $this->assertFalse($this->dir->appliesTo('foo'));
67
+ $this->assertFalse($this->dir->appliesTo('foo/bar'));
68
+ $this->assertTrue($this->dir->appliesTo('bar'));
69
+ }
70
+
71
+ /**
72
+ * renaming the directory to an invalid name throws a vfsStreamException
73
+ *
74
+ * @test
75
+ * @expectedException org\bovigo\vfs\vfsStreamException
76
+ */
77
+ public function renameToInvalidNameThrowsvfsStreamException()
78
+ {
79
+ $this->dir->rename('foo/baz');
80
+ }
81
+
82
+ /**
83
+ * @test
84
+ * @since 0.10.0
85
+ */
86
+ public function hasNoChildrenByDefault()
87
+ {
88
+ $this->assertFalse($this->dir->hasChildren());
89
+ }
90
+
91
+ /**
92
+ * @test
93
+ * @since 0.10.0
94
+ */
95
+ public function hasChildrenReturnsTrueIfAtLeastOneChildPresent()
96
+ {
97
+ $mockChild = $this->getMock('org\\bovigo\\vfs\\vfsStreamContent');
98
+ $mockChild->expects($this->any())
99
+ ->method('appliesTo')
100
+ ->will($this->returnValue(false));
101
+ $mockChild->expects($this->any())
102
+ ->method('getName')
103
+ ->will($this->returnValue('baz'));
104
+ $this->dir->addChild($mockChild);
105
+ $this->assertTrue($this->dir->hasChildren());
106
+ }
107
+
108
+ /**
109
+ * @test
110
+ */
111
+ public function hasChildReturnsFalseForNonExistingChild()
112
+ {
113
+ $this->assertFalse($this->dir->hasChild('bar'));
114
+ }
115
+
116
+ /**
117
+ * @test
118
+ */
119
+ public function getChildReturnsNullForNonExistingChild()
120
+ {
121
+ $this->assertNull($this->dir->getChild('bar'));
122
+ }
123
+
124
+ /**
125
+ * @test
126
+ */
127
+ public function removeChildReturnsFalseForNonExistingChild()
128
+ {
129
+ $this->assertFalse($this->dir->removeChild('bar'));
130
+ }
131
+
132
+ /**
133
+ * @test
134
+ */
135
+ public function nonExistingChild()
136
+ {
137
+ $mockChild = $this->getMock('org\\bovigo\\vfs\\vfsStreamContent');
138
+ $mockChild->expects($this->any())
139
+ ->method('appliesTo')
140
+ ->will($this->returnValue(false));
141
+ $mockChild->expects($this->any())
142
+ ->method('getName')
143
+ ->will($this->returnValue('baz'));
144
+ $this->dir->addChild($mockChild);
145
+ $this->assertFalse($this->dir->removeChild('bar'));
146
+ }
147
+
148
+ /**
149
+ * test that adding, handling and removing of a child works as expected
150
+ *
151
+ * @test
152
+ */
153
+ public function childHandling()
154
+ {
155
+ $mockChild = $this->getMock('org\\bovigo\\vfs\\vfsStreamContent');
156
+ $mockChild->expects($this->any())
157
+ ->method('getType')
158
+ ->will($this->returnValue(vfsStreamContent::TYPE_FILE));
159
+ $mockChild->expects($this->any())
160
+ ->method('getName')
161
+ ->will($this->returnValue('bar'));
162
+ $mockChild->expects($this->any())
163
+ ->method('appliesTo')
164
+ ->with($this->equalTo('bar'))
165
+ ->will($this->returnValue(true));
166
+ $mockChild->expects($this->once())
167
+ ->method('size')
168
+ ->will($this->returnValue(5));
169
+ $this->dir->addChild($mockChild);
170
+ $this->assertTrue($this->dir->hasChild('bar'));
171
+ $bar = $this->dir->getChild('bar');
172
+ $this->assertSame($mockChild, $bar);
173
+ $this->assertEquals(array($mockChild), $this->dir->getChildren());
174
+ $this->assertEquals(0, $this->dir->size());
175
+ $this->assertEquals(5, $this->dir->sizeSummarized());
176
+ $this->assertTrue($this->dir->removeChild('bar'));
177
+ $this->assertEquals(array(), $this->dir->getChildren());
178
+ $this->assertEquals(0, $this->dir->size());
179
+ $this->assertEquals(0, $this->dir->sizeSummarized());
180
+ }
181
+
182
+ /**
183
+ * test that adding, handling and removing of a child works as expected
184
+ *
185
+ * @test
186
+ */
187
+ public function childHandlingWithSubdirectory()
188
+ {
189
+ $mockChild = $this->getMock('org\\bovigo\\vfs\\vfsStreamContent');
190
+ $mockChild->expects($this->any())
191
+ ->method('getType')
192
+ ->will($this->returnValue(vfsStreamContent::TYPE_FILE));
193
+ $mockChild->expects($this->any())
194
+ ->method('getName')
195
+ ->will($this->returnValue('bar'));
196
+ $mockChild->expects($this->once())
197
+ ->method('size')
198
+ ->will($this->returnValue(5));
199
+ $subdir = new vfsStreamDirectory('subdir');
200
+ $subdir->addChild($mockChild);
201
+ $this->dir->addChild($subdir);
202
+ $this->assertTrue($this->dir->hasChild('subdir'));
203
+ $this->assertSame($subdir, $this->dir->getChild('subdir'));
204
+ $this->assertEquals(array($subdir), $this->dir->getChildren());
205
+ $this->assertEquals(0, $this->dir->size());
206
+ $this->assertEquals(5, $this->dir->sizeSummarized());
207
+ $this->assertTrue($this->dir->removeChild('subdir'));
208
+ $this->assertEquals(array(), $this->dir->getChildren());
209
+ $this->assertEquals(0, $this->dir->size());
210
+ $this->assertEquals(0, $this->dir->sizeSummarized());
211
+ }
212
+
213
+ /**
214
+ * dd
215
+ *
216
+ * @test
217
+ * @group regression
218
+ * @group bug_5
219
+ */
220
+ public function addChildReplacesChildWithSameName_Bug_5()
221
+ {
222
+ $mockChild1 = $this->getMock('org\\bovigo\\vfs\\vfsStreamContent');
223
+ $mockChild1->expects($this->any())
224
+ ->method('getType')
225
+ ->will($this->returnValue(vfsStreamContent::TYPE_FILE));
226
+ $mockChild1->expects($this->any())
227
+ ->method('getName')
228
+ ->will($this->returnValue('bar'));
229
+ $mockChild2 = $this->getMock('org\\bovigo\\vfs\\vfsStreamContent');
230
+ $mockChild2->expects($this->any())
231
+ ->method('getType')
232
+ ->will($this->returnValue(vfsStreamContent::TYPE_FILE));
233
+ $mockChild2->expects($this->any())
234
+ ->method('getName')
235
+ ->will($this->returnValue('bar'));
236
+ $this->dir->addChild($mockChild1);
237
+ $this->assertTrue($this->dir->hasChild('bar'));
238
+ $this->assertSame($mockChild1, $this->dir->getChild('bar'));
239
+ $this->dir->addChild($mockChild2);
240
+ $this->assertTrue($this->dir->hasChild('bar'));
241
+ $this->assertSame($mockChild2, $this->dir->getChild('bar'));
242
+ }
243
+
244
+ /**
245
+ * When testing for a nested path, verify that directory separators are respected properly
246
+ * so that subdir1/subdir2 is not considered equal to subdir1Xsubdir2.
247
+ *
248
+ * @test
249
+ * @group bug_24
250
+ * @group regression
251
+ */
252
+ public function explicitTestForSeparatorWithNestedPaths_Bug_24()
253
+ {
254
+ $mockChild = $this->getMock('org\\bovigo\\vfs\\vfsStreamContent');
255
+ $mockChild->expects($this->any())
256
+ ->method('getType')
257
+ ->will($this->returnValue(vfsStreamContent::TYPE_FILE));
258
+ $mockChild->expects($this->any())
259
+ ->method('getName')
260
+ ->will($this->returnValue('bar'));
261
+
262
+ $subdir1 = new vfsStreamDirectory('subdir1');
263
+ $this->dir->addChild($subdir1);
264
+
265
+ $subdir2 = new vfsStreamDirectory('subdir2');
266
+ $subdir1->addChild($subdir2);
267
+
268
+ $subdir2->addChild($mockChild);
269
+
270
+ $this->assertTrue($this->dir->hasChild('subdir1'), "Level 1 path with separator exists");
271
+ $this->assertTrue($this->dir->hasChild('subdir1/subdir2'), "Level 2 path with separator exists");
272
+ $this->assertTrue($this->dir->hasChild('subdir1/subdir2/bar'), "Level 3 path with separator exists");
273
+ $this->assertFalse($this->dir->hasChild('subdir1.subdir2'), "Path with period does not exist");
274
+ $this->assertFalse($this->dir->hasChild('subdir1.subdir2/bar'), "Nested path with period does not exist");
275
+ }
276
+
277
+
278
+ /**
279
+ * setting and retrieving permissions for a directory
280
+ *
281
+ * @test
282
+ * @group permissions
283
+ */
284
+ public function permissions()
285
+ {
286
+ $this->assertEquals(0777, $this->dir->getPermissions());
287
+ $this->assertSame($this->dir, $this->dir->chmod(0755));
288
+ $this->assertEquals(0755, $this->dir->getPermissions());
289
+ }
290
+
291
+ /**
292
+ * setting and retrieving permissions for a directory
293
+ *
294
+ * @test
295
+ * @group permissions
296
+ */
297
+ public function permissionsSet()
298
+ {
299
+ $this->dir = new vfsStreamDirectory('foo', 0755);
300
+ $this->assertEquals(0755, $this->dir->getPermissions());
301
+ $this->assertSame($this->dir, $this->dir->chmod(0700));
302
+ $this->assertEquals(0700, $this->dir->getPermissions());
303
+ }
304
+
305
+ /**
306
+ * setting and retrieving owner of a file
307
+ *
308
+ * @test
309
+ * @group permissions
310
+ */
311
+ public function owner()
312
+ {
313
+ $this->assertEquals(vfsStream::getCurrentUser(), $this->dir->getUser());
314
+ $this->assertTrue($this->dir->isOwnedByUser(vfsStream::getCurrentUser()));
315
+ $this->assertSame($this->dir, $this->dir->chown(vfsStream::OWNER_USER_1));
316
+ $this->assertEquals(vfsStream::OWNER_USER_1, $this->dir->getUser());
317
+ $this->assertTrue($this->dir->isOwnedByUser(vfsStream::OWNER_USER_1));
318
+ }
319
+
320
+ /**
321
+ * setting and retrieving owner group of a file
322
+ *
323
+ * @test
324
+ * @group permissions
325
+ */
326
+ public function group()
327
+ {
328
+ $this->assertEquals(vfsStream::getCurrentGroup(), $this->dir->getGroup());
329
+ $this->assertTrue($this->dir->isOwnedByGroup(vfsStream::getCurrentGroup()));
330
+ $this->assertSame($this->dir, $this->dir->chgrp(vfsStream::GROUP_USER_1));
331
+ $this->assertEquals(vfsStream::GROUP_USER_1, $this->dir->getGroup());
332
+ $this->assertTrue($this->dir->isOwnedByGroup(vfsStream::GROUP_USER_1));
333
+ }
334
+ }
335
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamExLockTestCase.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for LOCK_EX behaviour related to file_put_contents().
13
+ *
14
+ * @group lock_fpc
15
+ * @author https://github.com/iwyg
16
+ */
17
+ class vfsStreamExLockTestCase extends \PHPUnit_Framework_TestCase
18
+ {
19
+ /**
20
+ * set up test environment
21
+ */
22
+ protected function setUp()
23
+ {
24
+ $root = vfsStream::setup();
25
+ vfsStream::newFile('testfile')->at($root);
26
+
27
+ }
28
+
29
+ /**
30
+ * This test verifies the current behaviour where vfsStream URLs do not work
31
+ * with file_put_contents() and LOCK_EX. The test is intended to break once
32
+ * PHP changes this so we get notified about the change.
33
+ *
34
+ * @test
35
+ */
36
+ public function filePutContentsLockShouldReportError()
37
+ {
38
+ @file_put_contents(vfsStream::url('root/testfile'), "some string\n", LOCK_EX);
39
+ $php_error = error_get_last();
40
+ $this->assertEquals("file_put_contents(): Exclusive locks may only be set for regular files", $php_error['message']);
41
+ }
42
+
43
+ /**
44
+ * @test
45
+ */
46
+ public function flockSouldPass()
47
+ {
48
+ $fp = fopen(vfsStream::url('root/testfile'), 'w');
49
+ flock($fp, LOCK_EX);
50
+ fwrite($fp, "another string\n");
51
+ flock($fp, LOCK_UN);
52
+ fclose($fp);
53
+ $this->assertEquals("another string\n", file_get_contents(vfsStream::url('root/testfile')));
54
+ }
55
+ }
56
+
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamFileTestCase.php ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for org\bovigo\vfs\vfsStreamFile.
13
+ */
14
+ class vfsStreamFileTestCase extends \PHPUnit_Framework_TestCase
15
+ {
16
+ /**
17
+ * instance to test
18
+ *
19
+ * @var vfsStreamFile
20
+ */
21
+ protected $file;
22
+
23
+ /**
24
+ * set up test environment
25
+ */
26
+ public function setUp()
27
+ {
28
+ $this->file = new vfsStreamFile('foo');
29
+ }
30
+
31
+ /**
32
+ * test default values and methods
33
+ *
34
+ * @test
35
+ */
36
+ public function defaultValues()
37
+ {
38
+ $this->assertEquals(vfsStreamContent::TYPE_FILE, $this->file->getType());
39
+ $this->assertEquals('foo', $this->file->getName());
40
+ $this->assertTrue($this->file->appliesTo('foo'));
41
+ $this->assertFalse($this->file->appliesTo('foo/bar'));
42
+ $this->assertFalse($this->file->appliesTo('bar'));
43
+ }
44
+
45
+ /**
46
+ * test setting and getting the content of a file
47
+ *
48
+ * @test
49
+ */
50
+ public function content()
51
+ {
52
+ $this->assertNull($this->file->getContent());
53
+ $this->assertSame($this->file, $this->file->setContent('bar'));
54
+ $this->assertEquals('bar', $this->file->getContent());
55
+ $this->assertSame($this->file, $this->file->withContent('baz'));
56
+ $this->assertEquals('baz', $this->file->getContent());
57
+ }
58
+
59
+ /**
60
+ * test renaming the directory
61
+ *
62
+ * @test
63
+ */
64
+ public function rename()
65
+ {
66
+ $this->file->rename('bar');
67
+ $this->assertEquals('bar', $this->file->getName());
68
+ $this->assertFalse($this->file->appliesTo('foo'));
69
+ $this->assertFalse($this->file->appliesTo('foo/bar'));
70
+ $this->assertTrue($this->file->appliesTo('bar'));
71
+ }
72
+
73
+ /**
74
+ * test reading contents from the file
75
+ *
76
+ * @test
77
+ */
78
+ public function readEmptyFile()
79
+ {
80
+ $this->assertTrue($this->file->eof());
81
+ $this->assertEquals(0, $this->file->size());
82
+ $this->assertEquals('', $this->file->read(5));
83
+ $this->assertEquals(5, $this->file->getBytesRead());
84
+ $this->assertTrue($this->file->eof());
85
+ }
86
+
87
+ /**
88
+ * test reading contents from the file
89
+ *
90
+ * @test
91
+ */
92
+ public function read()
93
+ {
94
+ $this->file->setContent('foobarbaz');
95
+ $this->assertFalse($this->file->eof());
96
+ $this->assertEquals(9, $this->file->size());
97
+ $this->assertEquals('foo', $this->file->read(3));
98
+ $this->assertEquals(3, $this->file->getBytesRead());
99
+ $this->assertFalse($this->file->eof());
100
+ $this->assertEquals(9, $this->file->size());
101
+ $this->assertEquals('bar', $this->file->read(3));
102
+ $this->assertEquals(6, $this->file->getBytesRead());
103
+ $this->assertFalse($this->file->eof());
104
+ $this->assertEquals(9, $this->file->size());
105
+ $this->assertEquals('baz', $this->file->read(3));
106
+ $this->assertEquals(9, $this->file->getBytesRead());
107
+ $this->assertEquals(9, $this->file->size());
108
+ $this->assertTrue($this->file->eof());
109
+ $this->assertEquals('', $this->file->read(3));
110
+ }
111
+
112
+ /**
113
+ * test seeking to offset
114
+ *
115
+ * @test
116
+ */
117
+ public function seekEmptyFile()
118
+ {
119
+ $this->assertFalse($this->file->seek(0, 55));
120
+ $this->assertTrue($this->file->seek(0, SEEK_SET));
121
+ $this->assertEquals(0, $this->file->getBytesRead());
122
+ $this->assertTrue($this->file->seek(5, SEEK_SET));
123
+ $this->assertEquals(5, $this->file->getBytesRead());
124
+ $this->assertTrue($this->file->seek(0, SEEK_CUR));
125
+ $this->assertEquals(5, $this->file->getBytesRead());
126
+ $this->assertTrue($this->file->seek(2, SEEK_CUR));
127
+ $this->assertEquals(7, $this->file->getBytesRead());
128
+ $this->assertTrue($this->file->seek(0, SEEK_END));
129
+ $this->assertEquals(0, $this->file->getBytesRead());
130
+ $this->assertTrue($this->file->seek(2, SEEK_END));
131
+ $this->assertEquals(2, $this->file->getBytesRead());
132
+ }
133
+
134
+ /**
135
+ * test seeking to offset
136
+ *
137
+ * @test
138
+ */
139
+ public function seekRead()
140
+ {
141
+ $this->file->setContent('foobarbaz');
142
+ $this->assertFalse($this->file->seek(0, 55));
143
+ $this->assertTrue($this->file->seek(0, SEEK_SET));
144
+ $this->assertEquals('foobarbaz', $this->file->readUntilEnd());
145
+ $this->assertEquals(0, $this->file->getBytesRead());
146
+ $this->assertTrue($this->file->seek(5, SEEK_SET));
147
+ $this->assertEquals('rbaz', $this->file->readUntilEnd());
148
+ $this->assertEquals(5, $this->file->getBytesRead());
149
+ $this->assertTrue($this->file->seek(0, SEEK_CUR));
150
+ $this->assertEquals('rbaz', $this->file->readUntilEnd());
151
+ $this->assertEquals(5, $this->file->getBytesRead(), 5);
152
+ $this->assertTrue($this->file->seek(2, SEEK_CUR));
153
+ $this->assertEquals('az', $this->file->readUntilEnd());
154
+ $this->assertEquals(7, $this->file->getBytesRead());
155
+ $this->assertTrue($this->file->seek(0, SEEK_END));
156
+ $this->assertEquals('', $this->file->readUntilEnd());
157
+ $this->assertEquals(9, $this->file->getBytesRead());
158
+ $this->assertTrue($this->file->seek(2, SEEK_END));
159
+ $this->assertEquals('', $this->file->readUntilEnd());
160
+ $this->assertEquals(11, $this->file->getBytesRead());
161
+ }
162
+
163
+ /**
164
+ * test writing data into the file
165
+ *
166
+ * @test
167
+ */
168
+ public function writeEmptyFile()
169
+ {
170
+ $this->assertEquals(3, $this->file->write('foo'));
171
+ $this->assertEquals('foo', $this->file->getContent());
172
+ $this->assertEquals(3, $this->file->size());
173
+ $this->assertEquals(3, $this->file->write('bar'));
174
+ $this->assertEquals('foobar', $this->file->getContent());
175
+ $this->assertEquals(6, $this->file->size());
176
+ }
177
+
178
+ /**
179
+ * test writing data into the file
180
+ *
181
+ * @test
182
+ */
183
+ public function write()
184
+ {
185
+ $this->file->setContent('foobarbaz');
186
+ $this->assertTrue($this->file->seek(3, SEEK_SET));
187
+ $this->assertEquals(3, $this->file->write('foo'));
188
+ $this->assertEquals('foofoobaz', $this->file->getContent());
189
+ $this->assertEquals(9, $this->file->size());
190
+ $this->assertEquals(3, $this->file->write('bar'));
191
+ $this->assertEquals('foofoobar', $this->file->getContent());
192
+ $this->assertEquals(9, $this->file->size());
193
+ }
194
+
195
+ /**
196
+ * setting and retrieving permissions for a file
197
+ *
198
+ * @test
199
+ * @group permissions
200
+ */
201
+ public function permissions()
202
+ {
203
+ $this->assertEquals(0666, $this->file->getPermissions());
204
+ $this->assertSame($this->file, $this->file->chmod(0644));
205
+ $this->assertEquals(0644, $this->file->getPermissions());
206
+ }
207
+
208
+ /**
209
+ * setting and retrieving permissions for a file
210
+ *
211
+ * @test
212
+ * @group permissions
213
+ */
214
+ public function permissionsSet()
215
+ {
216
+ $this->file = new vfsStreamFile('foo', 0644);
217
+ $this->assertEquals(0644, $this->file->getPermissions());
218
+ $this->assertSame($this->file, $this->file->chmod(0600));
219
+ $this->assertEquals(0600, $this->file->getPermissions());
220
+ }
221
+
222
+ /**
223
+ * setting and retrieving owner of a file
224
+ *
225
+ * @test
226
+ * @group permissions
227
+ */
228
+ public function owner()
229
+ {
230
+ $this->assertEquals(vfsStream::getCurrentUser(), $this->file->getUser());
231
+ $this->assertTrue($this->file->isOwnedByUser(vfsStream::getCurrentUser()));
232
+ $this->assertSame($this->file, $this->file->chown(vfsStream::OWNER_USER_1));
233
+ $this->assertEquals(vfsStream::OWNER_USER_1, $this->file->getUser());
234
+ $this->assertTrue($this->file->isOwnedByUser(vfsStream::OWNER_USER_1));
235
+ }
236
+
237
+ /**
238
+ * setting and retrieving owner group of a file
239
+ *
240
+ * @test
241
+ * @group permissions
242
+ */
243
+ public function group()
244
+ {
245
+ $this->assertEquals(vfsStream::getCurrentGroup(), $this->file->getGroup());
246
+ $this->assertTrue($this->file->isOwnedByGroup(vfsStream::getCurrentGroup()));
247
+ $this->assertSame($this->file, $this->file->chgrp(vfsStream::GROUP_USER_1));
248
+ $this->assertEquals(vfsStream::GROUP_USER_1, $this->file->getGroup());
249
+ $this->assertTrue($this->file->isOwnedByGroup(vfsStream::GROUP_USER_1));
250
+ }
251
+
252
+ /**
253
+ * @test
254
+ * @group issue_33
255
+ * @since 1.1.0
256
+ */
257
+ public function truncateRemovesSuperflouosContent()
258
+ {
259
+ $this->assertEquals(11, $this->file->write("lorem ipsum"));
260
+ $this->assertTrue($this->file->truncate(5));
261
+ $this->assertEquals(5, $this->file->size());
262
+ $this->assertEquals('lorem', $this->file->getContent());
263
+ }
264
+
265
+ /**
266
+ * @test
267
+ * @group issue_33
268
+ * @since 1.1.0
269
+ */
270
+ public function truncateToGreaterSizeAddsZeroBytes()
271
+ {
272
+ $this->assertEquals(11, $this->file->write("lorem ipsum"));
273
+ $this->assertTrue($this->file->truncate(25));
274
+ $this->assertEquals(25, $this->file->size());
275
+ $this->assertEquals("lorem ipsum\0\0\0\0\0\0\0\0\0\0\0\0\0\0", $this->file->getContent());
276
+ }
277
+
278
+ /**
279
+ * @test
280
+ * @group issue_79
281
+ * @since 1.3.0
282
+ */
283
+ public function withContentAcceptsAnyFileContentInstance()
284
+ {
285
+ $mockFileContent = $this->getMock('org\bovigo\vfs\content\FileContent');
286
+ $mockFileContent->expects($this->once())
287
+ ->method('content')
288
+ ->will($this->returnValue('foobarbaz'));
289
+ $this->assertEquals(
290
+ 'foobarbaz',
291
+ $this->file->withContent($mockFileContent)
292
+ ->getContent()
293
+ );
294
+ }
295
+
296
+ /**
297
+ * @test
298
+ * @group issue_79
299
+ * @expectedException \InvalidArgumentException
300
+ * @since 1.3.0
301
+ */
302
+ public function withContentThrowsInvalidArgumentExceptionWhenContentIsNoStringAndNoFileContent()
303
+ {
304
+ $this->file->withContent(313);
305
+ }
306
+ }
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamGlobTestCase.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for org\bovigo\vfs\vfsStream.
13
+ *
14
+ * @since 0.9.0
15
+ * @group issue_2
16
+ */
17
+ class vfsStreamGlobTestCase extends \PHPUnit_Framework_TestCase
18
+ {
19
+ /**
20
+ * @test
21
+ */
22
+ public function globDoesNotWorkWithVfsStreamUrls()
23
+ {
24
+ $root = vfsStream::setup('example');
25
+ mkdir(vfsStream::url('example/test/'), 0777, true);
26
+ $this->assertEmpty(glob(vfsStream::url('example'), GLOB_MARK));
27
+ }
28
+ }
29
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamResolveIncludePathTestCase.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for org\bovigo\vfs\vfsStream.
13
+ *
14
+ * @since 0.9.0
15
+ * @group issue_5
16
+ */
17
+ class vfsStreamResolveIncludePathTestCase extends \PHPUnit_Framework_TestCase
18
+ {
19
+ /**
20
+ * include path to restore after test run
21
+ *
22
+ * @var string
23
+ */
24
+ protected $backupIncludePath;
25
+
26
+ /**
27
+ * set up test environment
28
+ */
29
+ public function setUp()
30
+ {
31
+ $this->backupIncludePath = get_include_path();
32
+ vfsStream::setup();
33
+ mkdir('vfs://root/a/path', 0777, true);
34
+ set_include_path('vfs://root/a' . PATH_SEPARATOR . $this->backupIncludePath);
35
+ }
36
+
37
+ /**
38
+ * clean up test environment
39
+ */
40
+ public function tearDown()
41
+ {
42
+ set_include_path($this->backupIncludePath);
43
+ }
44
+
45
+ /**
46
+ * @test
47
+ */
48
+ public function knownFileCanBeResolved()
49
+ {
50
+ file_put_contents('vfs://root/a/path/knownFile.php', '<?php ?>');
51
+ $this->assertEquals('vfs://root/a/path/knownFile.php', stream_resolve_include_path('path/knownFile.php'));
52
+ }
53
+
54
+ /**
55
+ * @test
56
+ */
57
+ public function unknownFileCanNotBeResolvedYieldsFalse()
58
+ {
59
+ $this->assertFalse(@stream_resolve_include_path('path/unknownFile.php'));
60
+ }
61
+ }
62
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamTestCase.php ADDED
@@ -0,0 +1,728 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for org\bovigo\vfs\vfsStream.
13
+ */
14
+ class vfsStreamTestCase extends \PHPUnit_Framework_TestCase
15
+ {
16
+ /**
17
+ * set up test environment
18
+ */
19
+ public function setUp()
20
+ {
21
+ vfsStreamWrapper::register();
22
+ }
23
+
24
+ /**
25
+ * assure that path2url conversion works correct
26
+ *
27
+ * @test
28
+ */
29
+ public function url()
30
+ {
31
+ $this->assertEquals('vfs://foo', vfsStream::url('foo'));
32
+ $this->assertEquals('vfs://foo/bar.baz', vfsStream::url('foo/bar.baz'));
33
+ $this->assertEquals('vfs://foo/bar.baz', vfsStream::url('foo\bar.baz'));
34
+ }
35
+
36
+ /**
37
+ * assure that url2path conversion works correct
38
+ *
39
+ * @test
40
+ */
41
+ public function path()
42
+ {
43
+ $this->assertEquals('foo', vfsStream::path('vfs://foo'));
44
+ $this->assertEquals('foo/bar.baz', vfsStream::path('vfs://foo/bar.baz'));
45
+ $this->assertEquals('foo/bar.baz', vfsStream::path('vfs://foo\bar.baz'));
46
+ }
47
+
48
+ /**
49
+ * windows directory separators are converted into default separator
50
+ *
51
+ * @author Gabriel Birke
52
+ * @test
53
+ */
54
+ public function pathConvertsWindowsDirectorySeparators()
55
+ {
56
+ $this->assertEquals('foo/bar', vfsStream::path('vfs://foo\\bar'));
57
+ }
58
+
59
+ /**
60
+ * trailing whitespace should be removed
61
+ *
62
+ * @author Gabriel Birke
63
+ * @test
64
+ */
65
+ public function pathRemovesTrailingWhitespace()
66
+ {
67
+ $this->assertEquals('foo/bar', vfsStream::path('vfs://foo/bar '));
68
+ }
69
+
70
+ /**
71
+ * trailing slashes are removed
72
+ *
73
+ * @author Gabriel Birke
74
+ * @test
75
+ */
76
+ public function pathRemovesTrailingSlash()
77
+ {
78
+ $this->assertEquals('foo/bar', vfsStream::path('vfs://foo/bar/'));
79
+ }
80
+
81
+ /**
82
+ * trailing slash and whitespace should be removed
83
+ *
84
+ * @author Gabriel Birke
85
+ * @test
86
+ */
87
+ public function pathRemovesTrailingSlashAndWhitespace()
88
+ {
89
+ $this->assertEquals('foo/bar', vfsStream::path('vfs://foo/bar/ '));
90
+ }
91
+
92
+ /**
93
+ * double slashes should be replaced by single slash
94
+ *
95
+ * @author Gabriel Birke
96
+ * @test
97
+ */
98
+ public function pathRemovesDoubleSlashes()
99
+ {
100
+ // Regular path
101
+ $this->assertEquals('my/path', vfsStream::path('vfs://my/path'));
102
+ // Path with double slashes
103
+ $this->assertEquals('my/path', vfsStream::path('vfs://my//path'));
104
+ }
105
+
106
+ /**
107
+ * test to create a new file
108
+ *
109
+ * @test
110
+ */
111
+ public function newFile()
112
+ {
113
+ $file = vfsStream::newFile('filename.txt');
114
+ $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamFile', $file);
115
+ $this->assertEquals('filename.txt', $file->getName());
116
+ $this->assertEquals(0666, $file->getPermissions());
117
+ }
118
+
119
+ /**
120
+ * test to create a new file with non-default permissions
121
+ *
122
+ * @test
123
+ * @group permissions
124
+ */
125
+ public function newFileWithDifferentPermissions()
126
+ {
127
+ $file = vfsStream::newFile('filename.txt', 0644);
128
+ $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamFile', $file);
129
+ $this->assertEquals('filename.txt', $file->getName());
130
+ $this->assertEquals(0644, $file->getPermissions());
131
+ }
132
+
133
+ /**
134
+ * test to create a new directory structure
135
+ *
136
+ * @test
137
+ */
138
+ public function newSingleDirectory()
139
+ {
140
+ $foo = vfsStream::newDirectory('foo');
141
+ $this->assertEquals('foo', $foo->getName());
142
+ $this->assertEquals(0, count($foo->getChildren()));
143
+ $this->assertEquals(0777, $foo->getPermissions());
144
+ }
145
+
146
+ /**
147
+ * test to create a new directory structure with non-default permissions
148
+ *
149
+ * @test
150
+ * @group permissions
151
+ */
152
+ public function newSingleDirectoryWithDifferentPermissions()
153
+ {
154
+ $foo = vfsStream::newDirectory('foo', 0755);
155
+ $this->assertEquals('foo', $foo->getName());
156
+ $this->assertEquals(0, count($foo->getChildren()));
157
+ $this->assertEquals(0755, $foo->getPermissions());
158
+ }
159
+
160
+ /**
161
+ * test to create a new directory structure
162
+ *
163
+ * @test
164
+ */
165
+ public function newDirectoryStructure()
166
+ {
167
+ $foo = vfsStream::newDirectory('foo/bar/baz');
168
+ $this->assertEquals('foo', $foo->getName());
169
+ $this->assertEquals(0777, $foo->getPermissions());
170
+ $this->assertTrue($foo->hasChild('bar'));
171
+ $this->assertTrue($foo->hasChild('bar/baz'));
172
+ $this->assertFalse($foo->hasChild('baz'));
173
+ $bar = $foo->getChild('bar');
174
+ $this->assertEquals('bar', $bar->getName());
175
+ $this->assertEquals(0777, $bar->getPermissions());
176
+ $this->assertTrue($bar->hasChild('baz'));
177
+ $baz1 = $bar->getChild('baz');
178
+ $this->assertEquals('baz', $baz1->getName());
179
+ $this->assertEquals(0777, $baz1->getPermissions());
180
+ $baz2 = $foo->getChild('bar/baz');
181
+ $this->assertSame($baz1, $baz2);
182
+ }
183
+
184
+ /**
185
+ * test that correct directory structure is created
186
+ *
187
+ * @test
188
+ */
189
+ public function newDirectoryWithSlashAtStart()
190
+ {
191
+ $foo = vfsStream::newDirectory('/foo/bar/baz', 0755);
192
+ $this->assertEquals('foo', $foo->getName());
193
+ $this->assertEquals(0755, $foo->getPermissions());
194
+ $this->assertTrue($foo->hasChild('bar'));
195
+ $this->assertTrue($foo->hasChild('bar/baz'));
196
+ $this->assertFalse($foo->hasChild('baz'));
197
+ $bar = $foo->getChild('bar');
198
+ $this->assertEquals('bar', $bar->getName());
199
+ $this->assertEquals(0755, $bar->getPermissions());
200
+ $this->assertTrue($bar->hasChild('baz'));
201
+ $baz1 = $bar->getChild('baz');
202
+ $this->assertEquals('baz', $baz1->getName());
203
+ $this->assertEquals(0755, $baz1->getPermissions());
204
+ $baz2 = $foo->getChild('bar/baz');
205
+ $this->assertSame($baz1, $baz2);
206
+ }
207
+
208
+ /**
209
+ * @test
210
+ * @group setup
211
+ * @since 0.7.0
212
+ */
213
+ public function setupRegistersStreamWrapperAndCreatesRootDirectoryWithDefaultNameAndPermissions()
214
+ {
215
+ $root = vfsStream::setup();
216
+ $this->assertSame($root, vfsStreamWrapper::getRoot());
217
+ $this->assertEquals('root', $root->getName());
218
+ $this->assertEquals(0777, $root->getPermissions());
219
+ }
220
+
221
+ /**
222
+ * @test
223
+ * @group setup
224
+ * @since 0.7.0
225
+ */
226
+ public function setupRegistersStreamWrapperAndCreatesRootDirectoryWithGivenNameAndDefaultPermissions()
227
+ {
228
+ $root = vfsStream::setup('foo');
229
+ $this->assertSame($root, vfsStreamWrapper::getRoot());
230
+ $this->assertEquals('foo', $root->getName());
231
+ $this->assertEquals(0777, $root->getPermissions());
232
+ }
233
+
234
+ /**
235
+ * @test
236
+ * @group setup
237
+ * @since 0.7.0
238
+ */
239
+ public function setupRegistersStreamWrapperAndCreatesRootDirectoryWithGivenNameAndPermissions()
240
+ {
241
+ $root = vfsStream::setup('foo', 0444);
242
+ $this->assertSame($root, vfsStreamWrapper::getRoot());
243
+ $this->assertEquals('foo', $root->getName());
244
+ $this->assertEquals(0444, $root->getPermissions());
245
+ }
246
+
247
+ /**
248
+ * @test
249
+ * @group issue_14
250
+ * @group issue_20
251
+ * @since 0.10.0
252
+ */
253
+ public function setupWithEmptyArrayIsEqualToSetup()
254
+ {
255
+ $root = vfsStream::setup('example',
256
+ 0755,
257
+ array()
258
+ );
259
+ $this->assertEquals('example', $root->getName());
260
+ $this->assertEquals(0755, $root->getPermissions());
261
+ $this->assertFalse($root->hasChildren());
262
+ }
263
+
264
+ /**
265
+ * @test
266
+ * @group issue_14
267
+ * @group issue_20
268
+ * @since 0.10.0
269
+ */
270
+ public function setupArraysAreTurnedIntoSubdirectories()
271
+ {
272
+ $root = vfsStream::setup('root',
273
+ null,
274
+ array('test' => array())
275
+ );
276
+ $this->assertTrue($root->hasChildren());
277
+ $this->assertTrue($root->hasChild('test'));
278
+ $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory',
279
+ $root->getChild('test')
280
+ );
281
+ $this->assertFalse($root->getChild('test')->hasChildren());
282
+ }
283
+
284
+ /**
285
+ * @test
286
+ * @group issue_14
287
+ * @group issue_20
288
+ * @since 0.10.0
289
+ */
290
+ public function setupStringsAreTurnedIntoFilesWithContent()
291
+ {
292
+ $root = vfsStream::setup('root',
293
+ null,
294
+ array('test.txt' => 'some content')
295
+ );
296
+ $this->assertTrue($root->hasChildren());
297
+ $this->assertTrue($root->hasChild('test.txt'));
298
+ $this->assertVfsFile($root->getChild('test.txt'), 'some content');
299
+ }
300
+
301
+ /**
302
+ * @test
303
+ * @group issue_14
304
+ * @group issue_20
305
+ * @since 0.10.0
306
+ */
307
+ public function setupWorksRecursively()
308
+ {
309
+ $root = vfsStream::setup('root',
310
+ null,
311
+ array('test' => array('foo' => array('test.txt' => 'hello'),
312
+ 'baz.txt' => 'world'
313
+ )
314
+ )
315
+ );
316
+ $this->assertTrue($root->hasChildren());
317
+ $this->assertTrue($root->hasChild('test'));
318
+ $test = $root->getChild('test');
319
+ $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory', $test);
320
+ $this->assertTrue($test->hasChildren());
321
+ $this->assertTrue($test->hasChild('baz.txt'));
322
+ $this->assertVfsFile($test->getChild('baz.txt'), 'world');
323
+
324
+ $this->assertTrue($test->hasChild('foo'));
325
+ $foo = $test->getChild('foo');
326
+ $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory', $foo);
327
+ $this->assertTrue($foo->hasChildren());
328
+ $this->assertTrue($foo->hasChild('test.txt'));
329
+ $this->assertVfsFile($foo->getChild('test.txt'), 'hello');
330
+ }
331
+
332
+ /**
333
+ * @test
334
+ * @group issue_17
335
+ * @group issue_20
336
+ */
337
+ public function setupCastsNumericDirectoriesToStrings()
338
+ {
339
+ $root = vfsStream::setup('root',
340
+ null,
341
+ array(2011 => array ('test.txt' => 'some content'))
342
+ );
343
+ $this->assertTrue($root->hasChild('2011'));
344
+
345
+ $directory = $root->getChild('2011');
346
+ $this->assertVfsFile($directory->getChild('test.txt'), 'some content');
347
+
348
+ $this->assertTrue(file_exists('vfs://root/2011/test.txt'));
349
+ }
350
+
351
+ /**
352
+ * @test
353
+ * @group issue_20
354
+ * @since 0.11.0
355
+ */
356
+ public function createArraysAreTurnedIntoSubdirectories()
357
+ {
358
+ $baseDir = vfsStream::create(array('test' => array()), new vfsStreamDirectory('baseDir'));
359
+ $this->assertTrue($baseDir->hasChildren());
360
+ $this->assertTrue($baseDir->hasChild('test'));
361
+ $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory',
362
+ $baseDir->getChild('test')
363
+ );
364
+ $this->assertFalse($baseDir->getChild('test')->hasChildren());
365
+ }
366
+
367
+ /**
368
+ * @test
369
+ * @group issue_20
370
+ * @since 0.11.0
371
+ */
372
+ public function createArraysAreTurnedIntoSubdirectoriesOfRoot()
373
+ {
374
+ $root = vfsStream::setup();
375
+ $this->assertSame($root, vfsStream::create(array('test' => array())));
376
+ $this->assertTrue($root->hasChildren());
377
+ $this->assertTrue($root->hasChild('test'));
378
+ $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory',
379
+ $root->getChild('test')
380
+ );
381
+ $this->assertFalse($root->getChild('test')->hasChildren());
382
+ }
383
+
384
+ /**
385
+ * @test
386
+ * @group issue_20
387
+ * @expectedException \InvalidArgumentException
388
+ * @since 0.11.0
389
+ */
390
+ public function createThrowsExceptionIfNoBaseDirGivenAndNoRootSet()
391
+ {
392
+ vfsStream::create(array('test' => array()));
393
+ }
394
+
395
+ /**
396
+ * @test
397
+ * @group issue_20
398
+ * @since 0.11.0
399
+ */
400
+ public function createWorksRecursively()
401
+ {
402
+ $baseDir = vfsStream::create(array('test' => array('foo' => array('test.txt' => 'hello'),
403
+ 'baz.txt' => 'world'
404
+ )
405
+ ),
406
+ new vfsStreamDirectory('baseDir')
407
+ );
408
+ $this->assertTrue($baseDir->hasChildren());
409
+ $this->assertTrue($baseDir->hasChild('test'));
410
+ $test = $baseDir->getChild('test');
411
+ $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory', $test);
412
+ $this->assertTrue($test->hasChildren());
413
+ $this->assertTrue($test->hasChild('baz.txt'));
414
+ $this->assertVfsFile($test->getChild('baz.txt'), 'world');
415
+
416
+ $this->assertTrue($test->hasChild('foo'));
417
+ $foo = $test->getChild('foo');
418
+ $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory', $foo);
419
+ $this->assertTrue($foo->hasChildren());
420
+ $this->assertTrue($foo->hasChild('test.txt'));
421
+ $this->assertVfsFile($foo->getChild('test.txt'), 'hello');
422
+ }
423
+
424
+ /**
425
+ * @test
426
+ * @group issue_20
427
+ * @since 0.11.0
428
+ */
429
+ public function createWorksRecursivelyWithRoot()
430
+ {
431
+ $root = vfsStream::setup();
432
+ $this->assertSame($root,
433
+ vfsStream::create(array('test' => array('foo' => array('test.txt' => 'hello'),
434
+ 'baz.txt' => 'world'
435
+ )
436
+ )
437
+ )
438
+ );
439
+ $this->assertTrue($root->hasChildren());
440
+ $this->assertTrue($root->hasChild('test'));
441
+ $test = $root->getChild('test');
442
+ $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory', $test);
443
+ $this->assertTrue($test->hasChildren());
444
+ $this->assertTrue($test->hasChild('baz.txt'));
445
+ $this->assertVfsFile($test->getChild('baz.txt'), 'world');
446
+
447
+ $this->assertTrue($test->hasChild('foo'));
448
+ $foo = $test->getChild('foo');
449
+ $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamDirectory', $foo);
450
+ $this->assertTrue($foo->hasChildren());
451
+ $this->assertTrue($foo->hasChild('test.txt'));
452
+ $this->assertVfsFile($foo->getChild('test.txt'), 'hello');
453
+ }
454
+
455
+ /**
456
+ * @test
457
+ * @group issue_20
458
+ * @since 0.10.0
459
+ */
460
+ public function createStringsAreTurnedIntoFilesWithContent()
461
+ {
462
+ $baseDir = vfsStream::create(array('test.txt' => 'some content'), new vfsStreamDirectory('baseDir'));
463
+ $this->assertTrue($baseDir->hasChildren());
464
+ $this->assertTrue($baseDir->hasChild('test.txt'));
465
+ $this->assertVfsFile($baseDir->getChild('test.txt'), 'some content');
466
+ }
467
+
468
+ /**
469
+ * @test
470
+ * @group issue_20
471
+ * @since 0.11.0
472
+ */
473
+ public function createStringsAreTurnedIntoFilesWithContentWithRoot()
474
+ {
475
+ $root = vfsStream::setup();
476
+ $this->assertSame($root,
477
+ vfsStream::create(array('test.txt' => 'some content'))
478
+ );
479
+ $this->assertTrue($root->hasChildren());
480
+ $this->assertTrue($root->hasChild('test.txt'));
481
+ $this->assertVfsFile($root->getChild('test.txt'), 'some content');
482
+ }
483
+
484
+ /**
485
+ * @test
486
+ * @group issue_20
487
+ * @since 0.11.0
488
+ */
489
+ public function createCastsNumericDirectoriesToStrings()
490
+ {
491
+ $baseDir = vfsStream::create(array(2011 => array ('test.txt' => 'some content')), new vfsStreamDirectory('baseDir'));
492
+ $this->assertTrue($baseDir->hasChild('2011'));
493
+
494
+ $directory = $baseDir->getChild('2011');
495
+ $this->assertVfsFile($directory->getChild('test.txt'), 'some content');
496
+ }
497
+
498
+ /**
499
+ * @test
500
+ * @group issue_20
501
+ * @since 0.11.0
502
+ */
503
+ public function createCastsNumericDirectoriesToStringsWithRoot()
504
+ {
505
+ $root = vfsStream::setup();
506
+ $this->assertSame($root,
507
+ vfsStream::create(array(2011 => array ('test.txt' => 'some content')))
508
+ );
509
+ $this->assertTrue($root->hasChild('2011'));
510
+
511
+ $directory = $root->getChild('2011');
512
+ $this->assertVfsFile($directory->getChild('test.txt'), 'some content');
513
+ }
514
+
515
+ /**
516
+ * helper function for assertions on vfsStreamFile
517
+ *
518
+ * @param vfsStreamFile $file
519
+ * @param string $content
520
+ */
521
+ protected function assertVfsFile(vfsStreamFile $file, $content)
522
+ {
523
+ $this->assertInstanceOf('org\\bovigo\\vfs\\vfsStreamFile',
524
+ $file
525
+ );
526
+ $this->assertEquals($content,
527
+ $file->getContent()
528
+ );
529
+ }
530
+
531
+ /**
532
+ * @test
533
+ * @group issue_10
534
+ * @since 0.10.0
535
+ */
536
+ public function inspectWithContentGivesContentToVisitor()
537
+ {
538
+ $mockContent = $this->getMock('org\\bovigo\\vfs\\vfsStreamContent');
539
+ $mockVisitor = $this->getMock('org\\bovigo\\vfs\\visitor\\vfsStreamVisitor');
540
+ $mockVisitor->expects($this->once())
541
+ ->method('visit')
542
+ ->with($this->equalTo($mockContent))
543
+ ->will($this->returnValue($mockVisitor));
544
+ $this->assertSame($mockVisitor, vfsStream::inspect($mockVisitor, $mockContent));
545
+ }
546
+
547
+ /**
548
+ * @test
549
+ * @group issue_10
550
+ * @since 0.10.0
551
+ */
552
+ public function inspectWithoutContentGivesRootToVisitor()
553
+ {
554
+ $root = vfsStream::setup();
555
+ $mockVisitor = $this->getMock('org\\bovigo\\vfs\\visitor\\vfsStreamVisitor');
556
+ $mockVisitor->expects($this->once())
557
+ ->method('visitDirectory')
558
+ ->with($this->equalTo($root))
559
+ ->will($this->returnValue($mockVisitor));
560
+ $this->assertSame($mockVisitor, vfsStream::inspect($mockVisitor));
561
+ }
562
+
563
+ /**
564
+ * @test
565
+ * @group issue_10
566
+ * @expectedException \InvalidArgumentException
567
+ * @since 0.10.0
568
+ */
569
+ public function inspectWithoutContentAndWithoutRootThrowsInvalidArgumentException()
570
+ {
571
+ $mockVisitor = $this->getMock('org\\bovigo\\vfs\\visitor\\vfsStreamVisitor');
572
+ $mockVisitor->expects($this->never())
573
+ ->method('visit');
574
+ $mockVisitor->expects($this->never())
575
+ ->method('visitDirectory');
576
+ vfsStream::inspect($mockVisitor);
577
+ }
578
+
579
+ /**
580
+ * returns path to file system copy resource directory
581
+ *
582
+ * @return string
583
+ */
584
+ protected function getFileSystemCopyDir()
585
+ {
586
+ return realpath(dirname(__FILE__) . '/../../../../resources/filesystemcopy');
587
+ }
588
+
589
+ /**
590
+ * @test
591
+ * @group issue_4
592
+ * @expectedException \InvalidArgumentException
593
+ * @since 0.11.0
594
+ */
595
+ public function copyFromFileSystemThrowsExceptionIfNoBaseDirGivenAndNoRootSet()
596
+ {
597
+ vfsStream::copyFromFileSystem($this->getFileSystemCopyDir());
598
+ }
599
+
600
+ /**
601
+ * @test
602
+ * @group issue_4
603
+ * @since 0.11.0
604
+ */
605
+ public function copyFromEmptyFolder()
606
+ {
607
+ $baseDir = vfsStream::copyFromFileSystem($this->getFileSystemCopyDir() . '/emptyFolder',
608
+ vfsStream::newDirectory('test')
609
+ );
610
+ $baseDir->removeChild('.gitignore');
611
+ $this->assertFalse($baseDir->hasChildren());
612
+ }
613
+
614
+ /**
615
+ * @test
616
+ * @group issue_4
617
+ * @since 0.11.0
618
+ */
619
+ public function copyFromEmptyFolderWithRoot()
620
+ {
621
+ $root = vfsStream::setup();
622
+ $this->assertEquals($root,
623
+ vfsStream::copyFromFileSystem($this->getFileSystemCopyDir() . '/emptyFolder')
624
+ );
625
+ $root->removeChild('.gitignore');
626
+ $this->assertFalse($root->hasChildren());
627
+ }
628
+
629
+ /**
630
+ * @test
631
+ * @group issue_4
632
+ * @since 0.11.0
633
+ */
634
+ public function copyFromWithSubFolders()
635
+ {
636
+ $baseDir = vfsStream::copyFromFileSystem($this->getFileSystemCopyDir(),
637
+ vfsStream::newDirectory('test'),
638
+ 3
639
+ );
640
+ $this->assertTrue($baseDir->hasChildren());
641
+ $this->assertTrue($baseDir->hasChild('emptyFolder'));
642
+ $this->assertTrue($baseDir->hasChild('withSubfolders'));
643
+ $subfolderDir = $baseDir->getChild('withSubfolders');
644
+ $this->assertTrue($subfolderDir->hasChild('subfolder1'));
645
+ $this->assertTrue($subfolderDir->getChild('subfolder1')->hasChild('file1.txt'));
646
+ $this->assertVfsFile($subfolderDir->getChild('subfolder1/file1.txt'), ' ');
647
+ $this->assertTrue($subfolderDir->hasChild('subfolder2'));
648
+ $this->assertTrue($subfolderDir->hasChild('aFile.txt'));
649
+ $this->assertVfsFile($subfolderDir->getChild('aFile.txt'), 'foo');
650
+ }
651
+
652
+ /**
653
+ * @test
654
+ * @group issue_4
655
+ * @since 0.11.0
656
+ */
657
+ public function copyFromWithSubFoldersWithRoot()
658
+ {
659
+ $root = vfsStream::setup();
660
+ $this->assertEquals($root,
661
+ vfsStream::copyFromFileSystem($this->getFileSystemCopyDir(),
662
+ null,
663
+ 3
664
+ )
665
+ );
666
+ $this->assertTrue($root->hasChildren());
667
+ $this->assertTrue($root->hasChild('emptyFolder'));
668
+ $this->assertTrue($root->hasChild('withSubfolders'));
669
+ $subfolderDir = $root->getChild('withSubfolders');
670
+ $this->assertTrue($subfolderDir->hasChild('subfolder1'));
671
+ $this->assertTrue($subfolderDir->getChild('subfolder1')->hasChild('file1.txt'));
672
+ $this->assertVfsFile($subfolderDir->getChild('subfolder1/file1.txt'), ' ');
673
+ $this->assertTrue($subfolderDir->hasChild('subfolder2'));
674
+ $this->assertTrue($subfolderDir->hasChild('aFile.txt'));
675
+ $this->assertVfsFile($subfolderDir->getChild('aFile.txt'), 'foo');
676
+ }
677
+
678
+ /**
679
+ * @test
680
+ * @group issue_4
681
+ * @group issue_29
682
+ * @since 0.11.2
683
+ */
684
+ public function copyFromPreservesFilePermissions()
685
+ {
686
+ if (DIRECTORY_SEPARATOR !== '/') {
687
+ $this->markTestSkipped('Only applicable on Linux style systems.');
688
+ }
689
+
690
+ $copyDir = $this->getFileSystemCopyDir();
691
+ $root = vfsStream::setup();
692
+ $this->assertEquals($root,
693
+ vfsStream::copyFromFileSystem($copyDir,
694
+ null
695
+ )
696
+ );
697
+ $this->assertEquals(fileperms($copyDir . '/withSubfolders') - vfsStreamContent::TYPE_DIR,
698
+ $root->getChild('withSubfolders')
699
+ ->getPermissions()
700
+ );
701
+ $this->assertEquals(fileperms($copyDir . '/withSubfolders/aFile.txt') - vfsStreamContent::TYPE_FILE,
702
+ $root->getChild('withSubfolders/aFile.txt')
703
+ ->getPermissions()
704
+ );
705
+ }
706
+
707
+ /**
708
+ * To test this the max file size is reduced to something reproduceable.
709
+ *
710
+ * @test
711
+ * @group issue_91
712
+ * @since 1.5.0
713
+ */
714
+ public function copyFromFileSystemMocksLargeFiles()
715
+ {
716
+ if (DIRECTORY_SEPARATOR !== '/') {
717
+ $this->markTestSkipped('Only applicable on Linux style systems.');
718
+ }
719
+
720
+ $copyDir = $this->getFileSystemCopyDir();
721
+ $root = vfsStream::setup();
722
+ vfsStream::copyFromFileSystem($copyDir, $root, 3);
723
+ $this->assertEquals(
724
+ ' ',
725
+ $root->getChild('withSubfolders/subfolder1/file1.txt')->getContent()
726
+ );
727
+ }
728
+ }
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamUmaskTestCase.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for umask settings.
13
+ *
14
+ * @group permissions
15
+ * @group umask
16
+ * @since 0.8.0
17
+ */
18
+ class vfsStreamUmaskTestCase extends \PHPUnit_Framework_TestCase
19
+ {
20
+ /**
21
+ * set up test environment
22
+ */
23
+ public function setUp()
24
+ {
25
+ vfsStream::umask(0000);
26
+ }
27
+
28
+ /**
29
+ * clean up test environment
30
+ */
31
+ public function tearDown()
32
+ {
33
+ vfsStream::umask(0000);
34
+ }
35
+
36
+ /**
37
+ * @test
38
+ */
39
+ public function gettingUmaskSettingDoesNotChangeUmaskSetting()
40
+ {
41
+ $this->assertEquals(vfsStream::umask(),
42
+ vfsStream::umask()
43
+ );
44
+ $this->assertEquals(0000,
45
+ vfsStream::umask()
46
+ );
47
+ }
48
+
49
+ /**
50
+ * @test
51
+ */
52
+ public function changingUmaskSettingReturnsOldUmaskSetting()
53
+ {
54
+ $this->assertEquals(0000,
55
+ vfsStream::umask(0022)
56
+ );
57
+ $this->assertEquals(0022,
58
+ vfsStream::umask()
59
+ );
60
+ }
61
+
62
+ /**
63
+ * @test
64
+ */
65
+ public function createFileWithDefaultUmaskSetting()
66
+ {
67
+ $file = new vfsStreamFile('foo');
68
+ $this->assertEquals(0666, $file->getPermissions());
69
+ }
70
+
71
+ /**
72
+ * @test
73
+ */
74
+ public function createFileWithDifferentUmaskSetting()
75
+ {
76
+ vfsStream::umask(0022);
77
+ $file = new vfsStreamFile('foo');
78
+ $this->assertEquals(0644, $file->getPermissions());
79
+ }
80
+
81
+ /**
82
+ * @test
83
+ */
84
+ public function createDirectoryWithDefaultUmaskSetting()
85
+ {
86
+ $directory = new vfsStreamDirectory('foo');
87
+ $this->assertEquals(0777, $directory->getPermissions());
88
+ }
89
+
90
+ /**
91
+ * @test
92
+ */
93
+ public function createDirectoryWithDifferentUmaskSetting()
94
+ {
95
+ vfsStream::umask(0022);
96
+ $directory = new vfsStreamDirectory('foo');
97
+ $this->assertEquals(0755, $directory->getPermissions());
98
+ }
99
+
100
+ /**
101
+ * @test
102
+ */
103
+ public function createFileUsingStreamWithDefaultUmaskSetting()
104
+ {
105
+ $root = vfsStream::setup();
106
+ file_put_contents(vfsStream::url('root/newfile.txt'), 'file content');
107
+ $this->assertEquals(0666, $root->getChild('newfile.txt')->getPermissions());
108
+ }
109
+
110
+ /**
111
+ * @test
112
+ */
113
+ public function createFileUsingStreamWithDifferentUmaskSetting()
114
+ {
115
+ $root = vfsStream::setup();
116
+ vfsStream::umask(0022);
117
+ file_put_contents(vfsStream::url('root/newfile.txt'), 'file content');
118
+ $this->assertEquals(0644, $root->getChild('newfile.txt')->getPermissions());
119
+ }
120
+
121
+ /**
122
+ * @test
123
+ */
124
+ public function createDirectoryUsingStreamWithDefaultUmaskSetting()
125
+ {
126
+ $root = vfsStream::setup();
127
+ mkdir(vfsStream::url('root/newdir'));
128
+ $this->assertEquals(0777, $root->getChild('newdir')->getPermissions());
129
+ }
130
+
131
+ /**
132
+ * @test
133
+ */
134
+ public function createDirectoryUsingStreamWithDifferentUmaskSetting()
135
+ {
136
+ $root = vfsStream::setup();
137
+ vfsStream::umask(0022);
138
+ mkdir(vfsStream::url('root/newdir'));
139
+ $this->assertEquals(0755, $root->getChild('newdir')->getPermissions());
140
+ }
141
+
142
+ /**
143
+ * @test
144
+ */
145
+ public function createDirectoryUsingStreamWithExplicit0()
146
+ {
147
+ $root = vfsStream::setup();
148
+ vfsStream::umask(0022);
149
+ mkdir(vfsStream::url('root/newdir'), null);
150
+ $this->assertEquals(0000, $root->getChild('newdir')->getPermissions());
151
+ }
152
+
153
+ /**
154
+ * @test
155
+ *
156
+ */
157
+ public function createDirectoryUsingStreamWithDifferentUmaskSettingButExplicit0777()
158
+ {
159
+ $root = vfsStream::setup();
160
+ vfsStream::umask(0022);
161
+ mkdir(vfsStream::url('root/newdir'), 0777);
162
+ $this->assertEquals(0755, $root->getChild('newdir')->getPermissions());
163
+ }
164
+
165
+ /**
166
+ * @test
167
+ */
168
+ public function createDirectoryUsingStreamWithDifferentUmaskSettingButExplicitModeRequestedByCall()
169
+ {
170
+ $root = vfsStream::setup();
171
+ vfsStream::umask(0022);
172
+ mkdir(vfsStream::url('root/newdir'), 0700);
173
+ $this->assertEquals(0700, $root->getChild('newdir')->getPermissions());
174
+ }
175
+
176
+ /**
177
+ * @test
178
+ */
179
+ public function defaultUmaskSettingDoesNotInfluenceSetup()
180
+ {
181
+ $root = vfsStream::setup();
182
+ $this->assertEquals(0777, $root->getPermissions());
183
+ }
184
+
185
+ /**
186
+ * @test
187
+ */
188
+ public function umaskSettingShouldBeRespectedBySetup()
189
+ {
190
+ vfsStream::umask(0022);
191
+ $root = vfsStream::setup();
192
+ $this->assertEquals(0755, $root->getPermissions());
193
+ }
194
+ }
195
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperAlreadyRegisteredTestCase.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Helper class for the test.
13
+ */
14
+ class TestvfsStreamWrapper extends vfsStreamWrapper
15
+ {
16
+ /**
17
+ * unregisters vfsStreamWrapper
18
+ */
19
+ public static function unregister()
20
+ {
21
+ if (in_array(vfsStream::SCHEME, stream_get_wrappers()) === true) {
22
+ stream_wrapper_unregister(vfsStream::SCHEME);
23
+ }
24
+
25
+ self::$registered = false;
26
+ }
27
+ }
28
+ /**
29
+ * Test for org\bovigo\vfs\vfsStreamWrapper.
30
+ */
31
+ class vfsStreamWrapperAlreadyRegisteredTestCase extends \PHPUnit_Framework_TestCase
32
+ {
33
+ /**
34
+ * set up test environment
35
+ */
36
+ public function setUp()
37
+ {
38
+ TestvfsStreamWrapper::unregister();
39
+ $mock = $this->getMock('org\\bovigo\\vfs\\vfsStreamWrapper');
40
+ stream_wrapper_register(vfsStream::SCHEME, get_class($mock));
41
+ }
42
+
43
+ /**
44
+ * clean up test environment
45
+ */
46
+ public function tearDown()
47
+ {
48
+ TestvfsStreamWrapper::unregister();
49
+ }
50
+
51
+ /**
52
+ * registering the stream wrapper when another stream wrapper is already
53
+ * registered for the vfs scheme should throw an exception
54
+ *
55
+ * @test
56
+ * @expectedException org\bovigo\vfs\vfsStreamException
57
+ */
58
+ public function registerOverAnotherStreamWrapper()
59
+ {
60
+ vfsStreamWrapper::register();
61
+ }
62
+ }
63
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperBaseTestCase.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for org\bovigo\vfs\vfsStreamWrapper.
13
+ */
14
+ abstract class vfsStreamWrapperBaseTestCase extends \PHPUnit_Framework_TestCase
15
+ {
16
+ /**
17
+ * root directory
18
+ *
19
+ * @var vfsStreamDirectory
20
+ */
21
+ protected $foo;
22
+ /**
23
+ * URL of root directory
24
+ *
25
+ * @var string
26
+ */
27
+ protected $fooURL;
28
+ /**
29
+ * sub directory
30
+ *
31
+ * @var vfsStreamDirectory
32
+ */
33
+ protected $bar;
34
+ /**
35
+ * URL of sub directory
36
+ *
37
+ * @var string
38
+ */
39
+ protected $barURL;
40
+ /**
41
+ * a file
42
+ *
43
+ * @var vfsStreamFile
44
+ */
45
+ protected $baz1;
46
+ /**
47
+ * URL of file 1
48
+ *
49
+ * @var string
50
+ */
51
+ protected $baz1URL;
52
+ /**
53
+ * another file
54
+ *
55
+ * @var vfsStreamFile
56
+ */
57
+ protected $baz2;
58
+ /**
59
+ * URL of file 2
60
+ *
61
+ * @var string
62
+ */
63
+ protected $baz2URL;
64
+
65
+ /**
66
+ * set up test environment
67
+ */
68
+ public function setUp()
69
+ {
70
+ $this->fooURL = vfsStream::url('foo');
71
+ $this->barURL = vfsStream::url('foo/bar');
72
+ $this->baz1URL = vfsStream::url('foo/bar/baz1');
73
+ $this->baz2URL = vfsStream::url('foo/baz2');
74
+ $this->foo = new vfsStreamDirectory('foo');
75
+ $this->bar = new vfsStreamDirectory('bar');
76
+ $this->baz1 = vfsStream::newFile('baz1')
77
+ ->lastModified(300)
78
+ ->lastAccessed(300)
79
+ ->lastAttributeModified(300)
80
+ ->withContent('baz 1');
81
+ $this->baz2 = vfsStream::newFile('baz2')
82
+ ->withContent('baz2')
83
+ ->lastModified(400)
84
+ ->lastAccessed(400)
85
+ ->lastAttributeModified(400);
86
+ $this->bar->addChild($this->baz1);
87
+ $this->foo->addChild($this->bar);
88
+ $this->foo->addChild($this->baz2);
89
+ $this->foo->lastModified(100)
90
+ ->lastAccessed(100)
91
+ ->lastAttributeModified(100);
92
+ $this->bar->lastModified(200)
93
+ ->lastAccessed(100)
94
+ ->lastAttributeModified(100);
95
+ vfsStreamWrapper::register();
96
+ vfsStreamWrapper::setRoot($this->foo);
97
+ }
98
+ }
99
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperDirSeparatorTestCase.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test that using windows directory separator works correct.
13
+ *
14
+ * @since 0.9.0
15
+ * @group issue_8
16
+ */
17
+ class vfsStreamWrapperDirSeparatorTestCase extends \PHPUnit_Framework_TestCase
18
+ {
19
+ /**
20
+ * root diretory
21
+ *
22
+ * @var vfsStreamDirectory
23
+ */
24
+ protected $root;
25
+
26
+ /**
27
+ * set up test environment
28
+ */
29
+ public function setUp()
30
+ {
31
+ $this->root = vfsStream::setup();
32
+ }
33
+
34
+ /**
35
+ * @test
36
+ */
37
+ public function fileCanBeAccessedUsingWinDirSeparator()
38
+ {
39
+ vfsStream::newFile('foo/bar/baz.txt')
40
+ ->at($this->root)
41
+ ->withContent('test');
42
+ $this->assertEquals('test', file_get_contents('vfs://root/foo\bar\baz.txt'));
43
+ }
44
+
45
+
46
+ /**
47
+ * @test
48
+ */
49
+ public function directoryCanBeCreatedUsingWinDirSeparator()
50
+ {
51
+ mkdir('vfs://root/dir\bar\foo', true, 0777);
52
+ $this->assertTrue($this->root->hasChild('dir'));
53
+ $this->assertTrue($this->root->getChild('dir')->hasChild('bar'));
54
+ $this->assertTrue($this->root->getChild('dir/bar')->hasChild('foo'));
55
+ }
56
+
57
+ /**
58
+ * @test
59
+ */
60
+ public function directoryExitsTestUsingTrailingWinDirSeparator()
61
+ {
62
+ $structure = array(
63
+ 'dir' => array(
64
+ 'bar' => array(
65
+ )
66
+ )
67
+ );
68
+ vfsStream::create($structure, $this->root);
69
+
70
+ $this->assertTrue(file_exists(vfsStream::url('root/').'dir\\'));
71
+ }
72
+ }
73
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperDirTestCase.php ADDED
@@ -0,0 +1,460 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ require_once __DIR__ . '/vfsStreamWrapperBaseTestCase.php';
12
+ /**
13
+ * Test for org\bovigo\vfs\vfsStreamWrapper around mkdir().
14
+ *
15
+ * @package bovigo_vfs
16
+ * @subpackage test
17
+ */
18
+ class vfsStreamWrapperMkDirTestCase extends vfsStreamWrapperBaseTestCase
19
+ {
20
+ /**
21
+ * mkdir() should not overwrite existing root
22
+ *
23
+ * @test
24
+ */
25
+ public function mkdirNoNewRoot()
26
+ {
27
+ $this->assertFalse(mkdir(vfsStream::url('another')));
28
+ $this->assertEquals(2, count($this->foo->getChildren()));
29
+ $this->assertSame($this->foo, vfsStreamWrapper::getRoot());
30
+ }
31
+
32
+ /**
33
+ * mkdir() should not overwrite existing root
34
+ *
35
+ * @test
36
+ */
37
+ public function mkdirNoNewRootRecursively()
38
+ {
39
+ $this->assertFalse(mkdir(vfsStream::url('another/more'), 0777, true));
40
+ $this->assertEquals(2, count($this->foo->getChildren()));
41
+ $this->assertSame($this->foo, vfsStreamWrapper::getRoot());
42
+ }
43
+
44
+ /**
45
+ * assert that mkdir() creates the correct directory structure
46
+ *
47
+ * @test
48
+ * @group permissions
49
+ */
50
+ public function mkdirNonRecursively()
51
+ {
52
+ $this->assertFalse(mkdir($this->barURL . '/another/more'));
53
+ $this->assertEquals(2, count($this->foo->getChildren()));
54
+ $this->assertTrue(mkdir($this->fooURL . '/another'));
55
+ $this->assertEquals(3, count($this->foo->getChildren()));
56
+ $this->assertEquals(0777, $this->foo->getChild('another')->getPermissions());
57
+ }
58
+
59
+ /**
60
+ * assert that mkdir() creates the correct directory structure
61
+ *
62
+ * @test
63
+ * @group permissions
64
+ */
65
+ public function mkdirRecursively()
66
+ {
67
+ $this->assertTrue(mkdir($this->fooURL . '/another/more', 0777, true));
68
+ $this->assertEquals(3, count($this->foo->getChildren()));
69
+ $another = $this->foo->getChild('another');
70
+ $this->assertTrue($another->hasChild('more'));
71
+ $this->assertEquals(0777, $this->foo->getChild('another')->getPermissions());
72
+ $this->assertEquals(0777, $this->foo->getChild('another')->getChild('more')->getPermissions());
73
+ }
74
+
75
+ /**
76
+ * @test
77
+ * @group issue_9
78
+ * @since 0.9.0
79
+ */
80
+ public function mkdirWithDots()
81
+ {
82
+ $this->assertTrue(mkdir($this->fooURL . '/another/../more/.', 0777, true));
83
+ $this->assertEquals(3, count($this->foo->getChildren()));
84
+ $this->assertTrue($this->foo->hasChild('more'));
85
+ }
86
+
87
+ /**
88
+ * no root > new directory becomes root
89
+ *
90
+ * @test
91
+ * @group permissions
92
+ */
93
+ public function mkdirWithoutRootCreatesNewRoot()
94
+ {
95
+ vfsStreamWrapper::register();
96
+ $this->assertTrue(@mkdir(vfsStream::url('foo')));
97
+ $this->assertEquals(vfsStreamContent::TYPE_DIR, vfsStreamWrapper::getRoot()->getType());
98
+ $this->assertEquals('foo', vfsStreamWrapper::getRoot()->getName());
99
+ $this->assertEquals(0777, vfsStreamWrapper::getRoot()->getPermissions());
100
+ }
101
+
102
+ /**
103
+ * trying to create a subdirectory of a file should not work
104
+ *
105
+ * @test
106
+ */
107
+ public function mkdirOnFileReturnsFalse()
108
+ {
109
+ $this->assertFalse(mkdir($this->baz1URL . '/another/more', 0777, true));
110
+ }
111
+
112
+ /**
113
+ * assert that mkdir() creates the correct directory structure
114
+ *
115
+ * @test
116
+ * @group permissions
117
+ */
118
+ public function mkdirNonRecursivelyDifferentPermissions()
119
+ {
120
+ $this->assertTrue(mkdir($this->fooURL . '/another', 0755));
121
+ $this->assertEquals(0755, $this->foo->getChild('another')->getPermissions());
122
+ }
123
+
124
+ /**
125
+ * assert that mkdir() creates the correct directory structure
126
+ *
127
+ * @test
128
+ * @group permissions
129
+ */
130
+ public function mkdirRecursivelyDifferentPermissions()
131
+ {
132
+ $this->assertTrue(mkdir($this->fooURL . '/another/more', 0755, true));
133
+ $this->assertEquals(3, count($this->foo->getChildren()));
134
+ $another = $this->foo->getChild('another');
135
+ $this->assertTrue($another->hasChild('more'));
136
+ $this->assertEquals(0755, $this->foo->getChild('another')->getPermissions());
137
+ $this->assertEquals(0755, $this->foo->getChild('another')->getChild('more')->getPermissions());
138
+ }
139
+
140
+ /**
141
+ * assert that mkdir() creates the correct directory structure
142
+ *
143
+ * @test
144
+ * @group permissions
145
+ */
146
+ public function mkdirRecursivelyUsesDefaultPermissions()
147
+ {
148
+ $this->foo->chmod(0700);
149
+ $this->assertTrue(mkdir($this->fooURL . '/another/more', 0777, true));
150
+ $this->assertEquals(3, count($this->foo->getChildren()));
151
+ $another = $this->foo->getChild('another');
152
+ $this->assertTrue($another->hasChild('more'));
153
+ $this->assertEquals(0777, $this->foo->getChild('another')->getPermissions());
154
+ $this->assertEquals(0777, $this->foo->getChild('another')->getChild('more')->getPermissions());
155
+ }
156
+
157
+ /**
158
+ * no root > new directory becomes root
159
+ *
160
+ * @test
161
+ * @group permissions
162
+ */
163
+ public function mkdirWithoutRootCreatesNewRootDifferentPermissions()
164
+ {
165
+ vfsStreamWrapper::register();
166
+ $this->assertTrue(@mkdir(vfsStream::url('foo'), 0755));
167
+ $this->assertEquals(vfsStreamContent::TYPE_DIR, vfsStreamWrapper::getRoot()->getType());
168
+ $this->assertEquals('foo', vfsStreamWrapper::getRoot()->getName());
169
+ $this->assertEquals(0755, vfsStreamWrapper::getRoot()->getPermissions());
170
+ }
171
+
172
+ /**
173
+ * no root > new directory becomes root
174
+ *
175
+ * @test
176
+ * @group permissions
177
+ */
178
+ public function mkdirWithoutRootCreatesNewRootWithDefaultPermissions()
179
+ {
180
+ vfsStreamWrapper::register();
181
+ $this->assertTrue(@mkdir(vfsStream::url('foo')));
182
+ $this->assertEquals(vfsStreamContent::TYPE_DIR, vfsStreamWrapper::getRoot()->getType());
183
+ $this->assertEquals('foo', vfsStreamWrapper::getRoot()->getName());
184
+ $this->assertEquals(0777, vfsStreamWrapper::getRoot()->getPermissions());
185
+ }
186
+
187
+ /**
188
+ * @test
189
+ * @group permissions
190
+ * @group bug_15
191
+ */
192
+ public function mkdirDirCanNotCreateNewDirInNonWritingDirectory()
193
+ {
194
+ vfsStreamWrapper::register();
195
+ vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
196
+ vfsStreamWrapper::getRoot()->addChild(new vfsStreamDirectory('restrictedFolder', 0000));
197
+ $this->assertFalse(is_writable(vfsStream::url('root/restrictedFolder/')));
198
+ $this->assertFalse(mkdir(vfsStream::url('root/restrictedFolder/newFolder')));
199
+ $this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('restrictedFolder/newFolder'));
200
+ }
201
+
202
+ /**
203
+ * @test
204
+ * @group issue_28
205
+ */
206
+ public function mkDirShouldNotOverwriteExistingDirectories()
207
+ {
208
+ vfsStream::setup('root');
209
+ $dir = vfsStream::url('root/dir');
210
+ $this->assertTrue(mkdir($dir));
211
+ $this->assertFalse(@mkdir($dir));
212
+ }
213
+
214
+ /**
215
+ * @test
216
+ * @group issue_28
217
+ * @expectedException PHPUnit_Framework_Error
218
+ * @expectedExceptionMessage mkdir(): Path vfs://root/dir exists
219
+ */
220
+ public function mkDirShouldNotOverwriteExistingDirectoriesAndTriggerE_USER_WARNING()
221
+ {
222
+ vfsStream::setup('root');
223
+ $dir = vfsStream::url('root/dir');
224
+ $this->assertTrue(mkdir($dir));
225
+ $this->assertFalse(mkdir($dir));
226
+ }
227
+
228
+ /**
229
+ * @test
230
+ * @group issue_28
231
+ */
232
+ public function mkDirShouldNotOverwriteExistingFiles()
233
+ {
234
+ $root = vfsStream::setup('root');
235
+ vfsStream::newFile('test.txt')->at($root);
236
+ $this->assertFalse(@mkdir(vfsStream::url('root/test.txt')));
237
+ }
238
+
239
+ /**
240
+ * @test
241
+ * @group issue_28
242
+ * @expectedException PHPUnit_Framework_Error
243
+ * @expectedExceptionMessage mkdir(): Path vfs://root/test.txt exists
244
+ */
245
+ public function mkDirShouldNotOverwriteExistingFilesAndTriggerE_USER_WARNING()
246
+ {
247
+ $root = vfsStream::setup('root');
248
+ vfsStream::newFile('test.txt')->at($root);
249
+ $this->assertFalse(mkdir(vfsStream::url('root/test.txt')));
250
+ }
251
+
252
+ /**
253
+ * @test
254
+ * @group permissions
255
+ * @group bug_15
256
+ */
257
+ public function canNotIterateOverNonReadableDirectory()
258
+ {
259
+ vfsStreamWrapper::register();
260
+ vfsStreamWrapper::setRoot(new vfsStreamDirectory('root', 0000));
261
+ $this->assertFalse(@opendir(vfsStream::url('root')));
262
+ $this->assertFalse(@dir(vfsStream::url('root')));
263
+ }
264
+
265
+ /**
266
+ * assert is_dir() returns correct result
267
+ *
268
+ * @test
269
+ */
270
+ public function is_dir()
271
+ {
272
+ $this->assertTrue(is_dir($this->fooURL));
273
+ $this->assertTrue(is_dir($this->fooURL . '/.'));
274
+ $this->assertTrue(is_dir($this->barURL));
275
+ $this->assertTrue(is_dir($this->barURL . '/.'));
276
+ $this->assertFalse(is_dir($this->baz1URL));
277
+ $this->assertFalse(is_dir($this->baz2URL));
278
+ $this->assertFalse(is_dir($this->fooURL . '/another'));
279
+ $this->assertFalse(is_dir(vfsStream::url('another')));
280
+ }
281
+
282
+ /**
283
+ * can not unlink without root
284
+ *
285
+ * @test
286
+ */
287
+ public function canNotUnlinkDirectoryWithoutRoot()
288
+ {
289
+ vfsStreamWrapper::register();
290
+ $this->assertFalse(@rmdir(vfsStream::url('foo')));
291
+ }
292
+
293
+ /**
294
+ * rmdir() can not remove files
295
+ *
296
+ * @test
297
+ */
298
+ public function rmdirCanNotRemoveFiles()
299
+ {
300
+ $this->assertFalse(rmdir($this->baz1URL));
301
+ $this->assertFalse(rmdir($this->baz2URL));
302
+ }
303
+
304
+ /**
305
+ * rmdir() can not remove a non-existing directory
306
+ *
307
+ * @test
308
+ */
309
+ public function rmdirCanNotRemoveNonExistingDirectory()
310
+ {
311
+ $this->assertFalse(rmdir($this->fooURL . '/another'));
312
+ }
313
+
314
+ /**
315
+ * rmdir() can not remove non-empty directories
316
+ *
317
+ * @test
318
+ */
319
+ public function rmdirCanNotRemoveNonEmptyDirectory()
320
+ {
321
+ $this->assertFalse(rmdir($this->fooURL));
322
+ $this->assertFalse(rmdir($this->barURL));
323
+ }
324
+
325
+ /**
326
+ * @test
327
+ */
328
+ public function rmdirCanRemoveEmptyDirectory()
329
+ {
330
+ vfsStream::newDirectory('empty')->at($this->foo);
331
+ $this->assertTrue($this->foo->hasChild('empty'));
332
+ $this->assertTrue(rmdir($this->fooURL . '/empty'));
333
+ $this->assertFalse($this->foo->hasChild('empty'));
334
+ }
335
+
336
+ /**
337
+ * @test
338
+ */
339
+ public function rmdirCanRemoveEmptyDirectoryWithDot()
340
+ {
341
+ vfsStream::newDirectory('empty')->at($this->foo);
342
+ $this->assertTrue($this->foo->hasChild('empty'));
343
+ $this->assertTrue(rmdir($this->fooURL . '/empty/.'));
344
+ $this->assertFalse($this->foo->hasChild('empty'));
345
+ }
346
+
347
+ /**
348
+ * rmdir() can remove empty directories
349
+ *
350
+ * @test
351
+ */
352
+ public function rmdirCanRemoveEmptyRoot()
353
+ {
354
+ $this->foo->removeChild('bar');
355
+ $this->foo->removeChild('baz2');
356
+ $this->assertTrue(rmdir($this->fooURL));
357
+ $this->assertFalse(file_exists($this->fooURL)); // make sure statcache was cleared
358
+ $this->assertNull(vfsStreamWrapper::getRoot());
359
+ }
360
+
361
+ /**
362
+ * @test
363
+ * @group permissions
364
+ * @group bug_15
365
+ */
366
+ public function rmdirDirCanNotRemoveDirFromNonWritingDirectory()
367
+ {
368
+ vfsStreamWrapper::register();
369
+ vfsStreamWrapper::setRoot(new vfsStreamDirectory('root', 0000));
370
+ vfsStreamWrapper::getRoot()->addChild(new vfsStreamDirectory('nonRemovableFolder'));
371
+ $this->assertFalse(is_writable(vfsStream::url('root')));
372
+ $this->assertFalse(rmdir(vfsStream::url('root/nonRemovableFolder')));
373
+ $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild('nonRemovableFolder'));
374
+ }
375
+
376
+ /**
377
+ * @test
378
+ * @group permissions
379
+ * @group bug_17
380
+ */
381
+ public function issue17()
382
+ {
383
+ vfsStreamWrapper::register();
384
+ vfsStreamWrapper::setRoot(new vfsStreamDirectory('root', 0770));
385
+ vfsStreamWrapper::getRoot()->chgrp(vfsStream::GROUP_USER_1)
386
+ ->chown(vfsStream::OWNER_USER_1);
387
+ $this->assertFalse(mkdir(vfsStream::url('root/doesNotWork')));
388
+ $this->assertFalse(vfsStreamWrapper::getRoot()->hasChild('doesNotWork'));
389
+ }
390
+
391
+ /**
392
+ * @test
393
+ * @group bug_19
394
+ */
395
+ public function accessWithDoubleDotReturnsCorrectContent()
396
+ {
397
+ $this->assertEquals('baz2',
398
+ file_get_contents(vfsStream::url('foo/bar/../baz2'))
399
+ );
400
+ }
401
+
402
+ /**
403
+ * @test
404
+ * @since 0.11.0
405
+ * @group issue_23
406
+ */
407
+ public function unlinkCanNotRemoveNonEmptyDirectory()
408
+ {
409
+ try {
410
+ $this->assertFalse(unlink($this->barURL));
411
+ } catch (\PHPUnit_Framework_Error $fe) {
412
+ $this->assertEquals('unlink(vfs://foo/bar): Operation not permitted', $fe->getMessage());
413
+ }
414
+
415
+ $this->assertTrue($this->foo->hasChild('bar'));
416
+ $this->assertFileExists($this->barURL);
417
+ }
418
+
419
+ /**
420
+ * @test
421
+ * @since 0.11.0
422
+ * @group issue_23
423
+ */
424
+ public function unlinkCanNotRemoveEmptyDirectory()
425
+ {
426
+ vfsStream::newDirectory('empty')->at($this->foo);
427
+ try {
428
+ $this->assertTrue(unlink($this->fooURL . '/empty'));
429
+ } catch (\PHPUnit_Framework_Error $fe) {
430
+ $this->assertEquals('unlink(vfs://foo/empty): Operation not permitted', $fe->getMessage());
431
+ }
432
+
433
+ $this->assertTrue($this->foo->hasChild('empty'));
434
+ $this->assertFileExists($this->fooURL . '/empty');
435
+ }
436
+
437
+ /**
438
+ * @test
439
+ * @group issue_32
440
+ */
441
+ public function canCreateFolderOfSameNameAsParentFolder()
442
+ {
443
+ $root = vfsStream::setup('testFolder');
444
+ mkdir(vfsStream::url('testFolder') . '/testFolder/subTestFolder', 0777, true);
445
+ $this->assertTrue(file_exists(vfsStream::url('testFolder/testFolder/subTestFolder/.')));
446
+ }
447
+
448
+ /**
449
+ * @test
450
+ * @group issue_32
451
+ */
452
+ public function canRetrieveFolderOfSameNameAsParentFolder()
453
+ {
454
+ $root = vfsStream::setup('testFolder');
455
+ mkdir(vfsStream::url('testFolder') . '/testFolder/subTestFolder', 0777, true);
456
+ $this->assertTrue($root->hasChild('testFolder'));
457
+ $this->assertNotNull($root->getChild('testFolder'));
458
+ }
459
+ }
460
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperFileTestCase.php ADDED
@@ -0,0 +1,458 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ require_once __DIR__ . '/vfsStreamWrapperBaseTestCase.php';
12
+ /**
13
+ * Test for org\bovigo\vfs\vfsStreamWrapper.
14
+ */
15
+ class vfsStreamWrapperFileTestCase extends vfsStreamWrapperBaseTestCase
16
+ {
17
+ /**
18
+ * assert that file_get_contents() delivers correct file contents
19
+ *
20
+ * @test
21
+ */
22
+ public function file_get_contents()
23
+ {
24
+ $this->assertEquals('baz2', file_get_contents($this->baz2URL));
25
+ $this->assertEquals('baz 1', file_get_contents($this->baz1URL));
26
+ $this->assertFalse(@file_get_contents($this->barURL));
27
+ $this->assertFalse(@file_get_contents($this->fooURL));
28
+ }
29
+
30
+ /**
31
+ * @test
32
+ * @group permissions
33
+ * @group bug_15
34
+ */
35
+ public function file_get_contentsNonReadableFile()
36
+ {
37
+ vfsStreamWrapper::register();
38
+ vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
39
+ vfsStream::newFile('new.txt', 0000)->at(vfsStreamWrapper::getRoot())->withContent('content');
40
+ $this->assertEquals('', @file_get_contents(vfsStream::url('root/new.txt')));
41
+ }
42
+
43
+ /**
44
+ * assert that file_put_contents() delivers correct file contents
45
+ *
46
+ * @test
47
+ */
48
+ public function file_put_contentsExistingFile()
49
+ {
50
+ $this->assertEquals(14, file_put_contents($this->baz2URL, 'baz is not bar'));
51
+ $this->assertEquals('baz is not bar', $this->baz2->getContent());
52
+ $this->assertEquals(6, file_put_contents($this->baz1URL, 'foobar'));
53
+ $this->assertEquals('foobar', $this->baz1->getContent());
54
+ $this->assertFalse(@file_put_contents($this->barURL, 'This does not work.'));
55
+ $this->assertFalse(@file_put_contents($this->fooURL, 'This does not work, too.'));
56
+ }
57
+
58
+ /**
59
+ * @test
60
+ * @group permissions
61
+ * @group bug_15
62
+ */
63
+ public function file_put_contentsExistingFileNonWritableDirectory()
64
+ {
65
+ vfsStreamWrapper::register();
66
+ vfsStreamWrapper::setRoot(new vfsStreamDirectory('root', 0000));
67
+ vfsStream::newFile('new.txt')->at(vfsStreamWrapper::getRoot())->withContent('content');
68
+ $this->assertEquals(15, @file_put_contents(vfsStream::url('root/new.txt'), 'This does work.'));
69
+ $this->assertEquals('This does work.', file_get_contents(vfsStream::url('root/new.txt')));
70
+
71
+ }
72
+
73
+ /**
74
+ * @test
75
+ * @group permissions
76
+ * @group bug_15
77
+ */
78
+ public function file_put_contentsExistingNonWritableFile()
79
+ {
80
+ vfsStreamWrapper::register();
81
+ vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
82
+ vfsStream::newFile('new.txt', 0400)->at(vfsStreamWrapper::getRoot())->withContent('content');
83
+ $this->assertFalse(@file_put_contents(vfsStream::url('root/new.txt'), 'This does not work.'));
84
+ $this->assertEquals('content', file_get_contents(vfsStream::url('root/new.txt')));
85
+ }
86
+
87
+ /**
88
+ * assert that file_put_contents() delivers correct file contents
89
+ *
90
+ * @test
91
+ */
92
+ public function file_put_contentsNonExistingFile()
93
+ {
94
+ $this->assertEquals(14, file_put_contents($this->fooURL . '/baznot.bar', 'baz is not bar'));
95
+ $this->assertEquals(3, count($this->foo->getChildren()));
96
+ $this->assertEquals(14, file_put_contents($this->barURL . '/baznot.bar', 'baz is not bar'));
97
+ $this->assertEquals(2, count($this->bar->getChildren()));
98
+ }
99
+
100
+ /**
101
+ * @test
102
+ * @group permissions
103
+ * @group bug_15
104
+ */
105
+ public function file_put_contentsNonExistingFileNonWritableDirectory()
106
+ {
107
+ vfsStreamWrapper::register();
108
+ vfsStreamWrapper::setRoot(new vfsStreamDirectory('root', 0000));
109
+ $this->assertFalse(@file_put_contents(vfsStream::url('root/new.txt'), 'This does not work.'));
110
+ $this->assertFalse(file_exists(vfsStream::url('root/new.txt')));
111
+
112
+ }
113
+
114
+ /**
115
+ * using a file pointer should work without any problems
116
+ *
117
+ * @test
118
+ */
119
+ public function usingFilePointer()
120
+ {
121
+ $fp = fopen($this->baz1URL, 'r');
122
+ $this->assertEquals(0, ftell($fp));
123
+ $this->assertFalse(feof($fp));
124
+ $this->assertEquals(0, fseek($fp, 2));
125
+ $this->assertEquals(2, ftell($fp));
126
+ $this->assertEquals(0, fseek($fp, 1, SEEK_CUR));
127
+ $this->assertEquals(3, ftell($fp));
128
+ $this->assertEquals(0, fseek($fp, 1, SEEK_END));
129
+ $this->assertEquals(6, ftell($fp));
130
+ $this->assertTrue(feof($fp));
131
+ $this->assertEquals(0, fseek($fp, 2));
132
+ $this->assertFalse(feof($fp));
133
+ $this->assertEquals(2, ftell($fp));
134
+ $this->assertEquals('z', fread($fp, 1));
135
+ $this->assertEquals(3, ftell($fp));
136
+ $this->assertEquals(' 1', fread($fp, 8092));
137
+ $this->assertEquals(5, ftell($fp));
138
+ $this->assertTrue(fclose($fp));
139
+ }
140
+
141
+ /**
142
+ * assert is_file() returns correct result
143
+ *
144
+ * @test
145
+ */
146
+ public function is_file()
147
+ {
148
+ $this->assertFalse(is_file($this->fooURL));
149
+ $this->assertFalse(is_file($this->barURL));
150
+ $this->assertTrue(is_file($this->baz1URL));
151
+ $this->assertTrue(is_file($this->baz2URL));
152
+ $this->assertFalse(is_file($this->fooURL . '/another'));
153
+ $this->assertFalse(is_file(vfsStream::url('another')));
154
+ }
155
+
156
+ /**
157
+ * @test
158
+ * @group issue7
159
+ * @group issue13
160
+ */
161
+ public function issue13CanNotOverwriteFiles()
162
+ {
163
+ $vfsFile = vfsStream::url('foo/overwrite.txt');
164
+ file_put_contents($vfsFile, 'test');
165
+ file_put_contents($vfsFile, 'd');
166
+ $this->assertEquals('d', file_get_contents($vfsFile));
167
+ }
168
+
169
+ /**
170
+ * @test
171
+ * @group issue7
172
+ * @group issue13
173
+ */
174
+ public function appendContentIfOpenedWithModeA()
175
+ {
176
+ $vfsFile = vfsStream::url('foo/overwrite.txt');
177
+ file_put_contents($vfsFile, 'test');
178
+ $fp = fopen($vfsFile, 'ab');
179
+ fwrite($fp, 'd');
180
+ fclose($fp);
181
+ $this->assertEquals('testd', file_get_contents($vfsFile));
182
+ }
183
+
184
+ /**
185
+ * @test
186
+ * @group issue7
187
+ * @group issue13
188
+ */
189
+ public function canOverwriteNonExistingFileWithModeX()
190
+ {
191
+ $vfsFile = vfsStream::url('foo/overwrite.txt');
192
+ $fp = fopen($vfsFile, 'xb');
193
+ fwrite($fp, 'test');
194
+ fclose($fp);
195
+ $this->assertEquals('test', file_get_contents($vfsFile));
196
+ }
197
+
198
+ /**
199
+ * @test
200
+ * @group issue7
201
+ * @group issue13
202
+ */
203
+ public function canNotOverwriteExistingFileWithModeX()
204
+ {
205
+ $vfsFile = vfsStream::url('foo/overwrite.txt');
206
+ file_put_contents($vfsFile, 'test');
207
+ $this->assertFalse(@fopen($vfsFile, 'xb'));
208
+ $this->assertEquals('test', file_get_contents($vfsFile));
209
+ }
210
+
211
+ /**
212
+ * @test
213
+ * @group issue7
214
+ * @group issue13
215
+ */
216
+ public function canNotOpenNonExistingFileReadonly()
217
+ {
218
+ $this->assertFalse(@fopen(vfsStream::url('foo/doesNotExist.txt'), 'rb'));
219
+ }
220
+
221
+ /**
222
+ * @test
223
+ * @group issue7
224
+ * @group issue13
225
+ */
226
+ public function canNotOpenNonExistingFileReadAndWrite()
227
+ {
228
+ $this->assertFalse(@fopen(vfsStream::url('foo/doesNotExist.txt'), 'rb+'));
229
+ }
230
+
231
+ /**
232
+ * @test
233
+ * @group issue7
234
+ * @group issue13
235
+ */
236
+ public function canNotOpenWithIllegalMode()
237
+ {
238
+ $this->assertFalse(@fopen($this->baz2URL, 'invalid'));
239
+ }
240
+
241
+ /**
242
+ * @test
243
+ * @group issue7
244
+ * @group issue13
245
+ */
246
+ public function canNotWriteToReadOnlyFile()
247
+ {
248
+ $fp = fopen($this->baz2URL, 'rb');
249
+ $this->assertEquals('baz2', fread($fp, 4096));
250
+ $this->assertEquals(0, fwrite($fp, 'foo'));
251
+ fclose($fp);
252
+ $this->assertEquals('baz2', file_get_contents($this->baz2URL));
253
+ }
254
+
255
+ /**
256
+ * @test
257
+ * @group issue7
258
+ * @group issue13
259
+ */
260
+ public function canNotReadFromWriteOnlyFileWithModeW()
261
+ {
262
+ $fp = fopen($this->baz2URL, 'wb');
263
+ $this->assertEquals('', fread($fp, 4096));
264
+ $this->assertEquals(3, fwrite($fp, 'foo'));
265
+ fseek($fp, 0);
266
+ $this->assertEquals('', fread($fp, 4096));
267
+ fclose($fp);
268
+ $this->assertEquals('foo', file_get_contents($this->baz2URL));
269
+ }
270
+
271
+ /**
272
+ * @test
273
+ * @group issue7
274
+ * @group issue13
275
+ */
276
+ public function canNotReadFromWriteOnlyFileWithModeA()
277
+ {
278
+ $fp = fopen($this->baz2URL, 'ab');
279
+ $this->assertEquals('', fread($fp, 4096));
280
+ $this->assertEquals(3, fwrite($fp, 'foo'));
281
+ fseek($fp, 0);
282
+ $this->assertEquals('', fread($fp, 4096));
283
+ fclose($fp);
284
+ $this->assertEquals('baz2foo', file_get_contents($this->baz2URL));
285
+ }
286
+
287
+ /**
288
+ * @test
289
+ * @group issue7
290
+ * @group issue13
291
+ */
292
+ public function canNotReadFromWriteOnlyFileWithModeX()
293
+ {
294
+ $vfsFile = vfsStream::url('foo/modeXtest.txt');
295
+ $fp = fopen($vfsFile, 'xb');
296
+ $this->assertEquals('', fread($fp, 4096));
297
+ $this->assertEquals(3, fwrite($fp, 'foo'));
298
+ fseek($fp, 0);
299
+ $this->assertEquals('', fread($fp, 4096));
300
+ fclose($fp);
301
+ $this->assertEquals('foo', file_get_contents($vfsFile));
302
+ }
303
+
304
+ /**
305
+ * @test
306
+ * @group permissions
307
+ * @group bug_15
308
+ */
309
+ public function canNotRemoveFileFromDirectoryWithoutWritePermissions()
310
+ {
311
+ vfsStreamWrapper::register();
312
+ vfsStreamWrapper::setRoot(new vfsStreamDirectory('root', 0000));
313
+ vfsStream::newFile('new.txt')->at(vfsStreamWrapper::getRoot());
314
+ $this->assertFalse(unlink(vfsStream::url('root/new.txt')));
315
+ $this->assertTrue(file_exists(vfsStream::url('root/new.txt')));
316
+ }
317
+
318
+ /**
319
+ * @test
320
+ * @group issue_30
321
+ */
322
+ public function truncatesFileWhenOpenedWithModeW()
323
+ {
324
+ $vfsFile = vfsStream::url('foo/overwrite.txt');
325
+ file_put_contents($vfsFile, 'test');
326
+ $fp = fopen($vfsFile, 'wb');
327
+ $this->assertEquals('', file_get_contents($vfsFile));
328
+ fclose($fp);
329
+ }
330
+
331
+ /**
332
+ * @test
333
+ * @group issue_30
334
+ */
335
+ public function createsNonExistingFileWhenOpenedWithModeC()
336
+ {
337
+ $vfsFile = vfsStream::url('foo/tobecreated.txt');
338
+ $fp = fopen($vfsFile, 'cb');
339
+ fwrite($fp, 'some content');
340
+ $this->assertTrue($this->foo->hasChild('tobecreated.txt'));
341
+ fclose($fp);
342
+ $this->assertEquals('some content', file_get_contents($vfsFile));
343
+ }
344
+
345
+ /**
346
+ * @test
347
+ * @group issue_30
348
+ */
349
+ public function createsNonExistingFileWhenOpenedWithModeCplus()
350
+ {
351
+ $vfsFile = vfsStream::url('foo/tobecreated.txt');
352
+ $fp = fopen($vfsFile, 'cb+');
353
+ fwrite($fp, 'some content');
354
+ $this->assertTrue($this->foo->hasChild('tobecreated.txt'));
355
+ fclose($fp);
356
+ $this->assertEquals('some content', file_get_contents($vfsFile));
357
+ }
358
+
359
+ /**
360
+ * @test
361
+ * @group issue_30
362
+ */
363
+ public function doesNotTruncateFileWhenOpenedWithModeC()
364
+ {
365
+ $vfsFile = vfsStream::url('foo/overwrite.txt');
366
+ file_put_contents($vfsFile, 'test');
367
+ $fp = fopen($vfsFile, 'cb');
368
+ $this->assertEquals('test', file_get_contents($vfsFile));
369
+ fclose($fp);
370
+ }
371
+
372
+ /**
373
+ * @test
374
+ * @group issue_30
375
+ */
376
+ public function setsPointerToStartWhenOpenedWithModeC()
377
+ {
378
+ $vfsFile = vfsStream::url('foo/overwrite.txt');
379
+ file_put_contents($vfsFile, 'test');
380
+ $fp = fopen($vfsFile, 'cb');
381
+ $this->assertEquals(0, ftell($fp));
382
+ fclose($fp);
383
+ }
384
+
385
+ /**
386
+ * @test
387
+ * @group issue_30
388
+ */
389
+ public function doesNotTruncateFileWhenOpenedWithModeCplus()
390
+ {
391
+ $vfsFile = vfsStream::url('foo/overwrite.txt');
392
+ file_put_contents($vfsFile, 'test');
393
+ $fp = fopen($vfsFile, 'cb+');
394
+ $this->assertEquals('test', file_get_contents($vfsFile));
395
+ fclose($fp);
396
+ }
397
+
398
+ /**
399
+ * @test
400
+ * @group issue_30
401
+ */
402
+ public function setsPointerToStartWhenOpenedWithModeCplus()
403
+ {
404
+ $vfsFile = vfsStream::url('foo/overwrite.txt');
405
+ file_put_contents($vfsFile, 'test');
406
+ $fp = fopen($vfsFile, 'cb+');
407
+ $this->assertEquals(0, ftell($fp));
408
+ fclose($fp);
409
+ }
410
+
411
+ /**
412
+ * @test
413
+ */
414
+ public function cannotOpenExistingNonwritableFileWithModeA()
415
+ {
416
+ $this->baz1->chmod(0400);
417
+ $this->assertFalse(@fopen($this->baz1URL, 'a'));
418
+ }
419
+
420
+ /**
421
+ * @test
422
+ */
423
+ public function cannotOpenExistingNonwritableFileWithModeW()
424
+ {
425
+ $this->baz1->chmod(0400);
426
+ $this->assertFalse(@fopen($this->baz1URL, 'w'));
427
+ }
428
+
429
+ /**
430
+ * @test
431
+ */
432
+ public function cannotOpenNonReadableFileWithModeR()
433
+ {
434
+ $this->baz1->chmod(0);
435
+ $this->assertFalse(@fopen($this->baz1URL, 'r'));
436
+ }
437
+
438
+ /**
439
+ * @test
440
+ */
441
+ public function cannotRenameToNonWritableDir()
442
+ {
443
+ $this->bar->chmod(0);
444
+ $this->assertFalse(@rename($this->baz2URL, vfsStream::url('foo/bar/baz3')));
445
+ }
446
+
447
+ /**
448
+ * @test
449
+ * @group issue_38
450
+ */
451
+ public function cannotReadFileFromNonReadableDir()
452
+ {
453
+ $this->markTestSkipped("Issue #38.");
454
+ $this->bar->chmod(0);
455
+ $this->assertFalse(@file_get_contents($this->baz1URL));
456
+ }
457
+ }
458
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperFileTimesTestCase.php ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for org\bovigo\vfs\vfsStreamWrapper.
13
+ *
14
+ * @since 0.9.0
15
+ */
16
+ class vfsStreamWrapperFileTimesTestCase extends \PHPUnit_Framework_TestCase
17
+ {
18
+ /**
19
+ * URL of foo.txt file
20
+ *
21
+ * @var string
22
+ */
23
+ protected $fooUrl;
24
+ /**
25
+ * URL of bar directory
26
+ *
27
+ * @var string
28
+ */
29
+ protected $barUrl;
30
+ /**
31
+ * URL of baz.txt file
32
+ *
33
+ * @var string
34
+ */
35
+ protected $bazUrl;
36
+
37
+ /**
38
+ * set up test environment
39
+ */
40
+ public function setUp()
41
+ {
42
+ vfsStream::setup()
43
+ ->lastModified(50)
44
+ ->lastAccessed(50)
45
+ ->lastAttributeModified(50);
46
+ $this->fooUrl = vfsStream::url('root/foo.txt');
47
+ $this->barUrl = vfsStream::url('root/bar');
48
+ $this->bazUrl = vfsStream::url('root/bar/baz.txt');
49
+ }
50
+
51
+ /**
52
+ * helper assertion for the tests
53
+ *
54
+ * @param string $url url to check
55
+ * @param vfsStreamContent $content content to compare
56
+ */
57
+ protected function assertFileTimesEqualStreamTimes($url, vfsStreamContent $content)
58
+ {
59
+ $this->assertEquals(filemtime($url), $content->filemtime());
60
+ $this->assertEquals(fileatime($url), $content->fileatime());
61
+ $this->assertEquals(filectime($url), $content->filectime());
62
+ }
63
+
64
+ /**
65
+ * @test
66
+ * @group issue_7
67
+ * @group issue_26
68
+ */
69
+ public function openFileChangesAttributeTimeOnly()
70
+ {
71
+ $file = vfsStream::newFile('foo.txt')
72
+ ->withContent('test')
73
+ ->at(vfsStreamWrapper::getRoot())
74
+ ->lastModified(100)
75
+ ->lastAccessed(100)
76
+ ->lastAttributeModified(100);
77
+ fclose(fopen($this->fooUrl, 'rb'));
78
+ $this->assertGreaterThan(time() - 2, fileatime($this->fooUrl));
79
+ $this->assertLessThanOrEqual(time(), fileatime($this->fooUrl));
80
+ $this->assertLessThanOrEqual(100, filemtime($this->fooUrl));
81
+ $this->assertEquals(100, filectime($this->fooUrl));
82
+ $this->assertFileTimesEqualStreamTimes($this->fooUrl, $file);
83
+ }
84
+
85
+ /**
86
+ * @test
87
+ * @group issue_7
88
+ * @group issue_26
89
+ */
90
+ public function fileGetContentsChangesAttributeTimeOnly()
91
+ {
92
+ $file = vfsStream::newFile('foo.txt')
93
+ ->withContent('test')
94
+ ->at(vfsStreamWrapper::getRoot())
95
+ ->lastModified(100)
96
+ ->lastAccessed(100)
97
+ ->lastAttributeModified(100);
98
+ file_get_contents($this->fooUrl);
99
+ $this->assertGreaterThan(time() - 2, fileatime($this->fooUrl));
100
+ $this->assertLessThanOrEqual(time(), fileatime($this->fooUrl));
101
+ $this->assertLessThanOrEqual(100, filemtime($this->fooUrl));
102
+ $this->assertEquals(100, filectime($this->fooUrl));
103
+ $this->assertFileTimesEqualStreamTimes($this->fooUrl, $file);
104
+ }
105
+
106
+ /**
107
+ * @test
108
+ * @group issue_7
109
+ * @group issue_26
110
+ */
111
+ public function openFileWithTruncateChangesAttributeAndModificationTime()
112
+ {
113
+ $file = vfsStream::newFile('foo.txt')
114
+ ->withContent('test')
115
+ ->at(vfsStreamWrapper::getRoot())
116
+ ->lastModified(100)
117
+ ->lastAccessed(100)
118
+ ->lastAttributeModified(100);
119
+ fclose(fopen($this->fooUrl, 'wb'));
120
+ $this->assertGreaterThan(time() - 2, filemtime($this->fooUrl));
121
+ $this->assertGreaterThan(time() - 2, fileatime($this->fooUrl));
122
+ $this->assertLessThanOrEqual(time(), filemtime($this->fooUrl));
123
+ $this->assertLessThanOrEqual(time(), fileatime($this->fooUrl));
124
+ $this->assertEquals(100, filectime($this->fooUrl));
125
+ $this->assertFileTimesEqualStreamTimes($this->fooUrl, $file);
126
+ }
127
+
128
+ /**
129
+ * @test
130
+ * @group issue_7
131
+ */
132
+ public function readFileChangesAccessTime()
133
+ {
134
+ $file = vfsStream::newFile('foo.txt')
135
+ ->withContent('test')
136
+ ->at(vfsStreamWrapper::getRoot())
137
+ ->lastModified(100)
138
+ ->lastAccessed(100)
139
+ ->lastAttributeModified(100);
140
+ $fp = fopen($this->fooUrl, 'rb');
141
+ $openTime = time();
142
+ sleep(2);
143
+ fread($fp, 1024);
144
+ fclose($fp);
145
+ $this->assertLessThanOrEqual($openTime, filemtime($this->fooUrl));
146
+ $this->assertLessThanOrEqual($openTime + 3, fileatime($this->fooUrl));
147
+ $this->assertEquals(100, filectime($this->fooUrl));
148
+ $this->assertFileTimesEqualStreamTimes($this->fooUrl, $file);
149
+ }
150
+
151
+ /**
152
+ * @test
153
+ * @group issue_7
154
+ */
155
+ public function writeFileChangesModificationTime()
156
+ {
157
+ $file = vfsStream::newFile('foo.txt')
158
+ ->at(vfsStreamWrapper::getRoot())
159
+ ->lastModified(100)
160
+ ->lastAccessed(100)
161
+ ->lastAttributeModified(100);
162
+ $fp = fopen($this->fooUrl, 'wb');
163
+ $openTime = time();
164
+ sleep(2);
165
+ fwrite($fp, 'test');
166
+ fclose($fp);
167
+ $this->assertLessThanOrEqual($openTime + 3, filemtime($this->fooUrl));
168
+ $this->assertLessThanOrEqual($openTime, fileatime($this->fooUrl));
169
+ $this->assertEquals(100, filectime($this->fooUrl));
170
+ $this->assertFileTimesEqualStreamTimes($this->fooUrl, $file);
171
+
172
+ }
173
+
174
+ /**
175
+ * @test
176
+ * @group issue_7
177
+ */
178
+ public function createNewFileSetsAllTimesToCurrentTime()
179
+ {
180
+ file_put_contents($this->fooUrl, 'test');
181
+ $this->assertLessThanOrEqual(time(), filemtime($this->fooUrl));
182
+ $this->assertEquals(fileatime($this->fooUrl), filectime($this->fooUrl));
183
+ $this->assertEquals(fileatime($this->fooUrl), filemtime($this->fooUrl));
184
+ $this->assertFileTimesEqualStreamTimes($this->fooUrl, vfsStreamWrapper::getRoot()->getChild('foo.txt'));
185
+ }
186
+
187
+ /**
188
+ * @test
189
+ * @group issue_7
190
+ */
191
+ public function createNewFileChangesAttributeAndModificationTimeOfContainingDirectory()
192
+ {
193
+ $dir = vfsStream::newDirectory('bar')
194
+ ->at(vfsStreamWrapper::getRoot())
195
+ ->lastModified(100)
196
+ ->lastAccessed(100)
197
+ ->lastAttributeModified(100);
198
+ file_put_contents($this->bazUrl, 'test');
199
+ $this->assertLessThanOrEqual(time(), filemtime($this->barUrl));
200
+ $this->assertLessThanOrEqual(time(), filectime($this->barUrl));
201
+ $this->assertEquals(100, fileatime($this->barUrl));
202
+ $this->assertFileTimesEqualStreamTimes($this->barUrl, $dir);
203
+ }
204
+
205
+ /**
206
+ * @test
207
+ * @group issue_7
208
+ */
209
+ public function addNewFileNameWithLinkFunctionChangesAttributeTimeOfOriginalFile()
210
+ {
211
+ $this->markTestSkipped('Links are currently not supported by vfsStream.');
212
+ }
213
+
214
+ /**
215
+ * @test
216
+ * @group issue_7
217
+ */
218
+ public function addNewFileNameWithLinkFunctionChangesAttributeAndModificationTimeOfDirectoryContainingLink()
219
+ {
220
+ $this->markTestSkipped('Links are currently not supported by vfsStream.');
221
+ }
222
+
223
+ /**
224
+ * @test
225
+ * @group issue_7
226
+ */
227
+ public function removeFileChangesAttributeAndModificationTimeOfContainingDirectory()
228
+ {
229
+ $dir = vfsStream::newDirectory('bar')
230
+ ->at(vfsStreamWrapper::getRoot());
231
+ $file = vfsStream::newFile('baz.txt')
232
+ ->at($dir)
233
+ ->lastModified(100)
234
+ ->lastAccessed(100)
235
+ ->lastAttributeModified(100);
236
+ $dir->lastModified(100)
237
+ ->lastAccessed(100)
238
+ ->lastAttributeModified(100);
239
+ unlink($this->bazUrl);
240
+ $this->assertLessThanOrEqual(time(), filemtime($this->barUrl));
241
+ $this->assertLessThanOrEqual(time(), filectime($this->barUrl));
242
+ $this->assertEquals(100, fileatime($this->barUrl));
243
+ $this->assertFileTimesEqualStreamTimes($this->barUrl, $dir);
244
+ }
245
+
246
+ /**
247
+ * @test
248
+ * @group issue_7
249
+ */
250
+ public function renameFileChangesAttributeAndModificationTimeOfAffectedDirectories()
251
+ {
252
+ $target = vfsStream::newDirectory('target')
253
+ ->at(vfsStreamWrapper::getRoot())
254
+ ->lastModified(200)
255
+ ->lastAccessed(200)
256
+ ->lastAttributeModified(200);
257
+ $source = vfsStream::newDirectory('bar')
258
+ ->at(vfsStreamWrapper::getRoot());
259
+ $file = vfsStream::newFile('baz.txt')
260
+ ->at($source)
261
+ ->lastModified(300)
262
+ ->lastAccessed(300)
263
+ ->lastAttributeModified(300);
264
+ $source->lastModified(100)
265
+ ->lastAccessed(100)
266
+ ->lastAttributeModified(100);
267
+ rename($this->bazUrl, vfsStream::url('root/target/baz.txt'));
268
+ $this->assertLessThanOrEqual(time(), filemtime($this->barUrl));
269
+ $this->assertLessThanOrEqual(time(), filectime($this->barUrl));
270
+ $this->assertEquals(100, fileatime($this->barUrl));
271
+ $this->assertFileTimesEqualStreamTimes($this->barUrl, $source);
272
+ $this->assertLessThanOrEqual(time(), filemtime(vfsStream::url('root/target')));
273
+ $this->assertLessThanOrEqual(time(), filectime(vfsStream::url('root/target')));
274
+ $this->assertEquals(200, fileatime(vfsStream::url('root/target')));
275
+ $this->assertFileTimesEqualStreamTimes(vfsStream::url('root/target'), $target);
276
+ }
277
+
278
+ /**
279
+ * @test
280
+ * @group issue_7
281
+ */
282
+ public function renameFileDoesNotChangeFileTimesOfFileItself()
283
+ {
284
+ $target = vfsStream::newDirectory('target')
285
+ ->at(vfsStreamWrapper::getRoot())
286
+ ->lastModified(200)
287
+ ->lastAccessed(200)
288
+ ->lastAttributeModified(200);
289
+ $source = vfsStream::newDirectory('bar')
290
+ ->at(vfsStreamWrapper::getRoot());
291
+ $file = vfsStream::newFile('baz.txt')
292
+ ->at($source)
293
+ ->lastModified(300)
294
+ ->lastAccessed(300)
295
+ ->lastAttributeModified(300);
296
+ $source->lastModified(100)
297
+ ->lastAccessed(100)
298
+ ->lastAttributeModified(100);
299
+ rename($this->bazUrl, vfsStream::url('root/target/baz.txt'));
300
+ $this->assertEquals(300, filemtime(vfsStream::url('root/target/baz.txt')));
301
+ $this->assertEquals(300, filectime(vfsStream::url('root/target/baz.txt')));
302
+ $this->assertEquals(300, fileatime(vfsStream::url('root/target/baz.txt')));
303
+ $this->assertFileTimesEqualStreamTimes(vfsStream::url('root/target/baz.txt'), $file);
304
+ }
305
+
306
+ /**
307
+ * @test
308
+ * @group issue_7
309
+ */
310
+ public function changeFileAttributesChangesAttributeTimeOfFileItself()
311
+ {
312
+ $this->markTestSkipped('Changing file attributes via stream wrapper for self-defined streams is not supported by PHP.');
313
+ }
314
+ }
315
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperFlockTestCase.php ADDED
@@ -0,0 +1,440 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for flock() implementation.
13
+ *
14
+ * @package bovigo_vfs
15
+ * @subpackage test
16
+ * @since 0.10.0
17
+ * @see https://github.com/mikey179/vfsStream/issues/6
18
+ * @group issue_6
19
+ */
20
+ class vfsStreamWrapperFlockTestCase extends \PHPUnit_Framework_TestCase
21
+ {
22
+ /**
23
+ * root directory
24
+ *
25
+ * @var vfsStreamContainer
26
+ */
27
+ protected $root;
28
+
29
+ /**
30
+ * set up test environment
31
+ */
32
+ public function setUp()
33
+ {
34
+ $this->root = vfsStream::setup();
35
+ }
36
+
37
+ /**
38
+ * @test
39
+ */
40
+ public function fileIsNotLockedByDefault()
41
+ {
42
+ $this->assertFalse(vfsStream::newFile('foo.txt')->isLocked());
43
+ }
44
+
45
+ /**
46
+ * @test
47
+ */
48
+ public function streamIsNotLockedByDefault()
49
+ {
50
+ file_put_contents(vfsStream::url('root/foo.txt'), 'content');
51
+ $this->assertFalse($this->root->getChild('foo.txt')->isLocked());
52
+ }
53
+
54
+ /**
55
+ * @test
56
+ */
57
+ public function canAquireSharedLock()
58
+ {
59
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
60
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
61
+ $this->assertTrue(flock($fp, LOCK_SH));
62
+ $this->assertTrue($file->isLocked());
63
+ $this->assertTrue($file->hasSharedLock());
64
+ $this->assertFalse($file->hasExclusiveLock());
65
+ fclose($fp);
66
+
67
+ }
68
+
69
+ /**
70
+ * @test
71
+ */
72
+ public function canAquireSharedLockWithNonBlockingFlockCall()
73
+ {
74
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
75
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
76
+ $this->assertTrue(flock($fp, LOCK_SH | LOCK_NB));
77
+ $this->assertTrue($file->isLocked());
78
+ $this->assertTrue($file->hasSharedLock());
79
+ $this->assertFalse($file->hasExclusiveLock());
80
+ fclose($fp);
81
+
82
+ }
83
+
84
+ /**
85
+ * @test
86
+ */
87
+ public function canAquireEclusiveLock()
88
+ {
89
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
90
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
91
+ $this->assertTrue(flock($fp, LOCK_EX));
92
+ $this->assertTrue($file->isLocked());
93
+ $this->assertFalse($file->hasSharedLock());
94
+ $this->assertTrue($file->hasExclusiveLock());
95
+ fclose($fp);
96
+ }
97
+
98
+ /**
99
+ * @test
100
+ */
101
+ public function canAquireEclusiveLockWithNonBlockingFlockCall()
102
+ {
103
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
104
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
105
+ $this->assertTrue(flock($fp, LOCK_EX | LOCK_NB));
106
+ $this->assertTrue($file->isLocked());
107
+ $this->assertFalse($file->hasSharedLock());
108
+ $this->assertTrue($file->hasExclusiveLock());
109
+ fclose($fp);
110
+ }
111
+
112
+ /**
113
+ * @test
114
+ */
115
+ public function canRemoveLock()
116
+ {
117
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
118
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
119
+ $file->lock($fp, LOCK_EX);
120
+ $this->assertTrue(flock($fp, LOCK_UN));
121
+ $this->assertFalse($file->isLocked());
122
+ $this->assertFalse($file->hasSharedLock());
123
+ $this->assertFalse($file->hasExclusiveLock());
124
+ fclose($fp);
125
+ }
126
+
127
+ /**
128
+ * @see https://github.com/mikey179/vfsStream/issues/40
129
+ * @test
130
+ * @group issue_40
131
+ */
132
+ public function canRemoveLockWhenNotLocked()
133
+ {
134
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
135
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
136
+ $this->assertTrue(flock($fp, LOCK_UN));
137
+ $this->assertFalse($file->isLocked());
138
+ $this->assertFalse($file->hasSharedLock());
139
+ $this->assertFalse($file->hasSharedLock($fp));
140
+ $this->assertFalse($file->hasExclusiveLock());
141
+ $this->assertFalse($file->hasExclusiveLock($fp));
142
+ fclose($fp);
143
+ }
144
+
145
+ /**
146
+ * @see https://github.com/mikey179/vfsStream/issues/40
147
+ * @test
148
+ * @group issue_40
149
+ */
150
+ public function canRemoveSharedLockWithoutRemovingSharedLockOnOtherFileHandler()
151
+ {
152
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
153
+ $fp1 = fopen(vfsStream::url('root/foo.txt'), 'rb');
154
+ $fp2 = fopen(vfsStream::url('root/foo.txt'), 'rb');
155
+ $file->lock($fp1, LOCK_SH);
156
+ $file->lock($fp2, LOCK_SH);
157
+ $this->assertTrue(flock($fp1, LOCK_UN));
158
+ $this->assertTrue($file->hasSharedLock());
159
+ $this->assertFalse($file->hasSharedLock($fp1));
160
+ $this->assertTrue($file->hasSharedLock($fp2));
161
+ fclose($fp1);
162
+ fclose($fp2);
163
+ }
164
+
165
+ /**
166
+ * @see https://github.com/mikey179/vfsStream/issues/40
167
+ * @test
168
+ * @group issue_40
169
+ */
170
+ public function canNotRemoveSharedLockAcquiredOnOtherFileHandler()
171
+ {
172
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
173
+ $fp1 = fopen(vfsStream::url('root/foo.txt'), 'rb');
174
+ $fp2 = fopen(vfsStream::url('root/foo.txt'), 'rb');
175
+ $file->lock($fp1, LOCK_SH);
176
+ $this->assertTrue(flock($fp2, LOCK_UN));
177
+ $this->assertTrue($file->isLocked());
178
+ $this->assertTrue($file->hasSharedLock());
179
+ $this->assertFalse($file->hasExclusiveLock());
180
+ fclose($fp1);
181
+ fclose($fp2);
182
+ }
183
+
184
+ /**
185
+ * @see https://github.com/mikey179/vfsStream/issues/40
186
+ * @test
187
+ * @group issue_40
188
+ */
189
+ public function canNotRemoveExlusiveLockAcquiredOnOtherFileHandler()
190
+ {
191
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
192
+ $fp1 = fopen(vfsStream::url('root/foo.txt'), 'rb');
193
+ $fp2 = fopen(vfsStream::url('root/foo.txt'), 'rb');
194
+ $file->lock($fp1, LOCK_EX);
195
+ $this->assertTrue(flock($fp2, LOCK_UN));
196
+ $this->assertTrue($file->isLocked());
197
+ $this->assertFalse($file->hasSharedLock());
198
+ $this->assertTrue($file->hasExclusiveLock());
199
+ fclose($fp1);
200
+ fclose($fp2);
201
+ }
202
+
203
+ /**
204
+ * @test
205
+ */
206
+ public function canRemoveLockWithNonBlockingFlockCall()
207
+ {
208
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
209
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
210
+ $file->lock($fp, LOCK_EX);
211
+ $this->assertTrue(flock($fp, LOCK_UN | LOCK_NB));
212
+ $this->assertFalse($file->isLocked());
213
+ $this->assertFalse($file->hasSharedLock());
214
+ $this->assertFalse($file->hasExclusiveLock());
215
+ fclose($fp);
216
+ }
217
+
218
+ /**
219
+ * @see https://github.com/mikey179/vfsStream/issues/40
220
+ * @test
221
+ * @group issue_40
222
+ */
223
+ public function canNotAquireExclusiveLockIfAlreadyExclusivelyLockedOnOtherFileHandler()
224
+ {
225
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
226
+ $fp1 = fopen(vfsStream::url('root/foo.txt'), 'rb');
227
+ $fp2 = fopen(vfsStream::url('root/foo.txt'), 'rb');
228
+ $file->lock($fp1, LOCK_EX);
229
+ $this->assertFalse(flock($fp2, LOCK_EX + LOCK_NB));
230
+ $this->assertTrue($file->isLocked());
231
+ $this->assertFalse($file->hasSharedLock());
232
+ $this->assertTrue($file->hasExclusiveLock());
233
+ $this->assertTrue($file->hasExclusiveLock($fp1));
234
+ $this->assertFalse($file->hasExclusiveLock($fp2));
235
+ fclose($fp1);
236
+ fclose($fp2);
237
+ }
238
+
239
+ /**
240
+ * @see https://github.com/mikey179/vfsStream/issues/40
241
+ * @test
242
+ * @group issue_40
243
+ */
244
+ public function canAquireExclusiveLockIfAlreadySelfExclusivelyLocked()
245
+ {
246
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
247
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
248
+ $file->lock($fp, LOCK_EX);
249
+ $this->assertTrue(flock($fp, LOCK_EX + LOCK_NB));
250
+ $this->assertTrue($file->isLocked());
251
+ $this->assertFalse($file->hasSharedLock());
252
+ $this->assertTrue($file->hasExclusiveLock());
253
+ fclose($fp);
254
+ }
255
+
256
+ /**
257
+ * @see https://github.com/mikey179/vfsStream/issues/40
258
+ * @test
259
+ * @group issue_40
260
+ */
261
+ public function canNotAquireExclusiveLockIfAlreadySharedLockedOnOtherFileHandler()
262
+ {
263
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
264
+ $fp1 = fopen(vfsStream::url('root/foo.txt'), 'rb');
265
+ $fp2 = fopen(vfsStream::url('root/foo.txt'), 'rb');
266
+ $file->lock($fp1, LOCK_SH);
267
+ $this->assertFalse(flock($fp2, LOCK_EX));
268
+ $this->assertTrue($file->isLocked());
269
+ $this->assertTrue($file->hasSharedLock());
270
+ $this->assertFalse($file->hasExclusiveLock());
271
+ fclose($fp1);
272
+ fclose($fp2);
273
+ }
274
+
275
+ /**
276
+ * @see https://github.com/mikey179/vfsStream/issues/40
277
+ * @test
278
+ * @group issue_40
279
+ */
280
+ public function canAquireExclusiveLockIfAlreadySelfSharedLocked()
281
+ {
282
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
283
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
284
+ $file->lock($fp, LOCK_SH);
285
+ $this->assertTrue(flock($fp, LOCK_EX));
286
+ $this->assertTrue($file->isLocked());
287
+ $this->assertFalse($file->hasSharedLock());
288
+ $this->assertTrue($file->hasExclusiveLock());
289
+ fclose($fp);
290
+ }
291
+
292
+ /**
293
+ * @see https://github.com/mikey179/vfsStream/issues/40
294
+ * @test
295
+ * @group issue_40
296
+ */
297
+ public function canNotAquireSharedLockIfAlreadyExclusivelyLockedOnOtherFileHandler()
298
+ {
299
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
300
+ $fp1 = fopen(vfsStream::url('root/foo.txt'), 'rb');
301
+ $fp2 = fopen(vfsStream::url('root/foo.txt'), 'rb');
302
+ $file->lock($fp1, LOCK_EX);
303
+ $this->assertFalse(flock($fp2, LOCK_SH + LOCK_NB));
304
+ $this->assertTrue($file->isLocked());
305
+ $this->assertFalse($file->hasSharedLock());
306
+ $this->assertTrue($file->hasExclusiveLock());
307
+ fclose($fp1);
308
+ fclose($fp2);
309
+ }
310
+
311
+ /**
312
+ * @see https://github.com/mikey179/vfsStream/issues/40
313
+ * @test
314
+ * @group issue_40
315
+ */
316
+ public function canAquireSharedLockIfAlreadySelfExclusivelyLocked()
317
+ {
318
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
319
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
320
+ $file->lock($fp, LOCK_EX);
321
+ $this->assertTrue(flock($fp, LOCK_SH + LOCK_NB));
322
+ $this->assertTrue($file->isLocked());
323
+ $this->assertTrue($file->hasSharedLock());
324
+ $this->assertFalse($file->hasExclusiveLock());
325
+ fclose($fp);
326
+ }
327
+
328
+ /**
329
+ * @see https://github.com/mikey179/vfsStream/issues/40
330
+ * @test
331
+ * @group issue_40
332
+ */
333
+ public function canAquireSharedLockIfAlreadySelfSharedLocked()
334
+ {
335
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
336
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
337
+ $file->lock($fp, LOCK_SH);
338
+ $this->assertTrue(flock($fp, LOCK_SH));
339
+ $this->assertTrue($file->isLocked());
340
+ $this->assertTrue($file->hasSharedLock());
341
+ $this->assertFalse($file->hasExclusiveLock());
342
+ fclose($fp);
343
+ }
344
+
345
+ /**
346
+ * @see https://github.com/mikey179/vfsStream/issues/40
347
+ * @test
348
+ * @group issue_40
349
+ */
350
+ public function canAquireSharedLockIfAlreadySharedLockedOnOtherFileHandler()
351
+ {
352
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
353
+ $fp1 = fopen(vfsStream::url('root/foo.txt'), 'rb');
354
+ $fp2 = fopen(vfsStream::url('root/foo.txt'), 'rb');
355
+ $file->lock($fp1, LOCK_SH);
356
+ $this->assertTrue(flock($fp2, LOCK_SH));
357
+ $this->assertTrue($file->isLocked());
358
+ $this->assertTrue($file->hasSharedLock());
359
+ $this->assertTrue($file->hasSharedLock($fp1));
360
+ $this->assertTrue($file->hasSharedLock($fp2));
361
+ $this->assertFalse($file->hasExclusiveLock());
362
+ fclose($fp1);
363
+ fclose($fp2);
364
+ }
365
+
366
+ /**
367
+ * @see https://github.com/mikey179/vfsStream/issues/31
368
+ * @see https://github.com/mikey179/vfsStream/issues/40
369
+ * @test
370
+ * @group issue_31
371
+ * @group issue_40
372
+ */
373
+ public function removesExclusiveLockOnStreamClose()
374
+ {
375
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
376
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
377
+ $file->lock($fp, LOCK_EX);
378
+ fclose($fp);
379
+ $this->assertFalse($file->isLocked());
380
+ $this->assertFalse($file->hasSharedLock());
381
+ $this->assertFalse($file->hasExclusiveLock());
382
+ }
383
+
384
+ /**
385
+ * @see https://github.com/mikey179/vfsStream/issues/31
386
+ * @see https://github.com/mikey179/vfsStream/issues/40
387
+ * @test
388
+ * @group issue_31
389
+ * @group issue_40
390
+ */
391
+ public function removesSharedLockOnStreamClose()
392
+ {
393
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
394
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
395
+ $file->lock($fp, LOCK_SH);
396
+ fclose($fp);
397
+ $this->assertFalse($file->isLocked());
398
+ $this->assertFalse($file->hasSharedLock());
399
+ $this->assertFalse($file->hasExclusiveLock());
400
+ }
401
+
402
+ /**
403
+ * @see https://github.com/mikey179/vfsStream/issues/40
404
+ * @test
405
+ * @group issue_40
406
+ */
407
+ public function notRemovesExclusiveLockOnStreamCloseIfExclusiveLockAcquiredOnOtherFileHandler()
408
+ {
409
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
410
+ $fp1 = fopen(vfsStream::url('root/foo.txt'), 'rb');
411
+ $fp2 = fopen(vfsStream::url('root/foo.txt'), 'rb');
412
+ $file->lock($fp2, LOCK_EX);
413
+ fclose($fp1);
414
+ $this->assertTrue($file->isLocked());
415
+ $this->assertFalse($file->hasSharedLock());
416
+ $this->assertTrue($file->hasExclusiveLock());
417
+ $this->assertTrue($file->hasExclusiveLock($fp2));
418
+ fclose($fp2);
419
+ }
420
+
421
+ /**
422
+ * @see https://github.com/mikey179/vfsStream/issues/40
423
+ * @test
424
+ * @group issue_40
425
+ */
426
+ public function notRemovesSharedLockOnStreamCloseIfSharedLockAcquiredOnOtherFileHandler()
427
+ {
428
+ $file = vfsStream::newFile('foo.txt')->at($this->root);
429
+ $fp1 = fopen(vfsStream::url('root/foo.txt'), 'rb');
430
+ $fp2 = fopen(vfsStream::url('root/foo.txt'), 'rb');
431
+ $file->lock($fp2, LOCK_SH);
432
+ fclose($fp1);
433
+ $this->assertTrue($file->isLocked());
434
+ $this->assertTrue($file->hasSharedLock());
435
+ $this->assertTrue($file->hasSharedLock($fp2));
436
+ $this->assertFalse($file->hasExclusiveLock());
437
+ fclose($fp2);
438
+ }
439
+ }
440
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperLargeFileTestCase.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ use org\bovigo\vfs\content\LargeFileContent;
12
+ /**
13
+ * Test for large file mocks.
14
+ *
15
+ * @package bovigo_vfs
16
+ * @subpackage test
17
+ * @since 1.3.0
18
+ * @group issue_79
19
+ */
20
+ class vfsStreamWrapperLargeFileTestCase extends \PHPUnit_Framework_TestCase
21
+ {
22
+ /**
23
+ * large file to test
24
+ *
25
+ * @var vfsStreamFile
26
+ */
27
+ private $largeFile;
28
+
29
+ /**
30
+ * set up test environment
31
+ */
32
+ public function setUp()
33
+ {
34
+ $root = vfsStream::setup();
35
+ $this->largeFile = vfsStream::newFile('large.txt')
36
+ ->withContent(LargeFileContent::withGigabytes(100))
37
+ ->at($root);
38
+ }
39
+
40
+ /**
41
+ * @test
42
+ */
43
+ public function hasLargeFileSize()
44
+ {
45
+ $this->assertEquals(
46
+ 100 * 1024 * 1024 * 1024,
47
+ filesize($this->largeFile->url())
48
+ );
49
+ }
50
+
51
+ /**
52
+ * @test
53
+ */
54
+ public function canReadFromLargeFile()
55
+ {
56
+ $fp = fopen($this->largeFile->url(), 'rb');
57
+ $data = fread($fp, 15);
58
+ fclose($fp);
59
+ $this->assertEquals(str_repeat(' ', 15), $data);
60
+ }
61
+
62
+ /**
63
+ * @test
64
+ */
65
+ public function canWriteIntoLargeFile()
66
+ {
67
+ $fp = fopen($this->largeFile->url(), 'rb+');
68
+ fseek($fp, 100 * 1024 * 1024, SEEK_SET);
69
+ fwrite($fp, 'foobarbaz');
70
+ fclose($fp);
71
+ $this->largeFile->seek((100 * 1024 * 1024) - 3, SEEK_SET);
72
+ $this->assertEquals(
73
+ ' foobarbaz ',
74
+ $this->largeFile->read(15)
75
+ );
76
+ }
77
+ }
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperQuotaTestCase.php ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for quota related functionality of org\bovigo\vfs\vfsStreamWrapper.
13
+ *
14
+ * @group issue_35
15
+ */
16
+ class vfsStreamWrapperQuotaTestCase extends \PHPUnit_Framework_TestCase
17
+ {
18
+ /**
19
+ * access to root
20
+ *
21
+ * @type vfsStreamDirectory
22
+ */
23
+ private $root;
24
+
25
+ /**
26
+ * set up test environment
27
+ */
28
+ public function setUp()
29
+ {
30
+ $this->root = vfsStream::setup();
31
+ vfsStream::setQuota(10);
32
+ }
33
+
34
+ /**
35
+ * @test
36
+ */
37
+ public function writeLessThanQuotaWritesEverything()
38
+ {
39
+ $this->assertEquals(9, file_put_contents(vfsStream::url('root/file.txt'), '123456789'));
40
+ $this->assertEquals('123456789', $this->root->getChild('file.txt')->getContent());
41
+ }
42
+
43
+ /**
44
+ * @test
45
+ */
46
+ public function writeUpToQotaWritesEverything()
47
+ {
48
+ $this->assertEquals(10, file_put_contents(vfsStream::url('root/file.txt'), '1234567890'));
49
+ $this->assertEquals('1234567890', $this->root->getChild('file.txt')->getContent());
50
+ }
51
+
52
+ /**
53
+ * @test
54
+ */
55
+ public function writeMoreThanQotaWritesOnlyUpToQuota()
56
+ {
57
+ try {
58
+ file_put_contents(vfsStream::url('root/file.txt'), '12345678901');
59
+ } catch (\PHPUnit_Framework_Error $e) {
60
+ $this->assertEquals('file_put_contents(): Only 10 of 11 bytes written, possibly out of free disk space',
61
+ $e->getMessage()
62
+ );
63
+ }
64
+
65
+ $this->assertEquals('1234567890', $this->root->getChild('file.txt')->getContent());
66
+ }
67
+
68
+ /**
69
+ * @test
70
+ */
71
+ public function considersAllFilesForQuota()
72
+ {
73
+ vfsStream::newFile('foo.txt')
74
+ ->withContent('foo')
75
+ ->at(vfsStream::newDirectory('bar')
76
+ ->at($this->root)
77
+ );
78
+ try {
79
+ file_put_contents(vfsStream::url('root/file.txt'), '12345678901');
80
+ } catch (\PHPUnit_Framework_Error $e) {
81
+ $this->assertEquals('file_put_contents(): Only 7 of 11 bytes written, possibly out of free disk space',
82
+ $e->getMessage()
83
+ );
84
+ }
85
+
86
+ $this->assertEquals('1234567', $this->root->getChild('file.txt')->getContent());
87
+ }
88
+
89
+ /**
90
+ * @test
91
+ * @group issue_33
92
+ */
93
+ public function truncateToLessThanQuotaWritesEverything()
94
+ {
95
+ if (version_compare(PHP_VERSION, '5.4.0', '<')) {
96
+ $this->markTestSkipped('Requires PHP 5.4');
97
+ }
98
+
99
+ if (strstr(PHP_VERSION, 'hiphop') !== false) {
100
+ $this->markTestSkipped('Not supported on hhvm');
101
+ }
102
+
103
+ $fp = fopen(vfsStream::url('root/file.txt'), 'w+');
104
+ $this->assertTrue(ftruncate($fp, 9));
105
+ fclose($fp);
106
+ $this->assertEquals(9,
107
+ $this->root->getChild('file.txt')->size()
108
+ );
109
+ $this->assertEquals("\0\0\0\0\0\0\0\0\0",
110
+ $this->root->getChild('file.txt')->getContent()
111
+ );
112
+ }
113
+
114
+ /**
115
+ * @test
116
+ * @group issue_33
117
+ */
118
+ public function truncateUpToQotaWritesEverything()
119
+ {
120
+ if (version_compare(PHP_VERSION, '5.4.0', '<')) {
121
+ $this->markTestSkipped('Requires PHP 5.4');
122
+ }
123
+
124
+ if (strstr(PHP_VERSION, 'hiphop') !== false) {
125
+ $this->markTestSkipped('Not supported on hhvm');
126
+ }
127
+
128
+ $fp = fopen(vfsStream::url('root/file.txt'), 'w+');
129
+ $this->assertTrue(ftruncate($fp, 10));
130
+ fclose($fp);
131
+ $this->assertEquals(10,
132
+ $this->root->getChild('file.txt')->size()
133
+ );
134
+ $this->assertEquals("\0\0\0\0\0\0\0\0\0\0",
135
+ $this->root->getChild('file.txt')->getContent()
136
+ );
137
+ }
138
+
139
+ /**
140
+ * @test
141
+ * @group issue_33
142
+ */
143
+ public function truncateToMoreThanQotaWritesOnlyUpToQuota()
144
+ {
145
+ if (version_compare(PHP_VERSION, '5.4.0', '<')) {
146
+ $this->markTestSkipped('Requires PHP 5.4');
147
+ }
148
+
149
+ if (strstr(PHP_VERSION, 'hiphop') !== false) {
150
+ $this->markTestSkipped('Not supported on hhvm');
151
+ }
152
+
153
+ $fp = fopen(vfsStream::url('root/file.txt'), 'w+');
154
+ $this->assertTrue(ftruncate($fp, 11));
155
+ fclose($fp);
156
+ $this->assertEquals(10,
157
+ $this->root->getChild('file.txt')->size()
158
+ );
159
+ $this->assertEquals("\0\0\0\0\0\0\0\0\0\0",
160
+ $this->root->getChild('file.txt')->getContent()
161
+ );
162
+ }
163
+
164
+ /**
165
+ * @test
166
+ * @group issue_33
167
+ */
168
+ public function truncateConsidersAllFilesForQuota()
169
+ {
170
+ if (version_compare(PHP_VERSION, '5.4.0', '<')) {
171
+ $this->markTestSkipped('Requires PHP 5.4');
172
+ }
173
+
174
+ if (strstr(PHP_VERSION, 'hiphop') !== false) {
175
+ $this->markTestSkipped('Not supported on hhvm');
176
+ }
177
+
178
+ vfsStream::newFile('bar.txt')
179
+ ->withContent('bar')
180
+ ->at(vfsStream::newDirectory('bar')
181
+ ->at($this->root)
182
+ );
183
+ $fp = fopen(vfsStream::url('root/file.txt'), 'w+');
184
+ $this->assertTrue(ftruncate($fp, 11));
185
+ fclose($fp);
186
+ $this->assertEquals(7,
187
+ $this->root->getChild('file.txt')->size()
188
+ );
189
+ $this->assertEquals("\0\0\0\0\0\0\0",
190
+ $this->root->getChild('file.txt')->getContent()
191
+ );
192
+ }
193
+
194
+ /**
195
+ * @test
196
+ * @group issue_33
197
+ */
198
+ public function canNotTruncateToGreaterLengthWhenDiscQuotaReached()
199
+ {
200
+ if (version_compare(PHP_VERSION, '5.4.0', '<')) {
201
+ $this->markTestSkipped('Requires PHP 5.4');
202
+ }
203
+
204
+ if (strstr(PHP_VERSION, 'hiphop') !== false) {
205
+ $this->markTestSkipped('Not supported on hhvm');
206
+ }
207
+
208
+ vfsStream::newFile('bar.txt')
209
+ ->withContent('1234567890')
210
+ ->at(vfsStream::newDirectory('bar')
211
+ ->at($this->root)
212
+ );
213
+ $fp = fopen(vfsStream::url('root/file.txt'), 'w+');
214
+ $this->assertFalse(ftruncate($fp, 11));
215
+ fclose($fp);
216
+ $this->assertEquals(0,
217
+ $this->root->getChild('file.txt')->size()
218
+ );
219
+ $this->assertEquals('',
220
+ $this->root->getChild('file.txt')->getContent()
221
+ );
222
+ }
223
+ }
224
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperSetOptionTestCase.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for stream_set_option() implementation.
13
+ *
14
+ * @since 0.10.0
15
+ * @see https://github.com/mikey179/vfsStream/issues/15
16
+ * @group issue_15
17
+ */
18
+ class vfsStreamWrapperSetOptionTestCase extends \PHPUnit_Framework_TestCase
19
+ {
20
+ /**
21
+ * root directory
22
+ *
23
+ * @var vfsStreamContainer
24
+ */
25
+ protected $root;
26
+
27
+ /**
28
+ * set up test environment
29
+ */
30
+ public function setUp()
31
+ {
32
+ $this->root = vfsStream::setup();
33
+ vfsStream::newFile('foo.txt')->at($this->root);
34
+ }
35
+
36
+ /**
37
+ * @test
38
+ */
39
+ public function setBlockingDoesNotWork()
40
+ {
41
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
42
+ $this->assertFalse(stream_set_blocking($fp, 1));
43
+ fclose($fp);
44
+ }
45
+
46
+ /**
47
+ * @test
48
+ */
49
+ public function removeBlockingDoesNotWork()
50
+ {
51
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
52
+ $this->assertFalse(stream_set_blocking($fp, 0));
53
+ fclose($fp);
54
+ }
55
+
56
+ /**
57
+ * @test
58
+ */
59
+ public function setTimeoutDoesNotWork()
60
+ {
61
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
62
+ $this->assertFalse(stream_set_timeout($fp, 1));
63
+ fclose($fp);
64
+ }
65
+
66
+ /**
67
+ * @test
68
+ */
69
+ public function setWriteBufferDoesNotWork()
70
+ {
71
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
72
+ $this->assertEquals(-1, stream_set_write_buffer($fp, 512));
73
+ fclose($fp);
74
+ }
75
+ }
76
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperStreamSelectTestCase.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for org\bovigo\vfs\vfsStreamWrapper.
13
+ *
14
+ * @since 0.9.0
15
+ * @group issue_3
16
+ */
17
+ class vfsStreamWrapperSelectStreamTestCase extends \PHPUnit_Framework_TestCase
18
+ {
19
+ /**
20
+ * @test
21
+ * @expectedException \PHPUnit_Framework_Error
22
+ */
23
+ public function selectStream()
24
+ {
25
+ $root = vfsStream::setup();
26
+ $file = vfsStream::newFile('foo.txt')->at($root)->withContent('testContent');
27
+
28
+ $fp = fopen(vfsStream::url('root/foo.txt'), 'rb');
29
+ $readarray = array($fp);
30
+ $writearray = array();
31
+ $exceptarray = array();
32
+ stream_select($readarray, $writearray, $exceptarray, 1);
33
+ }
34
+ }
35
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperTestCase.php ADDED
@@ -0,0 +1,770 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ require_once __DIR__ . '/vfsStreamWrapperBaseTestCase.php';
12
+ /**
13
+ * Test for org\bovigo\vfs\vfsStreamWrapper.
14
+ */
15
+ class vfsStreamWrapperTestCase extends vfsStreamWrapperBaseTestCase
16
+ {
17
+ /**
18
+ * ensure that a call to vfsStreamWrapper::register() resets the stream
19
+ *
20
+ * Implemented after a request by David Zülke.
21
+ *
22
+ * @test
23
+ */
24
+ public function resetByRegister()
25
+ {
26
+ $this->assertSame($this->foo, vfsStreamWrapper::getRoot());
27
+ vfsStreamWrapper::register();
28
+ $this->assertNull(vfsStreamWrapper::getRoot());
29
+ }
30
+
31
+ /**
32
+ * @test
33
+ * @since 0.11.0
34
+ */
35
+ public function setRootReturnsRoot()
36
+ {
37
+ vfsStreamWrapper::register();
38
+ $root = vfsStream::newDirectory('root');
39
+ $this->assertSame($root, vfsStreamWrapper::setRoot($root));
40
+ }
41
+
42
+ /**
43
+ * assure that filesize is returned correct
44
+ *
45
+ * @test
46
+ */
47
+ public function filesize()
48
+ {
49
+ $this->assertEquals(0, filesize($this->fooURL));
50
+ $this->assertEquals(0, filesize($this->fooURL . '/.'));
51
+ $this->assertEquals(0, filesize($this->barURL));
52
+ $this->assertEquals(0, filesize($this->barURL . '/.'));
53
+ $this->assertEquals(4, filesize($this->baz2URL));
54
+ $this->assertEquals(5, filesize($this->baz1URL));
55
+ }
56
+
57
+ /**
58
+ * assert that file_exists() delivers correct result
59
+ *
60
+ * @test
61
+ */
62
+ public function file_exists()
63
+ {
64
+ $this->assertTrue(file_exists($this->fooURL));
65
+ $this->assertTrue(file_exists($this->fooURL . '/.'));
66
+ $this->assertTrue(file_exists($this->barURL));
67
+ $this->assertTrue(file_exists($this->barURL . '/.'));
68
+ $this->assertTrue(file_exists($this->baz1URL));
69
+ $this->assertTrue(file_exists($this->baz2URL));
70
+ $this->assertFalse(file_exists($this->fooURL . '/another'));
71
+ $this->assertFalse(file_exists(vfsStream::url('another')));
72
+ }
73
+
74
+ /**
75
+ * assert that filemtime() delivers correct result
76
+ *
77
+ * @test
78
+ */
79
+ public function filemtime()
80
+ {
81
+ $this->assertEquals(100, filemtime($this->fooURL));
82
+ $this->assertEquals(100, filemtime($this->fooURL . '/.'));
83
+ $this->assertEquals(200, filemtime($this->barURL));
84
+ $this->assertEquals(200, filemtime($this->barURL . '/.'));
85
+ $this->assertEquals(300, filemtime($this->baz1URL));
86
+ $this->assertEquals(400, filemtime($this->baz2URL));
87
+ }
88
+
89
+ /**
90
+ * @test
91
+ * @group issue_23
92
+ */
93
+ public function unlinkRemovesFilesOnly()
94
+ {
95
+ $this->assertTrue(unlink($this->baz2URL));
96
+ $this->assertFalse(file_exists($this->baz2URL)); // make sure statcache was cleared
97
+ $this->assertEquals(array($this->bar), $this->foo->getChildren());
98
+ $this->assertFalse(@unlink($this->fooURL . '/another'));
99
+ $this->assertFalse(@unlink(vfsStream::url('another')));
100
+ $this->assertEquals(array($this->bar), $this->foo->getChildren());
101
+ }
102
+
103
+ /**
104
+ * @test
105
+ * @group issue_49
106
+ */
107
+ public function unlinkReturnsFalseWhenFileDoesNotExist()
108
+ {
109
+ vfsStream::setup()->addChild(vfsStream::newFile('foo.blubb'));
110
+ $this->assertFalse(@unlink(vfsStream::url('foo.blubb2')));
111
+ }
112
+
113
+ /**
114
+ * @test
115
+ * @group issue_49
116
+ */
117
+ public function unlinkReturnsFalseWhenFileDoesNotExistAndFileWithSameNameExistsInRoot()
118
+ {
119
+ vfsStream::setup()->addChild(vfsStream::newFile('foo.blubb'));
120
+ $this->assertFalse(@unlink(vfsStream::url('foo.blubb')));
121
+ }
122
+
123
+ /**
124
+ * assert dirname() returns correct directory name
125
+ *
126
+ * @test
127
+ */
128
+ public function dirname()
129
+ {
130
+ $this->assertEquals($this->fooURL, dirname($this->barURL));
131
+ $this->assertEquals($this->barURL, dirname($this->baz1URL));
132
+ # returns "vfs:" instead of "."
133
+ # however this seems not to be fixable because dirname() does not
134
+ # call the stream wrapper
135
+ #$this->assertEquals(dirname(vfsStream::url('doesNotExist')), '.');
136
+ }
137
+
138
+ /**
139
+ * assert basename() returns correct file name
140
+ *
141
+ * @test
142
+ */
143
+ public function basename()
144
+ {
145
+ $this->assertEquals('bar', basename($this->barURL));
146
+ $this->assertEquals('baz1', basename($this->baz1URL));
147
+ $this->assertEquals('doesNotExist', basename(vfsStream::url('doesNotExist')));
148
+ }
149
+
150
+ /**
151
+ * assert is_readable() works correct
152
+ *
153
+ * @test
154
+ */
155
+ public function is_readable()
156
+ {
157
+ $this->assertTrue(is_readable($this->fooURL));
158
+ $this->assertTrue(is_readable($this->fooURL . '/.'));
159
+ $this->assertTrue(is_readable($this->barURL));
160
+ $this->assertTrue(is_readable($this->barURL . '/.'));
161
+ $this->assertTrue(is_readable($this->baz1URL));
162
+ $this->assertTrue(is_readable($this->baz2URL));
163
+ $this->assertFalse(is_readable($this->fooURL . '/another'));
164
+ $this->assertFalse(is_readable(vfsStream::url('another')));
165
+
166
+ $this->foo->chmod(0222);
167
+ $this->assertFalse(is_readable($this->fooURL));
168
+
169
+ $this->baz1->chmod(0222);
170
+ $this->assertFalse(is_readable($this->baz1URL));
171
+ }
172
+
173
+ /**
174
+ * assert is_writable() works correct
175
+ *
176
+ * @test
177
+ */
178
+ public function is_writable()
179
+ {
180
+ $this->assertTrue(is_writable($this->fooURL));
181
+ $this->assertTrue(is_writable($this->fooURL . '/.'));
182
+ $this->assertTrue(is_writable($this->barURL));
183
+ $this->assertTrue(is_writable($this->barURL . '/.'));
184
+ $this->assertTrue(is_writable($this->baz1URL));
185
+ $this->assertTrue(is_writable($this->baz2URL));
186
+ $this->assertFalse(is_writable($this->fooURL . '/another'));
187
+ $this->assertFalse(is_writable(vfsStream::url('another')));
188
+
189
+ $this->foo->chmod(0444);
190
+ $this->assertFalse(is_writable($this->fooURL));
191
+
192
+ $this->baz1->chmod(0444);
193
+ $this->assertFalse(is_writable($this->baz1URL));
194
+ }
195
+
196
+ /**
197
+ * assert is_executable() works correct
198
+ *
199
+ * @test
200
+ */
201
+ public function is_executable()
202
+ {
203
+ $this->assertFalse(is_executable($this->baz1URL));
204
+ $this->baz1->chmod(0766);
205
+ $this->assertTrue(is_executable($this->baz1URL));
206
+ $this->assertFalse(is_executable($this->baz2URL));
207
+ }
208
+
209
+ /**
210
+ * assert is_executable() works correct
211
+ *
212
+ * @test
213
+ */
214
+ public function directoriesAndNonExistingFilesAreNeverExecutable()
215
+ {
216
+ $this->assertFalse(is_executable($this->fooURL));
217
+ $this->assertFalse(is_executable($this->fooURL . '/.'));
218
+ $this->assertFalse(is_executable($this->barURL));
219
+ $this->assertFalse(is_executable($this->barURL . '/.'));
220
+ $this->assertFalse(is_executable($this->fooURL . '/another'));
221
+ $this->assertFalse(is_executable(vfsStream::url('another')));
222
+ }
223
+
224
+ /**
225
+ * file permissions
226
+ *
227
+ * @test
228
+ * @group permissions
229
+ */
230
+ public function chmod()
231
+ {
232
+ $this->assertEquals(40777, decoct(fileperms($this->fooURL)));
233
+ $this->assertEquals(40777, decoct(fileperms($this->fooURL . '/.')));
234
+ $this->assertEquals(40777, decoct(fileperms($this->barURL)));
235
+ $this->assertEquals(40777, decoct(fileperms($this->barURL . '/.')));
236
+ $this->assertEquals(100666, decoct(fileperms($this->baz1URL)));
237
+ $this->assertEquals(100666, decoct(fileperms($this->baz2URL)));
238
+
239
+ $this->foo->chmod(0755);
240
+ $this->bar->chmod(0700);
241
+ $this->baz1->chmod(0644);
242
+ $this->baz2->chmod(0600);
243
+ $this->assertEquals(40755, decoct(fileperms($this->fooURL)));
244
+ $this->assertEquals(40755, decoct(fileperms($this->fooURL . '/.')));
245
+ $this->assertEquals(40700, decoct(fileperms($this->barURL)));
246
+ $this->assertEquals(40700, decoct(fileperms($this->barURL . '/.')));
247
+ $this->assertEquals(100644, decoct(fileperms($this->baz1URL)));
248
+ $this->assertEquals(100600, decoct(fileperms($this->baz2URL)));
249
+ }
250
+
251
+ /**
252
+ * @test
253
+ * @group issue_11
254
+ * @group permissions
255
+ */
256
+ public function chmodModifiesPermissions()
257
+ {
258
+ if (version_compare(phpversion(), '5.4.0', '<')) {
259
+ $this->assertFalse(@chmod($this->fooURL, 0755));
260
+ $this->assertFalse(@chmod($this->barURL, 0711));
261
+ $this->assertFalse(@chmod($this->baz1URL, 0644));
262
+ $this->assertFalse(@chmod($this->baz2URL, 0664));
263
+ $this->assertEquals(40777, decoct(fileperms($this->fooURL)));
264
+ $this->assertEquals(40777, decoct(fileperms($this->barURL)));
265
+ $this->assertEquals(100666, decoct(fileperms($this->baz1URL)));
266
+ $this->assertEquals(100666, decoct(fileperms($this->baz2URL)));
267
+ } else {
268
+ $this->assertTrue(chmod($this->fooURL, 0755));
269
+ $this->assertTrue(chmod($this->barURL, 0711));
270
+ $this->assertTrue(chmod($this->baz1URL, 0644));
271
+ $this->assertTrue(chmod($this->baz2URL, 0664));
272
+ $this->assertEquals(40755, decoct(fileperms($this->fooURL)));
273
+ $this->assertEquals(40711, decoct(fileperms($this->barURL)));
274
+ $this->assertEquals(100644, decoct(fileperms($this->baz1URL)));
275
+ $this->assertEquals(100664, decoct(fileperms($this->baz2URL)));
276
+ }
277
+ }
278
+
279
+ /**
280
+ * @test
281
+ * @group permissions
282
+ */
283
+ public function fileownerIsCurrentUserByDefault()
284
+ {
285
+ $this->assertEquals(vfsStream::getCurrentUser(), fileowner($this->fooURL));
286
+ $this->assertEquals(vfsStream::getCurrentUser(), fileowner($this->fooURL . '/.'));
287
+ $this->assertEquals(vfsStream::getCurrentUser(), fileowner($this->barURL));
288
+ $this->assertEquals(vfsStream::getCurrentUser(), fileowner($this->barURL . '/.'));
289
+ $this->assertEquals(vfsStream::getCurrentUser(), fileowner($this->baz1URL));
290
+ $this->assertEquals(vfsStream::getCurrentUser(), fileowner($this->baz2URL));
291
+ }
292
+
293
+ /**
294
+ * @test
295
+ * @group issue_11
296
+ * @group permissions
297
+ */
298
+ public function chownChangesUser()
299
+ {
300
+ if (version_compare(phpversion(), '5.4.0', '<')) {
301
+ $this->foo->chown(vfsStream::OWNER_USER_1);
302
+ $this->bar->chown(vfsStream::OWNER_USER_1);
303
+ $this->baz1->chown(vfsStream::OWNER_USER_2);
304
+ $this->baz2->chown(vfsStream::OWNER_USER_2);
305
+ } else {
306
+ chown($this->fooURL, vfsStream::OWNER_USER_1);
307
+ chown($this->barURL, vfsStream::OWNER_USER_1);
308
+ chown($this->baz1URL, vfsStream::OWNER_USER_2);
309
+ chown($this->baz2URL, vfsStream::OWNER_USER_2);
310
+ }
311
+
312
+ $this->assertEquals(vfsStream::OWNER_USER_1, fileowner($this->fooURL));
313
+ $this->assertEquals(vfsStream::OWNER_USER_1, fileowner($this->fooURL . '/.'));
314
+ $this->assertEquals(vfsStream::OWNER_USER_1, fileowner($this->barURL));
315
+ $this->assertEquals(vfsStream::OWNER_USER_1, fileowner($this->barURL . '/.'));
316
+ $this->assertEquals(vfsStream::OWNER_USER_2, fileowner($this->baz1URL));
317
+ $this->assertEquals(vfsStream::OWNER_USER_2, fileowner($this->baz2URL));
318
+ }
319
+
320
+ /**
321
+ * @test
322
+ * @group issue_11
323
+ * @group permissions
324
+ */
325
+ public function chownDoesNotWorkOnVfsStreamUrls()
326
+ {
327
+ if (version_compare(phpversion(), '5.4.0', '<')) {
328
+ $this->assertFalse(@chown($this->fooURL, vfsStream::OWNER_USER_2));
329
+ $this->assertEquals(vfsStream::getCurrentUser(), fileowner($this->fooURL));
330
+ }
331
+ }
332
+
333
+ /**
334
+ * @test
335
+ * @group issue_11
336
+ * @group permissions
337
+ */
338
+ public function groupIsCurrentGroupByDefault()
339
+ {
340
+ $this->assertEquals(vfsStream::getCurrentGroup(), filegroup($this->fooURL));
341
+ $this->assertEquals(vfsStream::getCurrentGroup(), filegroup($this->fooURL . '/.'));
342
+ $this->assertEquals(vfsStream::getCurrentGroup(), filegroup($this->barURL));
343
+ $this->assertEquals(vfsStream::getCurrentGroup(), filegroup($this->barURL . '/.'));
344
+ $this->assertEquals(vfsStream::getCurrentGroup(), filegroup($this->baz1URL));
345
+ $this->assertEquals(vfsStream::getCurrentGroup(), filegroup($this->baz2URL));
346
+ }
347
+
348
+ /**
349
+ * @test
350
+ * @group issue_11
351
+ * @group permissions
352
+ */
353
+ public function chgrp()
354
+ {
355
+ if (version_compare(phpversion(), '5.4.0', '<')) {
356
+ $this->foo->chgrp(vfsStream::GROUP_USER_1);
357
+ $this->bar->chgrp(vfsStream::GROUP_USER_1);
358
+ $this->baz1->chgrp(vfsStream::GROUP_USER_2);
359
+ $this->baz2->chgrp(vfsStream::GROUP_USER_2);
360
+ } else {
361
+ chgrp($this->fooURL, vfsStream::GROUP_USER_1);
362
+ chgrp($this->barURL, vfsStream::GROUP_USER_1);
363
+ chgrp($this->baz1URL, vfsStream::GROUP_USER_2);
364
+ chgrp($this->baz2URL, vfsStream::GROUP_USER_2);
365
+ }
366
+
367
+ $this->assertEquals(vfsStream::GROUP_USER_1, filegroup($this->fooURL));
368
+ $this->assertEquals(vfsStream::GROUP_USER_1, filegroup($this->fooURL . '/.'));
369
+ $this->assertEquals(vfsStream::GROUP_USER_1, filegroup($this->barURL));
370
+ $this->assertEquals(vfsStream::GROUP_USER_1, filegroup($this->barURL . '/.'));
371
+ $this->assertEquals(vfsStream::GROUP_USER_2, filegroup($this->baz1URL));
372
+ $this->assertEquals(vfsStream::GROUP_USER_2, filegroup($this->baz2URL));
373
+ }
374
+
375
+ /**
376
+ * @test
377
+ * @group issue_11
378
+ * @group permissions
379
+ */
380
+ public function chgrpDoesNotWorkOnVfsStreamUrls()
381
+ {
382
+ if (version_compare(phpversion(), '5.4.0', '<')) {
383
+ $this->assertFalse(@chgrp($this->fooURL, vfsStream::GROUP_USER_2));
384
+ $this->assertEquals(vfsStream::getCurrentGroup(), filegroup($this->fooURL));
385
+ }
386
+ }
387
+
388
+ /**
389
+ * @test
390
+ * @author Benoit Aubuchon
391
+ */
392
+ public function renameDirectory()
393
+ {
394
+ // move foo/bar to foo/baz3
395
+ $baz3URL = vfsStream::url('foo/baz3');
396
+ $this->assertTrue(rename($this->barURL, $baz3URL));
397
+ $this->assertFileExists($baz3URL);
398
+ $this->assertFileNotExists($this->barURL);
399
+ }
400
+
401
+ /**
402
+ * @test
403
+ */
404
+ public function renameDirectoryWithDots()
405
+ {
406
+ // move foo/bar to foo/baz3
407
+ $baz3URL = vfsStream::url('foo/baz3');
408
+ $this->assertTrue(rename($this->barURL . '/.', $baz3URL));
409
+ $this->assertFileExists($baz3URL);
410
+ $this->assertFileNotExists($this->barURL);
411
+ }
412
+
413
+ /**
414
+ * @test
415
+ * @group issue_9
416
+ * @since 0.9.0
417
+ */
418
+ public function renameDirectoryWithDotsInTarget()
419
+ {
420
+ // move foo/bar to foo/baz3
421
+ $baz3URL = vfsStream::url('foo/../foo/baz3/.');
422
+ $this->assertTrue(rename($this->barURL . '/.', $baz3URL));
423
+ $this->assertFileExists($baz3URL);
424
+ $this->assertFileNotExists($this->barURL);
425
+ }
426
+
427
+ /**
428
+ * @test
429
+ * @author Benoit Aubuchon
430
+ */
431
+ public function renameDirectoryOverwritingExistingFile()
432
+ {
433
+ // move foo/bar to foo/baz2
434
+ $this->assertTrue(rename($this->barURL, $this->baz2URL));
435
+ $this->assertFileExists(vfsStream::url('foo/baz2/baz1'));
436
+ $this->assertFileNotExists($this->barURL);
437
+ }
438
+
439
+ /**
440
+ * @test
441
+ * @expectedException PHPUnit_Framework_Error
442
+ */
443
+ public function renameFileIntoFile()
444
+ {
445
+ // foo/baz2 is a file, so it can not be turned into a directory
446
+ $baz3URL = vfsStream::url('foo/baz2/baz3');
447
+ $this->assertTrue(rename($this->baz1URL, $baz3URL));
448
+ $this->assertFileExists($baz3URL);
449
+ $this->assertFileNotExists($this->baz1URL);
450
+ }
451
+
452
+ /**
453
+ * @test
454
+ * @author Benoit Aubuchon
455
+ */
456
+ public function renameFileToDirectory()
457
+ {
458
+ // move foo/bar/baz1 to foo/baz3
459
+ $baz3URL = vfsStream::url('foo/baz3');
460
+ $this->assertTrue(rename($this->baz1URL, $baz3URL));
461
+ $this->assertFileExists($this->barURL);
462
+ $this->assertFileExists($baz3URL);
463
+ $this->assertFileNotExists($this->baz1URL);
464
+ }
465
+
466
+ /**
467
+ * assert that trying to rename from a non existing file trigger a warning
468
+ *
469
+ * @expectedException PHPUnit_Framework_Error
470
+ * @test
471
+ */
472
+ public function renameOnSourceFileNotFound()
473
+ {
474
+ rename(vfsStream::url('notfound'), $this->baz1URL);
475
+ }
476
+ /**
477
+ * assert that trying to rename to a directory that is not found trigger a warning
478
+
479
+ * @expectedException PHPUnit_Framework_Error
480
+ * @test
481
+ */
482
+ public function renameOnDestinationDirectoryFileNotFound()
483
+ {
484
+ rename($this->baz1URL, vfsStream::url('foo/notfound/file2'));
485
+ }
486
+ /**
487
+ * stat() and fstat() should return the same result
488
+ *
489
+ * @test
490
+ */
491
+ public function statAndFstatReturnSameResult()
492
+ {
493
+ $fp = fopen($this->baz2URL, 'r');
494
+ $this->assertEquals(stat($this->baz2URL),
495
+ fstat($fp)
496
+ );
497
+ fclose($fp);
498
+ }
499
+
500
+ /**
501
+ * stat() returns full data
502
+ *
503
+ * @test
504
+ */
505
+ public function statReturnsFullDataForFiles()
506
+ {
507
+ $this->assertEquals(array(0 => 0,
508
+ 1 => 0,
509
+ 2 => 0100666,
510
+ 3 => 0,
511
+ 4 => vfsStream::getCurrentUser(),
512
+ 5 => vfsStream::getCurrentGroup(),
513
+ 6 => 0,
514
+ 7 => 4,
515
+ 8 => 400,
516
+ 9 => 400,
517
+ 10 => 400,
518
+ 11 => -1,
519
+ 12 => -1,
520
+ 'dev' => 0,
521
+ 'ino' => 0,
522
+ 'mode' => 0100666,
523
+ 'nlink' => 0,
524
+ 'uid' => vfsStream::getCurrentUser(),
525
+ 'gid' => vfsStream::getCurrentGroup(),
526
+ 'rdev' => 0,
527
+ 'size' => 4,
528
+ 'atime' => 400,
529
+ 'mtime' => 400,
530
+ 'ctime' => 400,
531
+ 'blksize' => -1,
532
+ 'blocks' => -1
533
+ ),
534
+ stat($this->baz2URL)
535
+ );
536
+ }
537
+
538
+ /**
539
+ * @test
540
+ */
541
+ public function statReturnsFullDataForDirectories()
542
+ {
543
+ $this->assertEquals(array(0 => 0,
544
+ 1 => 0,
545
+ 2 => 0040777,
546
+ 3 => 0,
547
+ 4 => vfsStream::getCurrentUser(),
548
+ 5 => vfsStream::getCurrentGroup(),
549
+ 6 => 0,
550
+ 7 => 0,
551
+ 8 => 100,
552
+ 9 => 100,
553
+ 10 => 100,
554
+ 11 => -1,
555
+ 12 => -1,
556
+ 'dev' => 0,
557
+ 'ino' => 0,
558
+ 'mode' => 0040777,
559
+ 'nlink' => 0,
560
+ 'uid' => vfsStream::getCurrentUser(),
561
+ 'gid' => vfsStream::getCurrentGroup(),
562
+ 'rdev' => 0,
563
+ 'size' => 0,
564
+ 'atime' => 100,
565
+ 'mtime' => 100,
566
+ 'ctime' => 100,
567
+ 'blksize' => -1,
568
+ 'blocks' => -1
569
+ ),
570
+ stat($this->fooURL)
571
+ );
572
+ }
573
+
574
+ /**
575
+ * @test
576
+ */
577
+ public function statReturnsFullDataForDirectoriesWithDot()
578
+ {
579
+ $this->assertEquals(array(0 => 0,
580
+ 1 => 0,
581
+ 2 => 0040777,
582
+ 3 => 0,
583
+ 4 => vfsStream::getCurrentUser(),
584
+ 5 => vfsStream::getCurrentGroup(),
585
+ 6 => 0,
586
+ 7 => 0,
587
+ 8 => 100,
588
+ 9 => 100,
589
+ 10 => 100,
590
+ 11 => -1,
591
+ 12 => -1,
592
+ 'dev' => 0,
593
+ 'ino' => 0,
594
+ 'mode' => 0040777,
595
+ 'nlink' => 0,
596
+ 'uid' => vfsStream::getCurrentUser(),
597
+ 'gid' => vfsStream::getCurrentGroup(),
598
+ 'rdev' => 0,
599
+ 'size' => 0,
600
+ 'atime' => 100,
601
+ 'mtime' => 100,
602
+ 'ctime' => 100,
603
+ 'blksize' => -1,
604
+ 'blocks' => -1
605
+ ),
606
+ stat($this->fooURL . '/.')
607
+ );
608
+ }
609
+
610
+ /**
611
+ * @test
612
+ * @expectedException PHPUnit_Framework_Error
613
+ */
614
+ public function openFileWithoutDirectory()
615
+ {
616
+ vfsStreamWrapper::register();
617
+ $this->assertFalse(file_get_contents(vfsStream::url('file.txt')));
618
+ }
619
+
620
+ /**
621
+ * @test
622
+ * @group issue_33
623
+ * @since 1.1.0
624
+ * @requires PHP 5.4.0
625
+ */
626
+ public function truncateRemovesSuperflouosContent()
627
+ {
628
+ if (strstr(PHP_VERSION, 'hiphop') !== false) {
629
+ $this->markTestSkipped('Not supported on hhvm');
630
+ }
631
+
632
+ $handle = fopen($this->baz1URL, "r+");
633
+ $this->assertTrue(ftruncate($handle, 0));
634
+ $this->assertEquals(0, filesize($this->baz1URL));
635
+ $this->assertEquals('', file_get_contents($this->baz1URL));
636
+ fclose($handle);
637
+ }
638
+
639
+ /**
640
+ * @test
641
+ * @group issue_33
642
+ * @since 1.1.0
643
+ * @requires PHP 5.4.0
644
+ */
645
+ public function truncateToGreaterSizeAddsZeroBytes()
646
+ {
647
+ if (strstr(PHP_VERSION, 'hiphop') !== false) {
648
+ $this->markTestSkipped('Not supported on hhvm');
649
+ }
650
+
651
+ $handle = fopen($this->baz1URL, "r+");
652
+ $this->assertTrue(ftruncate($handle, 25));
653
+ $this->assertEquals(25, filesize($this->baz1URL));
654
+ $this->assertEquals("baz 1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
655
+ file_get_contents($this->baz1URL));
656
+ fclose($handle);
657
+ }
658
+
659
+ /**
660
+ * @test
661
+ * @group issue_11
662
+ * @requires PHP 5.4.0
663
+ */
664
+ public function touchCreatesNonExistingFile()
665
+ {
666
+ $this->assertTrue(touch($this->fooURL . '/new.txt'));
667
+ $this->assertTrue($this->foo->hasChild('new.txt'));
668
+ }
669
+
670
+ /**
671
+ * @test
672
+ * @group issue_11
673
+ * @requires PHP 5.4.0
674
+ */
675
+ public function touchChangesAccessAndModificationTimeForFile()
676
+ {
677
+ $this->assertTrue(touch($this->baz1URL, 303, 313));
678
+ $this->assertEquals(303, $this->baz1->filemtime());
679
+ $this->assertEquals(313, $this->baz1->fileatime());
680
+ }
681
+
682
+ /**
683
+ * @test
684
+ * @group issue_11
685
+ * @group issue_80
686
+ * @requires PHP 5.4.0
687
+ */
688
+ public function touchChangesTimesToCurrentTimestampWhenNoTimesGiven()
689
+ {
690
+ $this->assertTrue(touch($this->baz1URL));
691
+ $this->assertEquals(time(), $this->baz1->filemtime(), '', 1);
692
+ $this->assertEquals(time(), $this->baz1->fileatime(), '', 1);
693
+ }
694
+
695
+ /**
696
+ * @test
697
+ * @group issue_11
698
+ * @requires PHP 5.4.0
699
+ */
700
+ public function touchWithModifiedTimeChangesAccessAndModifiedTime()
701
+ {
702
+ $this->assertTrue(touch($this->baz1URL, 303));
703
+ $this->assertEquals(303, $this->baz1->filemtime());
704
+ $this->assertEquals(303, $this->baz1->fileatime());
705
+ }
706
+
707
+ /**
708
+ * @test
709
+ * @group issue_11
710
+ * @requires PHP 5.4.0
711
+ */
712
+ public function touchChangesAccessAndModificationTimeForDirectory()
713
+ {
714
+ $this->assertTrue(touch($this->fooURL, 303, 313));
715
+ $this->assertEquals(303, $this->foo->filemtime());
716
+ $this->assertEquals(313, $this->foo->fileatime());
717
+ }
718
+
719
+ /**
720
+ * @test
721
+ * @group issue_34
722
+ * @since 1.2.0
723
+ */
724
+ public function pathesAreCorrectlySet()
725
+ {
726
+ $this->assertEquals(vfsStream::path($this->fooURL), $this->foo->path());
727
+ $this->assertEquals(vfsStream::path($this->barURL), $this->bar->path());
728
+ $this->assertEquals(vfsStream::path($this->baz1URL), $this->baz1->path());
729
+ $this->assertEquals(vfsStream::path($this->baz2URL), $this->baz2->path());
730
+ }
731
+
732
+ /**
733
+ * @test
734
+ * @group issue_34
735
+ * @since 1.2.0
736
+ */
737
+ public function urlsAreCorrectlySet()
738
+ {
739
+ $this->assertEquals($this->fooURL, $this->foo->url());
740
+ $this->assertEquals($this->barURL, $this->bar->url());
741
+ $this->assertEquals($this->baz1URL, $this->baz1->url());
742
+ $this->assertEquals($this->baz2URL, $this->baz2->url());
743
+ }
744
+
745
+ /**
746
+ * @test
747
+ * @group issue_34
748
+ * @since 1.2.0
749
+ */
750
+ public function pathIsUpdatedAfterMove()
751
+ {
752
+ // move foo/bar/baz1 to foo/baz3
753
+ $baz3URL = vfsStream::url('foo/baz3');
754
+ $this->assertTrue(rename($this->baz1URL, $baz3URL));
755
+ $this->assertEquals(vfsStream::path($baz3URL), $this->baz1->path());
756
+ }
757
+
758
+ /**
759
+ * @test
760
+ * @group issue_34
761
+ * @since 1.2.0
762
+ */
763
+ public function urlIsUpdatedAfterMove()
764
+ {
765
+ // move foo/bar/baz1 to foo/baz3
766
+ $baz3URL = vfsStream::url('foo/baz3');
767
+ $this->assertTrue(rename($this->baz1URL, $baz3URL));
768
+ $this->assertEquals($baz3URL, $this->baz1->url());
769
+ }
770
+ }
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamWrapperWithoutRootTestCase.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for org\bovigo\vfs\vfsStreamWrapper.
13
+ */
14
+ class vfsStreamWrapperWithoutRootTestCase extends \PHPUnit_Framework_TestCase
15
+ {
16
+ /**
17
+ * set up test environment
18
+ */
19
+ public function setUp()
20
+ {
21
+ vfsStreamWrapper::register();
22
+ }
23
+
24
+ /**
25
+ * no root > no directory to open
26
+ *
27
+ * @test
28
+ */
29
+ public function canNotOpenDirectory()
30
+ {
31
+ $this->assertFalse(@dir(vfsStream::url('foo')));
32
+ }
33
+
34
+ /**
35
+ * can not unlink without root
36
+ *
37
+ * @test
38
+ */
39
+ public function canNotUnlink()
40
+ {
41
+ $this->assertFalse(@unlink(vfsStream::url('foo')));
42
+ }
43
+
44
+ /**
45
+ * can not open a file without root
46
+ *
47
+ * @test
48
+ */
49
+ public function canNotOpen()
50
+ {
51
+ $this->assertFalse(@fopen(vfsStream::url('foo'), 'r'));
52
+ }
53
+
54
+ /**
55
+ * can not rename a file without root
56
+ *
57
+ * @test
58
+ */
59
+ public function canNotRename()
60
+ {
61
+ $this->assertFalse(@rename(vfsStream::url('foo'), vfsStream::url('bar')));
62
+ }
63
+ }
64
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/vfsStreamZipTestCase.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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;
11
+ /**
12
+ * Test for org\bovigo\vfs\vfsStreamWrapper in conjunction with ext/zip.
13
+ *
14
+ * @group zip
15
+ */
16
+ class vfsStreamZipTestCase extends \PHPUnit_Framework_TestCase
17
+ {
18
+ /**
19
+ * set up test environment
20
+ */
21
+ public function setUp()
22
+ {
23
+ if (extension_loaded('zip') === false) {
24
+ $this->markTestSkipped('No ext/zip installed, skipping test.');
25
+ }
26
+
27
+ $this->markTestSkipped('Zip extension can not work with vfsStream urls.');
28
+
29
+ vfsStreamWrapper::register();
30
+ vfsStreamWrapper::setRoot(vfsStream::newDirectory('root'));
31
+
32
+ }
33
+
34
+ /**
35
+ * @test
36
+ */
37
+ public function createZipArchive()
38
+ {
39
+ $zip = new ZipArchive();
40
+ $this->assertTrue($zip->open(vfsStream::url('root/test.zip'), ZipArchive::CREATE));
41
+ $this->assertTrue($zip->addFromString("testfile1.txt", "#1 This is a test string added as testfile1.txt.\n"));
42
+ $this->assertTrue($zip->addFromString("testfile2.txt", "#2 This is a test string added as testfile2.txt.\n"));
43
+ $zip->setArchiveComment('a test');
44
+ var_dump($zip);
45
+ $this->assertTrue($zip->close());
46
+ var_dump($zip->getStatusString());
47
+ var_dump($zip->close());
48
+ var_dump($zip->getStatusString());
49
+ var_dump($zip);
50
+ var_dump(file_exists(vfsStream::url('root/test.zip')));
51
+ }
52
+ }
53
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/visitor/vfsStreamAbstractVisitorTestCase.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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\visitor;
11
+ use org\bovigo\vfs\vfsStreamDirectory;
12
+ use org\bovigo\vfs\vfsStreamFile;
13
+ use org\bovigo\vfs\vfsStreamBlock;
14
+ /**
15
+ * Test for org\bovigo\vfs\visitor\vfsStreamAbstractVisitor.
16
+ *
17
+ * @since 0.10.0
18
+ * @see https://github.com/mikey179/vfsStream/issues/10
19
+ * @group issue_10
20
+ */
21
+ class vfsStreamAbstractVisitorTestCase extends \PHPUnit_Framework_TestCase
22
+ {
23
+ /**
24
+ * instance to test
25
+ *
26
+ * @var vfsStreamAbstractVisitor
27
+ */
28
+ protected $abstractVisitor;
29
+
30
+ /**
31
+ * set up test environment
32
+ */
33
+ public function setUp()
34
+ {
35
+ $this->abstractVisitor = $this->getMock('org\\bovigo\\vfs\\visitor\\vfsStreamAbstractVisitor',
36
+ array('visitFile', 'visitDirectory')
37
+ );
38
+ }
39
+
40
+ /**
41
+ * @test
42
+ * @expectedException \InvalidArgumentException
43
+ */
44
+ public function visitThrowsInvalidArgumentExceptionOnUnknownContentType()
45
+ {
46
+ $mockContent = $this->getMock('org\\bovigo\\vfs\\vfsStreamContent');
47
+ $mockContent->expects($this->any())
48
+ ->method('getType')
49
+ ->will($this->returnValue('invalid'));
50
+ $this->assertSame($this->abstractVisitor,
51
+ $this->abstractVisitor->visit($mockContent)
52
+ );
53
+ }
54
+
55
+ /**
56
+ * @test
57
+ */
58
+ public function visitWithFileCallsVisitFile()
59
+ {
60
+ $file = new vfsStreamFile('foo.txt');
61
+ $this->abstractVisitor->expects($this->once())
62
+ ->method('visitFile')
63
+ ->with($this->equalTo($file));
64
+ $this->assertSame($this->abstractVisitor,
65
+ $this->abstractVisitor->visit($file)
66
+ );
67
+ }
68
+
69
+ /**
70
+ * tests that a block device eventually calls out to visit file
71
+ *
72
+ * @test
73
+ */
74
+ public function visitWithBlockCallsVisitFile()
75
+ {
76
+ $block = new vfsStreamBlock('foo');
77
+ $this->abstractVisitor->expects($this->once())
78
+ ->method('visitFile')
79
+ ->with($this->equalTo($block));
80
+ $this->assertSame($this->abstractVisitor,
81
+ $this->abstractVisitor->visit($block)
82
+ );
83
+ }
84
+
85
+ /**
86
+ * @test
87
+ */
88
+ public function visitWithDirectoryCallsVisitDirectory()
89
+ {
90
+ $dir = new vfsStreamDirectory('bar');
91
+ $this->abstractVisitor->expects($this->once())
92
+ ->method('visitDirectory')
93
+ ->with($this->equalTo($dir));
94
+ $this->assertSame($this->abstractVisitor,
95
+ $this->abstractVisitor->visit($dir)
96
+ );
97
+ }
98
+ }
99
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/visitor/vfsStreamPrintVisitorTestCase.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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\visitor;
11
+ use org\bovigo\vfs\vfsStream;
12
+ use org\bovigo\vfs\vfsStreamDirectory;
13
+ use org\bovigo\vfs\vfsStreamFile;
14
+ /**
15
+ * Test for org\bovigo\vfs\visitor\vfsStreamPrintVisitor.
16
+ *
17
+ * @since 0.10.0
18
+ * @see https://github.com/mikey179/vfsStream/issues/10
19
+ * @group issue_10
20
+ */
21
+ class vfsStreamPrintVisitorTestCase extends \PHPUnit_Framework_TestCase
22
+ {
23
+ /**
24
+ * @test
25
+ * @expectedException \InvalidArgumentException
26
+ */
27
+ public function constructWithNonResourceThrowsInvalidArgumentException()
28
+ {
29
+ new vfsStreamPrintVisitor('invalid');
30
+ }
31
+
32
+ /**
33
+ * @test
34
+ * @expectedException \InvalidArgumentException
35
+ */
36
+ public function constructWithNonStreamResourceThrowsInvalidArgumentException()
37
+ {
38
+ new vfsStreamPrintVisitor(xml_parser_create());
39
+ }
40
+
41
+ /**
42
+ * @test
43
+ */
44
+ public function visitFileWritesFileNameToStream()
45
+ {
46
+ $output = vfsStream::newFile('foo.txt')
47
+ ->at(vfsStream::setup());
48
+ $printVisitor = new vfsStreamPrintVisitor(fopen('vfs://root/foo.txt', 'wb'));
49
+ $this->assertSame($printVisitor,
50
+ $printVisitor->visitFile(vfsStream::newFile('bar.txt'))
51
+ );
52
+ $this->assertEquals("- bar.txt\n", $output->getContent());
53
+ }
54
+
55
+ /**
56
+ * @test
57
+ */
58
+ public function visitFileWritesBlockDeviceToStream()
59
+ {
60
+ $output = vfsStream::newFile('foo.txt')
61
+ ->at(vfsStream::setup());
62
+ $printVisitor = new vfsStreamPrintVisitor(fopen('vfs://root/foo.txt', 'wb'));
63
+ $this->assertSame($printVisitor,
64
+ $printVisitor->visitBlockDevice(vfsStream::newBlock('bar'))
65
+ );
66
+ $this->assertEquals("- [bar]\n", $output->getContent());
67
+ }
68
+
69
+ /**
70
+ * @test
71
+ */
72
+ public function visitDirectoryWritesDirectoryNameToStream()
73
+ {
74
+ $output = vfsStream::newFile('foo.txt')
75
+ ->at(vfsStream::setup());
76
+ $printVisitor = new vfsStreamPrintVisitor(fopen('vfs://root/foo.txt', 'wb'));
77
+ $this->assertSame($printVisitor,
78
+ $printVisitor->visitDirectory(vfsStream::newDirectory('baz'))
79
+ );
80
+ $this->assertEquals("- baz\n", $output->getContent());
81
+ }
82
+
83
+ /**
84
+ * @test
85
+ */
86
+ public function visitRecursiveDirectoryStructure()
87
+ {
88
+ $root = vfsStream::setup('root',
89
+ null,
90
+ array('test' => array('foo' => array('test.txt' => 'hello'),
91
+ 'baz.txt' => 'world'
92
+ ),
93
+ 'foo.txt' => ''
94
+ )
95
+ );
96
+ $printVisitor = new vfsStreamPrintVisitor(fopen('vfs://root/foo.txt', 'wb'));
97
+ $this->assertSame($printVisitor,
98
+ $printVisitor->visitDirectory($root)
99
+ );
100
+ $this->assertEquals("- root\n - test\n - foo\n - test.txt\n - baz.txt\n - foo.txt\n", file_get_contents('vfs://root/foo.txt'));
101
+ }
102
+ }
103
+ ?>
vendor/mikey179/vfsStream/src/test/php/org/bovigo/vfs/visitor/vfsStreamStructureVisitorTestCase.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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\visitor;
11
+ use org\bovigo\vfs\vfsStream;
12
+ /**
13
+ * Test for org\bovigo\vfs\visitor\vfsStreamStructureVisitor.
14
+ *
15
+ * @since 0.10.0
16
+ * @see https://github.com/mikey179/vfsStream/issues/10
17
+ * @group issue_10
18
+ */
19
+ class vfsStreamStructureVisitorTestCase extends \PHPUnit_Framework_TestCase
20
+ {
21
+ /**
22
+ * @test
23
+ */
24
+ public function visitFileCreatesStructureForFile()
25
+ {
26
+ $structureVisitor = new vfsStreamStructureVisitor();
27
+ $this->assertEquals(array('foo.txt' => 'test'),
28
+ $structureVisitor->visitFile(vfsStream::newFile('foo.txt')
29
+ ->withContent('test')
30
+ )
31
+ ->getStructure()
32
+ );
33
+ }
34
+
35
+ /**
36
+ * @test
37
+ */
38
+ public function visitFileCreatesStructureForBlock()
39
+ {
40
+ $structureVisitor = new vfsStreamStructureVisitor();
41
+ $this->assertEquals(array('[foo]' => 'test'),
42
+ $structureVisitor->visitBlockDevice(vfsStream::newBlock('foo')
43
+ ->withContent('test')
44
+ )
45
+ ->getStructure()
46
+ );
47
+ }
48
+
49
+ /**
50
+ * @test
51
+ */
52
+ public function visitDirectoryCreatesStructureForDirectory()
53
+ {
54
+ $structureVisitor = new vfsStreamStructureVisitor();
55
+ $this->assertEquals(array('baz' => array()),
56
+ $structureVisitor->visitDirectory(vfsStream::newDirectory('baz'))
57
+ ->getStructure()
58
+ );
59
+ }
60
+
61
+ /**
62
+ * @test
63
+ */
64
+ public function visitRecursiveDirectoryStructure()
65
+ {
66
+ $root = vfsStream::setup('root',
67
+ null,
68
+ array('test' => array('foo' => array('test.txt' => 'hello'),
69
+ 'baz.txt' => 'world'
70
+ ),
71
+ 'foo.txt' => ''
72
+ )
73
+ );
74
+ $structureVisitor = new vfsStreamStructureVisitor();
75
+ $this->assertEquals(array('root' => array('test' => array('foo' => array('test.txt' => 'hello'),
76
+ 'baz.txt' => 'world'
77
+ ),
78
+ 'foo.txt' => ''
79
+ ),
80
+ ),
81
+ $structureVisitor->visitDirectory($root)
82
+ ->getStructure()
83
+ );
84
+ }
85
+ }
86
+ ?>
vendor/mikey179/vfsStream/src/test/resources/filesystemcopy/withSubfolders/aFile.txt ADDED
@@ -0,0 +1 @@
 
1
+ foo
vendor/mikey179/vfsStream/src/test/resources/filesystemcopy/withSubfolders/subfolder1/file1.txt ADDED
@@ -0,0 +1 @@
 
1
+ foobar
vendor/symfony/finder/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php CHANGED
@@ -272,7 +272,7 @@ abstract class AbstractFindAdapter extends AbstractAdapter
272
  foreach ($dates as $i => $date) {
273
  $command->add($i > 0 ? '-and' : null);
274
 
275
- $mins = (int) round((time()-$date->getTarget()) / 60);
276
 
277
  if (0 > $mins) {
278
  // mtime is in the future
272
  foreach ($dates as $i => $date) {
273
  $command->add($i > 0 ? '-and' : null);
274
 
275
+ $mins = (int) round((time() - $date->getTarget()) / 60);
276
 
277
  if (0 > $mins) {
278
  // mtime is in the future
vendor/symfony/finder/Symfony/Component/Finder/Comparator/NumberComparator.php CHANGED
@@ -64,13 +64,13 @@ class NumberComparator extends Comparator
64
  $target *= 1000000;
65
  break;
66
  case 'mi':
67
- $target *= 1024*1024;
68
  break;
69
  case 'g':
70
  $target *= 1000000000;
71
  break;
72
  case 'gi':
73
- $target *= 1024*1024*1024;
74
  break;
75
  }
76
  }
64
  $target *= 1000000;
65
  break;
66
  case 'mi':
67
+ $target *= 1024 * 1024;
68
  break;
69
  case 'g':
70
  $target *= 1000000000;
71
  break;
72
  case 'gi':
73
+ $target *= 1024 * 1024 * 1024;
74
  break;
75
  }
76
  }
vendor/symfony/finder/Symfony/Component/Finder/Finder.php CHANGED
@@ -234,7 +234,7 @@ class Finder implements \IteratorAggregate, \Countable
234
  * $finder->date('> now - 2 hours');
235
  * $finder->date('>= 2005-10-15');
236
  *
237
- * @param string $date A date rage string
238
  *
239
  * @return Finder The current Finder instance
240
  *
@@ -436,9 +436,9 @@ class Finder implements \IteratorAggregate, \Countable
436
  public function ignoreDotFiles($ignoreDotFiles)
437
  {
438
  if ($ignoreDotFiles) {
439
- $this->ignore = $this->ignore | static::IGNORE_DOT_FILES;
440
  } else {
441
- $this->ignore = $this->ignore & ~static::IGNORE_DOT_FILES;
442
  }
443
 
444
  return $this;
@@ -458,9 +458,9 @@ class Finder implements \IteratorAggregate, \Countable
458
  public function ignoreVCS($ignoreVCS)
459
  {
460
  if ($ignoreVCS) {
461
- $this->ignore = $this->ignore | static::IGNORE_VCS_FILES;
462
  } else {
463
- $this->ignore = $this->ignore & ~static::IGNORE_VCS_FILES;
464
  }
465
 
466
  return $this;
234
  * $finder->date('> now - 2 hours');
235
  * $finder->date('>= 2005-10-15');
236
  *
237
+ * @param string $date A date range string
238
  *
239
  * @return Finder The current Finder instance
240
  *
436
  public function ignoreDotFiles($ignoreDotFiles)
437
  {
438
  if ($ignoreDotFiles) {
439
+ $this->ignore |= static::IGNORE_DOT_FILES;
440
  } else {
441
+ $this->ignore &= ~static::IGNORE_DOT_FILES;
442
  }
443
 
444
  return $this;
458
  public function ignoreVCS($ignoreVCS)
459
  {
460
  if ($ignoreVCS) {
461
+ $this->ignore |= static::IGNORE_VCS_FILES;
462
  } else {
463
+ $this->ignore &= ~static::IGNORE_VCS_FILES;
464
  }
465
 
466
  return $this;
vendor/symfony/finder/Symfony/Component/Finder/README.md CHANGED
@@ -45,7 +45,7 @@ Resources
45
  You can run the unit tests with the following command:
46
 
47
  $ cd path/to/Symfony/Component/Finder/
48
- $ composer.phar install
49
  $ phpunit
50
 
51
  [1]: http://api.symfony.com/2.5/Symfony/Component/Finder/SplFileInfo.html
45
  You can run the unit tests with the following command:
46
 
47
  $ cd path/to/Symfony/Component/Finder/
48
+ $ composer install
49
  $ phpunit
50
 
51
  [1]: http://api.symfony.com/2.5/Symfony/Component/Finder/SplFileInfo.html
vendor/symfony/finder/Symfony/Component/Finder/Shell/Command.php CHANGED
@@ -168,7 +168,7 @@ class Command
168
  }
169
 
170
  $this->bits[] = self::create($this);
171
- $this->labels[$label] = count($this->bits)-1;
172
 
173
  return $this->bits[$this->labels[$label]];
174
  }
168
  }
169
 
170
  $this->bits[] = self::create($this);
171
+ $this->labels[$label] = count($this->bits) - 1;
172
 
173
  return $this->bits[$this->labels[$label]];
174
  }
vendor/symfony/finder/Symfony/Component/Finder/composer.json CHANGED
@@ -18,6 +18,9 @@
18
  "require": {
19
  "php": ">=5.3.3"
20
  },
 
 
 
21
  "autoload": {
22
  "psr-0": { "Symfony\\Component\\Finder\\": "" }
23
  },
18
  "require": {
19
  "php": ">=5.3.3"
20
  },
21
+ "require-dev": {
22
+ "symfony/phpunit-bridge": "~2.7"
23
+ },
24
  "autoload": {
25
  "psr-0": { "Symfony\\Component\\Finder\\": "" }
26
  },
vendor/symfony/finder/Symfony/Component/Finder/phpunit.xml.dist CHANGED
@@ -7,8 +7,7 @@
7
  bootstrap="vendor/autoload.php"
8
  >
9
  <php>
10
- <!-- Silence E_USER_DEPRECATED (-16385 == -1 & ~E_USER_DEPRECATED) -->
11
- <ini name="error_reporting" value="-16385"/>
12
  </php>
13
  <testsuites>
14
  <testsuite name="Symfony Finder Component Test Suite">
7
  bootstrap="vendor/autoload.php"
8
  >
9
  <php>
10
+ <ini name="error_reporting" value="-1" />
 
11
  </php>
12
  <testsuites>
13
  <testsuite name="Symfony Finder Component Test Suite">