BackUpWordPress - Version 3.6.1

Version Description

= 3.4 =

  • This version introduces a major refactoring of the code responsible for the core backup engine. We made sure to write unit tests for the new code, and we have tested it on several user's sites. It fixes a lot of old bugs, and Windows users should see major improvements to reliability.

= 3.3.4 =

  • WordPress 4.4 compatibility.

= 3.3.1 =

  • Fixes a bug that would prevent downloading backups since 3.3.0 - please update.

= 3.2.5 =

  • Security fixes related to add_query_arg

= 3.2.1 =

  • Important bug fixes. Please upgrade to this version to avoid incomplete or broken backups.

= 3.1.3 =

  • Fixes backwards compatibility for add-ons and avoids a Fatal Error. Please upgrade straight to this version before upgrading your add-ons.

= 3.0.4 =

  • Fixes a few minor bugs. Immediate update is recommended.

= 3.0.2 =

  • Important: we have dropped support for PHP 5.2, you will not be able to activate BackUpWordPress on a server running PHP versions older than PHP 5.3.29

= 3.0.1 =

  • This is a critical update. Fixes a bug in the core backup library. Please update immediately.
Download this release

Release Info

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

Code changes from version 3.6.0 to 3.6.1

Files changed (73) hide show
  1. backupwordpress.php +1 -1
  2. classes/backup/class-backup-engine-database-mysqldump.php +1 -1
  3. classes/backup/class-backup-utilities.php +1 -1
  4. classes/class-plugin.php +1 -1
  5. classes/class-requirement.php +1 -1
  6. functions/interface.php +7 -3
  7. languages/backupwordpress.pot +2 -2
  8. readme.txt +1 -1
  9. vendor/composer/autoload_classmap.php +65 -0
  10. vendor/ifsnop/mysqldump-php/.gitignore +4 -0
  11. vendor/ifsnop/mysqldump-php/.scrutinizer.yml +43 -0
  12. vendor/ifsnop/mysqldump-php/.travis.yml +22 -0
  13. vendor/ifsnop/mysqldump-php/README.md +266 -0
  14. vendor/ifsnop/mysqldump-php/phpunit.xml +18 -0
  15. vendor/ifsnop/mysqldump-php/tests/test.php +67 -0
  16. vendor/ifsnop/mysqldump-php/tests/test.sh +132 -0
  17. vendor/ifsnop/mysqldump-php/tests/test001.src.sql +136 -0
  18. vendor/ifsnop/mysqldump-php/tests/test002.src.sql +14 -0
  19. vendor/ifsnop/mysqldump-php/tests/test005.src.sql +12 -0
  20. vendor/ifsnop/mysqldump-php/tests/test006.src.sql +107 -0
  21. vendor/symfony/finder/.gitignore +3 -0
  22. vendor/symfony/finder/README.md +14 -0
  23. vendor/symfony/finder/Tests/BsdFinderTest.php +34 -0
  24. vendor/symfony/finder/Tests/Comparator/ComparatorTest.php +64 -0
  25. vendor/symfony/finder/Tests/Comparator/DateComparatorTest.php +63 -0
  26. vendor/symfony/finder/Tests/Comparator/NumberComparatorTest.php +107 -0
  27. vendor/symfony/finder/Tests/Expression/ExpressionTest.php +71 -0
  28. vendor/symfony/finder/Tests/Expression/GlobTest.php +50 -0
  29. vendor/symfony/finder/Tests/Expression/RegexTest.php +146 -0
  30. vendor/symfony/finder/Tests/FakeAdapter/DummyAdapter.php +57 -0
  31. vendor/symfony/finder/Tests/FakeAdapter/FailingAdapter.php +45 -0
  32. vendor/symfony/finder/Tests/FakeAdapter/NamedAdapter.php +57 -0
  33. vendor/symfony/finder/Tests/FakeAdapter/UnsupportedAdapter.php +44 -0
  34. vendor/symfony/finder/Tests/FinderTest.php +745 -0
  35. vendor/symfony/finder/Tests/Fixtures/A/B/C/abc.dat +0 -0
  36. vendor/symfony/finder/Tests/Fixtures/A/B/ab.dat +0 -0
  37. vendor/symfony/finder/Tests/Fixtures/A/a.dat +0 -0
  38. vendor/symfony/finder/Tests/Fixtures/copy/A/B/C/abc.dat.copy +0 -0
  39. vendor/symfony/finder/Tests/Fixtures/copy/A/B/ab.dat.copy +0 -0
  40. vendor/symfony/finder/Tests/Fixtures/copy/A/a.dat.copy +0 -0
  41. vendor/symfony/finder/Tests/Fixtures/dolor.txt +2 -0
  42. vendor/symfony/finder/Tests/Fixtures/ipsum.txt +2 -0
  43. vendor/symfony/finder/Tests/Fixtures/lorem.txt +2 -0
  44. vendor/symfony/finder/Tests/Fixtures/one/a +0 -0
  45. vendor/symfony/finder/Tests/Fixtures/one/b/c.neon +0 -0
  46. vendor/symfony/finder/Tests/Fixtures/one/b/d.neon +0 -0
  47. vendor/symfony/finder/Tests/Fixtures/r+e.gex[c]a(r)s/dir/bar.dat +0 -0
  48. vendor/symfony/finder/Tests/Fixtures/with space/foo.txt +0 -0
  49. vendor/symfony/finder/Tests/GlobTest.php +25 -0
  50. vendor/symfony/finder/Tests/GnuFinderTest.php +34 -0
  51. vendor/symfony/finder/Tests/Iterator/CustomFilterIteratorTest.php +46 -0
  52. vendor/symfony/finder/Tests/Iterator/DateRangeFilterIteratorTest.php +74 -0
  53. vendor/symfony/finder/Tests/Iterator/DepthRangeFilterIteratorTest.php +83 -0
  54. vendor/symfony/finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php +66 -0
  55. vendor/symfony/finder/Tests/Iterator/FilePathsIteratorTest.php +72 -0
  56. vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php +73 -0
  57. vendor/symfony/finder/Tests/Iterator/FilecontentFilterIteratorTest.php +86 -0
  58. vendor/symfony/finder/Tests/Iterator/FilenameFilterIteratorTest.php +54 -0
  59. vendor/symfony/finder/Tests/Iterator/FilterIteratorTest.php +51 -0
  60. vendor/symfony/finder/Tests/Iterator/Iterator.php +55 -0
  61. vendor/symfony/finder/Tests/Iterator/IteratorTestCase.php +98 -0
  62. vendor/symfony/finder/Tests/Iterator/MockFileListIterator.php +21 -0
  63. vendor/symfony/finder/Tests/Iterator/MockSplFileInfo.php +134 -0
  64. vendor/symfony/finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php +70 -0
  65. vendor/symfony/finder/Tests/Iterator/PathFilterIteratorTest.php +83 -0
  66. vendor/symfony/finder/Tests/Iterator/RealIteratorTestCase.php +110 -0
  67. vendor/symfony/finder/Tests/Iterator/RecursiveDirectoryIteratorTest.php +59 -0
  68. vendor/symfony/finder/Tests/Iterator/SizeRangeFilterIteratorTest.php +69 -0
  69. vendor/symfony/finder/Tests/Iterator/SortableIteratorTest.php +183 -0
  70. vendor/symfony/finder/Tests/PhpFinderTest.php +45 -0
  71. vendor/symfony/finder/Tests/Shell/CommandTest.php +165 -0
  72. vendor/symfony/process/.gitignore +3 -0
  73. vendor/symfony/process/README.md +13 -0
backupwordpress.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: BackUpWordPress
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.6.0
7
  Author: Human Made Limited
8
  Author URI: http://hmn.md/
9
  License: GPL-2+
3
  Plugin Name: BackUpWordPress
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.6.1
7
  Author: Human Made Limited
8
  Author URI: http://hmn.md/
9
  License: GPL-2+
classes/backup/class-backup-engine-database-mysqldump.php CHANGED
@@ -86,7 +86,7 @@ class Mysqldump_Database_Backup_Engine extends Database_Backup_Engine {
86
  */
87
  public function check_user_can_connect_to_database_via_cli() {
88
 
89
- if ( ! function_exists( 'proc_open' ) ) {
90
  return false;
91
  }
92
 
86
  */
87
  public function check_user_can_connect_to_database_via_cli() {
88
 
89
+ if ( ! function_exists( 'proc_open' ) || ! function_exists( 'proc_close' ) ) {
90
  return false;
91
  }
92
 
classes/backup/class-backup-utilities.php CHANGED
@@ -39,7 +39,7 @@ class Backup_Utilities {
39
  */
40
  public static function get_executable_path( $paths ) {
41
 
42
- if ( ! function_exists( 'proc_open' ) ) {
43
  return false;
44
  }
45
 
39
  */
40
  public static function get_executable_path( $paths ) {
41
 
42
+ if ( ! function_exists( 'proc_open' ) || ! function_exists( 'proc_close' ) ) {
43
  return false;
44
  }
45
 
classes/class-plugin.php CHANGED
@@ -6,7 +6,7 @@ namespace HM\BackUpWordPress;
6
  * Class Plugin
7
  */
8
  final class Plugin {
9
- const PLUGIN_VERSION = '3.6.0';
10
 
11
  /**
12
  * @var Plugin The singleton instance.
6
  * Class Plugin
7
  */
8
  final class Plugin {
9
+ const PLUGIN_VERSION = '3.6.1';
10
 
11
  /**
12
  * @var Plugin The singleton instance.
classes/class-requirement.php CHANGED
@@ -748,7 +748,7 @@ class Requirement_Proc_Open extends Requirement {
748
  * @return bool
749
  */
750
  public static function test() {
751
- return function_exists( 'proc_open' );
752
  }
753
  }
754
  Requirements::register( 'HM\BackUpWordPress\Requirement_Proc_Open', 'PHP' );
748
  * @return bool
749
  */
750
  public static function test() {
751
+ return function_exists( 'proc_open' ) && function_exists( 'proc_close' );
752
  }
753
  }
754
  Requirements::register( 'HM\BackUpWordPress\Requirement_Proc_Open', 'PHP' );
functions/interface.php CHANGED
@@ -442,11 +442,17 @@ function is_same_size_format( $size, $other_size ) {
442
  */
443
  function disk_space_low( $backup_size = false ) {
444
 
 
 
 
 
 
 
445
  if ( ! $backup_size ) {
446
 
447
  $site_size = new Site_Size();
448
 
449
- if ( $site_size->is_site_size_cached() ) {
450
  return false;
451
  }
452
 
@@ -454,8 +460,6 @@ function disk_space_low( $backup_size = false ) {
454
 
455
  }
456
 
457
- $disk_space = disk_free_space( Path::get_path() );
458
-
459
  return $backup_size >= $disk_space;
460
 
461
  }
442
  */
443
  function disk_space_low( $backup_size = false ) {
444
 
445
+ $disk_space = @disk_free_space( Path::get_path() );
446
+
447
+ if ( ! $disk_space ) {
448
+ return false;
449
+ }
450
+
451
  if ( ! $backup_size ) {
452
 
453
  $site_size = new Site_Size();
454
 
455
+ if ( ! $site_size->is_site_size_cached() ) {
456
  return false;
457
  }
458
 
460
 
461
  }
462
 
 
 
463
  return $backup_size >= $disk_space;
464
 
465
  }
languages/backupwordpress.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the GPL-2+.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: BackUpWordPress 3.5\n"
6
  "Report-Msgid-Bugs-To: backupwordpress@hmn.md\n"
7
- "POT-Creation-Date: 2016-03-31 17:13:57+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
2
  # This file is distributed under the GPL-2+.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: BackUpWordPress 3.6.1\n"
6
  "Report-Msgid-Bugs-To: backupwordpress@hmn.md\n"
7
+ "POT-Creation-Date: 2016-04-26 15:47:53+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: humanmade, willmot, pauldewouters, joehoyle, mattheu, tcrsavage, c
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.4.2
6
- Stable tag: 3.6.0
7
 
8
  Simple automated backups of your WordPress-powered website.
9
 
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.4.2
6
+ Stable tag: 3.6.1
7
 
8
  Simple automated backups of your WordPress-powered website.
9
 
vendor/composer/autoload_classmap.php CHANGED
@@ -6,4 +6,69 @@ $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  );
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
+ 'Ifsnop\\Mysqldump\\CompressBzip2' => $vendorDir . '/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php',
10
+ 'Ifsnop\\Mysqldump\\CompressGzip' => $vendorDir . '/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php',
11
+ 'Ifsnop\\Mysqldump\\CompressManagerFactory' => $vendorDir . '/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php',
12
+ 'Ifsnop\\Mysqldump\\CompressMethod' => $vendorDir . '/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php',
13
+ 'Ifsnop\\Mysqldump\\CompressNone' => $vendorDir . '/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php',
14
+ 'Ifsnop\\Mysqldump\\Mysqldump' => $vendorDir . '/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php',
15
+ 'Ifsnop\\Mysqldump\\TypeAdapter' => $vendorDir . '/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php',
16
+ 'Ifsnop\\Mysqldump\\TypeAdapterDblib' => $vendorDir . '/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php',
17
+ 'Ifsnop\\Mysqldump\\TypeAdapterFactory' => $vendorDir . '/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php',
18
+ 'Ifsnop\\Mysqldump\\TypeAdapterMysql' => $vendorDir . '/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php',
19
+ 'Ifsnop\\Mysqldump\\TypeAdapterPgsql' => $vendorDir . '/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php',
20
+ 'Ifsnop\\Mysqldump\\TypeAdapterSqlite' => $vendorDir . '/ifsnop/mysqldump-php/src/Ifsnop/Mysqldump/Mysqldump.php',
21
+ 'Symfony\\Component\\Finder\\Adapter\\AbstractAdapter' => $vendorDir . '/symfony/finder/Adapter/AbstractAdapter.php',
22
+ 'Symfony\\Component\\Finder\\Adapter\\AbstractFindAdapter' => $vendorDir . '/symfony/finder/Adapter/AbstractFindAdapter.php',
23
+ 'Symfony\\Component\\Finder\\Adapter\\AdapterInterface' => $vendorDir . '/symfony/finder/Adapter/AdapterInterface.php',
24
+ 'Symfony\\Component\\Finder\\Adapter\\BsdFindAdapter' => $vendorDir . '/symfony/finder/Adapter/BsdFindAdapter.php',
25
+ 'Symfony\\Component\\Finder\\Adapter\\GnuFindAdapter' => $vendorDir . '/symfony/finder/Adapter/GnuFindAdapter.php',
26
+ 'Symfony\\Component\\Finder\\Adapter\\PhpAdapter' => $vendorDir . '/symfony/finder/Adapter/PhpAdapter.php',
27
+ 'Symfony\\Component\\Finder\\Comparator\\Comparator' => $vendorDir . '/symfony/finder/Comparator/Comparator.php',
28
+ 'Symfony\\Component\\Finder\\Comparator\\DateComparator' => $vendorDir . '/symfony/finder/Comparator/DateComparator.php',
29
+ 'Symfony\\Component\\Finder\\Comparator\\NumberComparator' => $vendorDir . '/symfony/finder/Comparator/NumberComparator.php',
30
+ 'Symfony\\Component\\Finder\\Exception\\AccessDeniedException' => $vendorDir . '/symfony/finder/Exception/AccessDeniedException.php',
31
+ 'Symfony\\Component\\Finder\\Exception\\AdapterFailureException' => $vendorDir . '/symfony/finder/Exception/AdapterFailureException.php',
32
+ 'Symfony\\Component\\Finder\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/finder/Exception/ExceptionInterface.php',
33
+ 'Symfony\\Component\\Finder\\Exception\\OperationNotPermitedException' => $vendorDir . '/symfony/finder/Exception/OperationNotPermitedException.php',
34
+ 'Symfony\\Component\\Finder\\Exception\\ShellCommandFailureException' => $vendorDir . '/symfony/finder/Exception/ShellCommandFailureException.php',
35
+ 'Symfony\\Component\\Finder\\Expression\\Expression' => $vendorDir . '/symfony/finder/Expression/Expression.php',
36
+ 'Symfony\\Component\\Finder\\Expression\\Glob' => $vendorDir . '/symfony/finder/Expression/Glob.php',
37
+ 'Symfony\\Component\\Finder\\Expression\\Regex' => $vendorDir . '/symfony/finder/Expression/Regex.php',
38
+ 'Symfony\\Component\\Finder\\Expression\\ValueInterface' => $vendorDir . '/symfony/finder/Expression/ValueInterface.php',
39
+ 'Symfony\\Component\\Finder\\Finder' => $vendorDir . '/symfony/finder/Finder.php',
40
+ 'Symfony\\Component\\Finder\\Glob' => $vendorDir . '/symfony/finder/Glob.php',
41
+ 'Symfony\\Component\\Finder\\Iterator\\CustomFilterIterator' => $vendorDir . '/symfony/finder/Iterator/CustomFilterIterator.php',
42
+ 'Symfony\\Component\\Finder\\Iterator\\DateRangeFilterIterator' => $vendorDir . '/symfony/finder/Iterator/DateRangeFilterIterator.php',
43
+ 'Symfony\\Component\\Finder\\Iterator\\DepthRangeFilterIterator' => $vendorDir . '/symfony/finder/Iterator/DepthRangeFilterIterator.php',
44
+ 'Symfony\\Component\\Finder\\Iterator\\ExcludeDirectoryFilterIterator' => $vendorDir . '/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.php',
45
+ 'Symfony\\Component\\Finder\\Iterator\\FilePathsIterator' => $vendorDir . '/symfony/finder/Iterator/FilePathsIterator.php',
46
+ 'Symfony\\Component\\Finder\\Iterator\\FileTypeFilterIterator' => $vendorDir . '/symfony/finder/Iterator/FileTypeFilterIterator.php',
47
+ 'Symfony\\Component\\Finder\\Iterator\\FilecontentFilterIterator' => $vendorDir . '/symfony/finder/Iterator/FilecontentFilterIterator.php',
48
+ 'Symfony\\Component\\Finder\\Iterator\\FilenameFilterIterator' => $vendorDir . '/symfony/finder/Iterator/FilenameFilterIterator.php',
49
+ 'Symfony\\Component\\Finder\\Iterator\\FilterIterator' => $vendorDir . '/symfony/finder/Iterator/FilterIterator.php',
50
+ 'Symfony\\Component\\Finder\\Iterator\\MultiplePcreFilterIterator' => $vendorDir . '/symfony/finder/Iterator/MultiplePcreFilterIterator.php',
51
+ 'Symfony\\Component\\Finder\\Iterator\\PathFilterIterator' => $vendorDir . '/symfony/finder/Iterator/PathFilterIterator.php',
52
+ 'Symfony\\Component\\Finder\\Iterator\\RecursiveDirectoryIterator' => $vendorDir . '/symfony/finder/Iterator/RecursiveDirectoryIterator.php',
53
+ 'Symfony\\Component\\Finder\\Iterator\\SizeRangeFilterIterator' => $vendorDir . '/symfony/finder/Iterator/SizeRangeFilterIterator.php',
54
+ 'Symfony\\Component\\Finder\\Iterator\\SortableIterator' => $vendorDir . '/symfony/finder/Iterator/SortableIterator.php',
55
+ 'Symfony\\Component\\Finder\\Shell\\Command' => $vendorDir . '/symfony/finder/Shell/Command.php',
56
+ 'Symfony\\Component\\Finder\\Shell\\Shell' => $vendorDir . '/symfony/finder/Shell/Shell.php',
57
+ 'Symfony\\Component\\Finder\\SplFileInfo' => $vendorDir . '/symfony/finder/SplFileInfo.php',
58
+ 'Symfony\\Component\\Process\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/process/Exception/ExceptionInterface.php',
59
+ 'Symfony\\Component\\Process\\Exception\\InvalidArgumentException' => $vendorDir . '/symfony/process/Exception/InvalidArgumentException.php',
60
+ 'Symfony\\Component\\Process\\Exception\\LogicException' => $vendorDir . '/symfony/process/Exception/LogicException.php',
61
+ 'Symfony\\Component\\Process\\Exception\\ProcessFailedException' => $vendorDir . '/symfony/process/Exception/ProcessFailedException.php',
62
+ 'Symfony\\Component\\Process\\Exception\\ProcessTimedOutException' => $vendorDir . '/symfony/process/Exception/ProcessTimedOutException.php',
63
+ 'Symfony\\Component\\Process\\Exception\\RuntimeException' => $vendorDir . '/symfony/process/Exception/RuntimeException.php',
64
+ 'Symfony\\Component\\Process\\ExecutableFinder' => $vendorDir . '/symfony/process/ExecutableFinder.php',
65
+ 'Symfony\\Component\\Process\\PhpExecutableFinder' => $vendorDir . '/symfony/process/PhpExecutableFinder.php',
66
+ 'Symfony\\Component\\Process\\PhpProcess' => $vendorDir . '/symfony/process/PhpProcess.php',
67
+ 'Symfony\\Component\\Process\\Pipes\\AbstractPipes' => $vendorDir . '/symfony/process/Pipes/AbstractPipes.php',
68
+ 'Symfony\\Component\\Process\\Pipes\\PipesInterface' => $vendorDir . '/symfony/process/Pipes/PipesInterface.php',
69
+ 'Symfony\\Component\\Process\\Pipes\\UnixPipes' => $vendorDir . '/symfony/process/Pipes/UnixPipes.php',
70
+ 'Symfony\\Component\\Process\\Pipes\\WindowsPipes' => $vendorDir . '/symfony/process/Pipes/WindowsPipes.php',
71
+ 'Symfony\\Component\\Process\\Process' => $vendorDir . '/symfony/process/Process.php',
72
+ 'Symfony\\Component\\Process\\ProcessBuilder' => $vendorDir . '/symfony/process/ProcessBuilder.php',
73
+ 'Symfony\\Component\\Process\\ProcessUtils' => $vendorDir . '/symfony/process/ProcessUtils.php',
74
  );
vendor/ifsnop/mysqldump-php/.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ /.project
2
+ /composer.phar
3
+ /.settings
4
+ /vendor/
vendor/ifsnop/mysqldump-php/.scrutinizer.yml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ before_commands:
2
+ - 'composer install --dev --prefer-source'
3
+
4
+ checks:
5
+ php: true
6
+
7
+ filter:
8
+ excluded_paths: [vendor/*, tests/*]
9
+
10
+ tools:
11
+ php_mess_detector:
12
+ enabled: true
13
+ config:
14
+ controversial_rules:
15
+ camel_case_method_name: false
16
+
17
+ sensiolabs_security_checker: true
18
+
19
+ # Analyzes the size and structure of a PHP project.
20
+ php_pdepend: true
21
+ php_loc:
22
+ enabled: true
23
+
24
+ # We recommend to use PHP Code Similarity Analyzer instead as it is
25
+ # robust against code modifications and provides better targets for
26
+ # refactoring.
27
+ php_cpd: false
28
+ php_sim: true
29
+
30
+ # PHP Analyzer is our own analysis tool for PHP code. It’s latest
31
+ # version is exclusively available through the hosted version on
32
+ # scrutinizer-ci.com.
33
+ php_analyzer: true
34
+ php_code_sniffer:
35
+ enabled: true
36
+ config:
37
+ standard: "PSR1"
38
+ sniffs:
39
+ generic:
40
+ naming_conventions:
41
+ camel_caps_function_name_sniff: false
42
+ files:
43
+ one_class_per_file_sniff: false
vendor/ifsnop/mysqldump-php/.travis.yml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ sudo: false
2
+
3
+ language: php
4
+
5
+ php:
6
+ - 5.6
7
+ - 5.5
8
+ - 5.4
9
+ - 5.3
10
+ - hhvm
11
+ - nightly
12
+
13
+ services:
14
+ - mysql
15
+
16
+ before_script:
17
+ - curl -s http://getcomposer.org/installer | php
18
+ - php composer.phar install --dev
19
+
20
+ script:
21
+ - php src/Ifsnop/Mysqldump/Mysqldump.php
22
+ - cd tests && ./test.sh
vendor/ifsnop/mysqldump-php/README.md ADDED
@@ -0,0 +1,266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MySQLDump - PHP
2
+ =========
3
+
4
+ [Requirements](https://github.com/ifsnop/mysqldump-php#requirements) |
5
+ [Installing](https://github.com/ifsnop/mysqldump-php#installing) |
6
+ [Getting started](https://github.com/ifsnop/mysqldump-php#getting-started) |
7
+ [API](https://github.com/ifsnop/mysqldump-php#constructor-and-default-parameters) |
8
+ [Settings](https://github.com/ifsnop/mysqldump-php#dump-settings) |
9
+ [PDO Settings](https://github.com/ifsnop/mysqldump-php#pdo-settings) |
10
+ [TODO](https://github.com/ifsnop/mysqldump-php#todo) |
11
+ [License](https://github.com/ifsnop/mysqldump-php#license) |
12
+ [Credits](https://github.com/ifsnop/mysqldump-php#credits)
13
+
14
+ [![Build Status](https://travis-ci.org/ifsnop/mysqldump-php.svg?branch=devel)](https://travis-ci.org/ifsnop/mysqldump-php)
15
+ [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/ifsnop/mysqldump-php/badges/quality-score.png?s=d02891e196a3ca1298619032a538ce8ae8cafd2b)](https://scrutinizer-ci.com/g/ifsnop/mysqldump-php/)
16
+ [![Latest Stable Version](https://poser.pugx.org/ifsnop/mysqldump-php/v/stable.png)](https://packagist.org/packages/ifsnop/mysqldump-php)
17
+
18
+ This is a php version of linux's mysqldump in terminal "$ mysqldump -u username -p...", without dependencies, output compression and sane defaults.
19
+
20
+ Out of the box, MySQLDump-PHP supports backing up table structures, the data itself, views and triggers.
21
+
22
+ MySQLDump-PHP is the only library that supports:
23
+ * output binary blobs as hex.
24
+ * resolves view dependencies (using Stand-In tables).
25
+ * output compared against original mysqldump. Linked to travis-ci testing system.
26
+ * dumps stored procedures.
27
+
28
+ ## Important
29
+
30
+ From version 2.0, connections to database are made using the standard DSN, documented in [PDO connection string](http://php.net/manual/en/ref.pdo-mysql.connection.php).
31
+
32
+ ## Requirements
33
+
34
+ - PHP 5.3.0 or newer
35
+ - MySQL 4.1.0 or newer
36
+ - [PDO](http://php.net/pdo)
37
+
38
+ ## Installing
39
+
40
+ Using [Composer](http://getcomposer.org):
41
+
42
+ ```
43
+ $ composer require ifsnop/mysqldump-php:2.*
44
+
45
+ ```
46
+
47
+ Or via json file:
48
+
49
+ ````
50
+ "require": {
51
+ "ifsnop/mysqldump-php":"2.*"
52
+ }
53
+ ````
54
+
55
+ Using [Curl](http://curl.haxx.se):
56
+
57
+ ```
58
+ $ curl --silent --location https://github.com/ifsnop/mysqldump-php/archive/v2.0.0.tar.gz | tar xvfz -
59
+ ```
60
+
61
+ ## Getting started
62
+
63
+ With [Autoloader](http://www.php-fig.org/psr/psr-4/)/[Composer](http://getcomposer.org):
64
+
65
+ ```
66
+ <?php
67
+
68
+ use Ifsnop\Mysqldump as IMysqldump;
69
+
70
+ try {
71
+ $dump = new IMysqldump\Mysqldump('mysql:host=localhost;dbname=testdb', 'username', 'password');
72
+ $dump->start('storage/work/dump.sql');
73
+ } catch (\Exception $e) {
74
+ echo 'mysqldump-php error: ' . $e->getMessage();
75
+ }
76
+
77
+ ?>
78
+ ```
79
+
80
+ Plain old PHP:
81
+
82
+ ```
83
+ <?php
84
+
85
+ include_once(dirname(__FILE__) . '/mysqldump-php-2.0.0/src/Ifsnop/Mysqldump/Mysqldump.php');
86
+ $dump = new Ifsnop\Mysqldump\Mysqldump('mysql:host=localhost;dbname=testdb', 'username', 'password');
87
+ $dump->start('storage/work/dump.sql');
88
+
89
+ ?>
90
+ ```
91
+
92
+ Refer to the [wiki](https://github.com/ifsnop/mysqldump-php/wiki/full-example) for some examples and a comparision between mysqldump and mysqldump-php dumps.
93
+
94
+ ## Constructor and default parameters
95
+ /**
96
+ * Constructor of Mysqldump. Note that in the case of an SQLite database
97
+ * connection, the filename must be in the $db parameter.
98
+ *
99
+ * @param string $dsn PDO DSN connection string
100
+ * @param string $user SQL account username
101
+ * @param string $pass SQL account password
102
+ * @param array $dumpSettings SQL database settings
103
+ * @param array $pdoSettings PDO configured attributes
104
+ */
105
+ public function __construct(
106
+ $dsn = '',
107
+ $user = '',
108
+ $pass = '',
109
+ $dumpSettings = array(),
110
+ $pdoSettings = array()
111
+ )
112
+
113
+ $dumpSettingsDefault = array(
114
+ 'include-tables' => array(),
115
+ 'exclude-tables' => array(),
116
+ 'compress' => 'None',
117
+ 'no-data' => false,
118
+ 'add-drop-table' => false,
119
+ 'single-transaction' => true,
120
+ 'lock-tables' => false,
121
+ 'add-locks' => true,
122
+ 'extended-insert' => true,
123
+ 'disable-keys' => true,
124
+ 'where' => '',
125
+ 'no-create-info' => false,
126
+ 'skip-triggers' => false,
127
+ 'add-drop-trigger' => true,
128
+ 'routines' => false,
129
+ 'hex-blob' => true,
130
+ 'databases' => false,
131
+ 'add-drop-database' => false,
132
+ 'skip-tz-utc' => false,
133
+ 'no-autocommit' => true,
134
+ 'default-character-set' => 'utf8',
135
+ 'skip-comments' => false,
136
+ 'skip-dump-date' => false,
137
+ );
138
+
139
+ $pdoSettingsDefaults = array(
140
+ PDO::ATTR_PERSISTENT => true,
141
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
142
+ PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false
143
+ );
144
+
145
+ // missing settings in constructor will be replaced by default options
146
+ $this->_pdoSettings = self::array_replace_recursive($pdoSettingsDefault, $pdoSettings);
147
+ $this->_dumpSettings = self::array_replace_recursive($dumpSettingsDefault, $dumpSettings);
148
+
149
+ ## Dump Settings
150
+
151
+ - **include-tables**
152
+ - Only include these tables (array of table names)
153
+ - **exclude-tables**
154
+ - Exclude these tables (array of table names)
155
+ - **compress**
156
+ - Gzip, Bzip2, None.
157
+ - Could be specified using the declared consts: IMysqldump\Mysqldump::GZIP, IMysqldump\Mysqldump::BZIP2 or IMysqldump\Mysqldump::NONE
158
+ - **no-data**
159
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_no-data
160
+ - **add-drop-table**
161
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_add-drop-table
162
+ - **single-transaction**
163
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_single-transaction
164
+ - **lock-tables**
165
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_lock-tables
166
+ - **add-locks**
167
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_add-locks
168
+ - **extended-insert**
169
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_extended-insert
170
+ - **disable-keys**
171
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_disable-keys
172
+ - **where**
173
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_where
174
+ - **no-create-info**
175
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_no-create-info
176
+ - **skip-triggers**
177
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_triggers
178
+ - **add-drop-triggers**
179
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_add-drop-trigger
180
+ - **routines**
181
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_routines
182
+ - **hex-blob**
183
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_hex-blob
184
+ - **databases**
185
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_databases
186
+ - **add-drop-database**
187
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_add-drop-database
188
+ - **skip-tz-utc**
189
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_tz-utc
190
+ - **no-autocommit**
191
+ - Option to disable autocommit (faster inserts, no problems with index keys)
192
+ - http://dev.mysql.com/doc/refman/4.1/en/commit.html
193
+ - **default-character-set**
194
+ - utf8 (default, compatible option), utf8mb4 (for full utf8 compliance)
195
+ - Could be specified using the declared consts: IMysqldump\Mysqldump::UTF8 or IMysqldump\Mysqldump::UTF8MB4BZIP2
196
+ - http://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html
197
+ - https://mathiasbynens.be/notes/mysql-utf8mb4
198
+ - **skip-comments**
199
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_comments
200
+ - **skip-dump-date**
201
+ - http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html#option_mysqldump_dump-date
202
+
203
+ The following options are now enabled by default, and there is no way to disable them since
204
+ they should always be used.
205
+
206
+ - **disable-foreign-keys-check**
207
+ - http://dev.mysql.com/doc/refman/5.5/en/optimizing-innodb-bulk-data-loading.html
208
+
209
+ ## PDO Settings
210
+
211
+ - **PDO::ATTR_PERSISTENT**
212
+ - **PDO::ATTR_ERRMODE**
213
+ - **PDO::MYSQL_ATTR_INIT_COMMAND**
214
+ - **PDO::MYSQL_ATTR_USE_BUFFERED_QUERY**
215
+ - http://www.php.net/manual/en/ref.pdo-mysql.php
216
+ - http://stackoverflow.com/questions/13728106/unexpectedly-hitting-php-memory-limit-with-a-single-pdo-query/13729745#13729745
217
+ - http://www.php.net/manual/en/mysqlinfo.concepts.buffering.php
218
+
219
+ ## Errors
220
+
221
+ To dump a database, you need the following privileges :
222
+
223
+ - **SELECT**
224
+ - In order to dump table structures and data.
225
+ - **SHOW VIEW**
226
+ - If any databases has views, else you will get an error.
227
+ - **TRIGGER**
228
+ - If any table has one or more triggers.
229
+ - **LOCK TABLES**
230
+ - If "lock tables" option was enabled.
231
+
232
+ Use **SHOW GRANTS FOR user@host;** to know what privileges user has. See the following link for more information:
233
+
234
+ [Which are the minimum privileges required to get a backup of a MySQL database schema?](http://dba.stackexchange.com/questions/55546/which-are-the-minimum-privileges-required-to-get-a-backup-of-a-mysql-database-sc/55572#55572)
235
+
236
+ ## Tests
237
+
238
+ Current code for testing is an ugly hack. Probably there are much better ways
239
+ of doing them using PHPUnit, so PR's are welcomed. The testing script creates
240
+ and populates a database using all possible datatypes. Then it exports it
241
+ using both mysqldump-php and mysqldump, and compares the output. Only if
242
+ it is identical tests are OK.
243
+
244
+ ## TODO
245
+
246
+ ...
247
+
248
+ ## Contributing
249
+
250
+ Format all code to PHP-FIG standards.
251
+ http://www.php-fig.org/
252
+
253
+ ## License
254
+
255
+ This project is open-sourced software licensed under the [GPL license](http://www.gnu.org/copyleft/gpl.html)
256
+
257
+ ## Credits
258
+
259
+ Originally based on James Elliott's script from 2009.
260
+ http://code.google.com/p/db-mysqldump/
261
+
262
+ Adapted and extended by Michael J. Calkins.
263
+ https://github.com/clouddueling
264
+
265
+ Currently maintained and developed by Diego Torres.
266
+ https://github.com/ifsnop
vendor/ifsnop/mysqldump-php/phpunit.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ processIsolation="false"
10
+ stopOnFailure="false"
11
+ syntaxCheck="false"
12
+ >
13
+ <testsuites>
14
+ <testsuite name="Package Test Suite">
15
+ <directory suffix=".php">./tests/</directory>
16
+ </testsuite>
17
+ </testsuites>
18
+ </phpunit>
vendor/ifsnop/mysqldump-php/tests/test.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ for($i=0;$i<128;$i++) {
4
+ echo "$i>" . bin2hex(chr($i)) . "<" . PHP_EOL;
5
+ }
6
+ */
7
+
8
+ error_reporting(E_ALL);
9
+
10
+ include_once(dirname(__FILE__) . "/../src/Ifsnop/Mysqldump/Mysqldump.php");
11
+
12
+ use Ifsnop\Mysqldump as IMysqldump;
13
+
14
+ $dumpSettings = array(
15
+ 'compress' => IMysqldump\Mysqldump::NONE,
16
+ 'no-data' => false,
17
+ 'add-drop-table' => true,
18
+ 'single-transaction' => true,
19
+ 'lock-tables' => true,
20
+ 'add-locks' => true,
21
+ 'extended-insert' => false,
22
+ 'disable-keys' => true,
23
+ 'skip-triggers' => false,
24
+ 'add-drop-trigger' => true,
25
+ 'routines' => true,
26
+ 'databases' => false,
27
+ 'add-drop-database' => false,
28
+ 'hex-blob' => true,
29
+ 'no-create-info' => false,
30
+ 'where' => ''
31
+ );
32
+
33
+ $dump = new IMysqldump\Mysqldump(
34
+ "mysql:host=localhost;dbname=test001",
35
+ "travis",
36
+ "",
37
+ $dumpSettings);
38
+
39
+ $dump->start("mysqldump-php_test001.sql");
40
+
41
+ $dumpSettings['default-character-set'] = IMysqldump\Mysqldump::UTF8MB4;
42
+
43
+ $dump = new IMysqldump\Mysqldump(
44
+ "mysql:host=localhost;dbname=test002",
45
+ "travis",
46
+ "",
47
+ $dumpSettings);
48
+
49
+ $dump->start("mysqldump-php_test002.sql");
50
+
51
+ $dump = new IMysqldump\Mysqldump(
52
+ "mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=test005",
53
+ "travis",
54
+ "",
55
+ $dumpSettings);
56
+
57
+ $dump->start("mysqldump-php_test005.sql");
58
+
59
+ $dump = new IMysqldump\Mysqldump(
60
+ "mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=test006a",
61
+ "travis",
62
+ "",
63
+ array("no-data" => true, "add-drop-table" => true));
64
+
65
+ $dump->start("mysqldump-php_test006.sql");
66
+
67
+ exit;
vendor/ifsnop/mysqldump-php/tests/test.sh ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ function checksum_test001() {
4
+ for i in 000 001 002 003 010 011 015 027 029 033 200; do
5
+ mysql -B -e "CHECKSUM TABLE test${i}" test001 | grep -v -i checksum
6
+ done
7
+ }
8
+
9
+ function checksum_test002() {
10
+ for i in 201; do
11
+ mysql --default-character-set=utf8mb4 -B -e "CHECKSUM TABLE test${i}" test002 | grep -v -i checksum
12
+ done
13
+ }
14
+
15
+ function checksum_test005() {
16
+ for i in 000; do
17
+ mysql -B -e "CHECKSUM TABLE test${i}" test001 | grep -v -i checksum
18
+ done
19
+ }
20
+
21
+ for i in $(seq 0 20) ; do
22
+ ret[$i]=0
23
+ done
24
+
25
+ index=0
26
+
27
+ mysql -e "CREATE USER 'travis'@'localhost' IDENTIFIED BY '';" 2> /dev/null
28
+ mysql -e "CREATE DATABASE test001;" 2> /dev/null
29
+ mysql -e "CREATE DATABASE test002;" 2> /dev/null
30
+ mysql -e "CREATE DATABASE test005;" 2> /dev/null
31
+ mysql -e "CREATE DATABASE test006a;" 2> /dev/null
32
+ mysql -e "CREATE DATABASE test006b;" 2> /dev/null
33
+ mysql -e "GRANT ALL PRIVILEGES ON test001.* TO 'travis'@'localhost';" 2> /dev/null
34
+ mysql -e "GRANT SELECT ON mysql.proc to 'travis'@'localhost';" 2> /dev/null
35
+ mysql -e "GRANT ALL PRIVILEGES ON test002.* TO 'travis'@'localhost';" 2> /dev/null
36
+ mysql -e "GRANT ALL PRIVILEGES ON test005.* TO 'travis'@'localhost';" 2> /dev/null
37
+ mysql -e "GRANT ALL PRIVILEGES ON test006a.* TO 'travis'@'localhost';" 2> /dev/null
38
+ mysql -e "GRANT ALL PRIVILEGES ON test00ba.* TO 'travis'@'localhost';" 2> /dev/null
39
+ mysql -e "FLUSH PRIVILEGES;" 2> /dev/null
40
+
41
+ mysql -uroot < test001.src.sql; ret[((index++))]=$?
42
+ mysql -uroot --default-character-set=utf8mb4 < test002.src.sql; ret[((index++))]=$?
43
+ mysql -uroot < test005.src.sql; ret[((index++))]=$?
44
+ mysql -uroot < test006.src.sql; ret[((index++))]=$?
45
+
46
+ checksum_test001 > test001.src.checksum
47
+ checksum_test002 > test002.src.checksum
48
+ checksum_test005 > test005.src.checksum
49
+
50
+ mysqldump -uroot test001 \
51
+ --no-autocommit \
52
+ --extended-insert=false \
53
+ --hex-blob=true \
54
+ --routines=true \
55
+ > mysqldump_test001.sql
56
+ ret[((index++))]=$?
57
+
58
+ mysqldump -uroot test002 \
59
+ --no-autocommit \
60
+ --extended-insert=false \
61
+ --hex-blob=true \
62
+ --default-character-set=utf8mb4 \
63
+ > mysqldump_test002.sql
64
+ ret[((index++))]=$?
65
+
66
+ mysqldump -uroot test005 \
67
+ --no-autocommit \
68
+ --extended-insert=false \
69
+ --hex-blob=true \
70
+ > mysqldump_test005.sql
71
+ ret[((index++))]=$?
72
+
73
+ php test.php
74
+ ret[((index++))]=$?
75
+
76
+ mysql -uroot test001 < mysqldump-php_test001.sql
77
+ ret[((index++))]=$?
78
+ mysql -uroot test002 < mysqldump-php_test002.sql
79
+ ret[((index++))]=$?
80
+ mysql -uroot test005 < mysqldump-php_test005.sql
81
+ ret[((index++))]=$?
82
+
83
+ mysql -uroot test006b < mysqldump-php_test006.sql
84
+ ret[((index++))]=$?
85
+
86
+ checksum_test001 > mysqldump-php_test001.checksum
87
+ checksum_test002 > mysqldump-php_test002.checksum
88
+ checksum_test005 > mysqldump-php_test005.checksum
89
+
90
+ cat test001.src.sql | grep ^INSERT > test001.filtered.sql
91
+ cat test002.src.sql | grep ^INSERT > test002.filtered.sql
92
+ cat test005.src.sql | grep ^INSERT > test005.filtered.sql
93
+ cat mysqldump_test001.sql | grep ^INSERT > mysqldump_test001.filtered.sql
94
+ cat mysqldump_test002.sql | grep ^INSERT > mysqldump_test002.filtered.sql
95
+ cat mysqldump_test005.sql | grep ^INSERT > mysqldump_test005.filtered.sql
96
+ cat mysqldump-php_test001.sql | grep ^INSERT > mysqldump-php_test001.filtered.sql
97
+ cat mysqldump-php_test002.sql | grep ^INSERT > mysqldump-php_test002.filtered.sql
98
+ cat mysqldump-php_test005.sql | grep ^INSERT > mysqldump-php_test005.filtered.sql
99
+
100
+ diff test001.filtered.sql mysqldump_test001.filtered.sql
101
+ ret[((index++))]=$?
102
+ diff test002.filtered.sql mysqldump_test002.filtered.sql
103
+ ret[((index++))]=$?
104
+
105
+ diff test001.filtered.sql mysqldump-php_test001.filtered.sql
106
+ ret[((index++))]=$?
107
+ diff test002.filtered.sql mysqldump-php_test002.filtered.sql
108
+ ret[((index++))]=$?
109
+
110
+ diff test001.src.checksum mysqldump-php_test001.checksum
111
+ ret[((index++))]=$?
112
+ diff test002.src.checksum mysqldump-php_test002.checksum
113
+ ret[((index++))]=$?
114
+ diff test005.src.checksum mysqldump-php_test005.checksum
115
+ ret[((index++))]=$?
116
+
117
+ diff mysqldump_test005.filtered.sql mysqldump-php_test005.filtered.sql
118
+ ret[((index++))]=$?
119
+ rm *.checksum 2> /dev/null
120
+ rm *.filtered.sql 2> /dev/null
121
+ rm mysqldump* 2> /dev/null
122
+
123
+ echo "Done $index tests"
124
+
125
+ total=0
126
+ for i in $(seq 0 20) ; do
127
+ total=$((${ret[$i]} + $total))
128
+ done
129
+
130
+ echo "Exiting with code $total"
131
+
132
+ exit $total
vendor/ifsnop/mysqldump-php/tests/test001.src.sql ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ DROP DATABASE IF EXISTS `test001`;
2
+ CREATE DATABASE `test001`;
3
+ USE `test001`;
4
+
5
+ DROP TABLE IF EXISTS `test000`;
6
+ CREATE TABLE `test000` (
7
+ `id` int,
8
+ `col01` bit(6) DEFAULT NULL,
9
+ `col02` tinyint(4) DEFAULT NULL,
10
+ `col03` tinyint(4) UNSIGNED DEFAULT NULL,
11
+ `col10` bigint DEFAULT NULL,
12
+ `col11` bigint UNSIGNED DEFAULT NULL,
13
+ `col15` double DEFAULT NULL,
14
+ `col27` varchar(6) DEFAULT NULL
15
+ );
16
+ INSERT INTO `test000` VALUES (1,0x21,-128,255,-9223372036854775808,18446744073709551615,-2.2250738585072014e-308,'0abcde');
17
+
18
+ DROP TABLE IF EXISTS `test001`;
19
+ CREATE TABLE `test001` (
20
+ `id` int,
21
+ `col` bit(1) DEFAULT NULL
22
+ );
23
+ INSERT INTO `test001` VALUES (1,NULL);
24
+ INSERT INTO `test001` VALUES (2,0x00);
25
+ INSERT INTO `test001` VALUES (3,0x01);
26
+
27
+ DROP TABLE IF EXISTS `test002`;
28
+ CREATE TABLE `test002` (
29
+ `id` int,
30
+ `col` tinyint(4) DEFAULT NULL
31
+ );
32
+ INSERT INTO `test002` VALUES (1,NULL);
33
+ INSERT INTO `test002` VALUES (2,-128);
34
+ INSERT INTO `test002` VALUES (3,0);
35
+ INSERT INTO `test002` VALUES (4,127);
36
+
37
+ DROP TABLE IF EXISTS `test003`;
38
+ CREATE TABLE `test003` (
39
+ `id` int,
40
+ `col` tinyint(4) UNSIGNED DEFAULT NULL
41
+ );
42
+ INSERT INTO `test003` VALUES (1,NULL);
43
+ INSERT INTO `test003` VALUES (2,0);
44
+ INSERT INTO `test003` VALUES (3,255);
45
+
46
+ DROP TABLE IF EXISTS `test010`;
47
+ CREATE TABLE `test010` (
48
+ `id` int,
49
+ `col` bigint DEFAULT NULL
50
+ );
51
+ INSERT INTO `test010` VALUES (1,NULL);
52
+ INSERT INTO `test010` VALUES (2,-9223372036854775808);
53
+ INSERT INTO `test010` VALUES (3,0);
54
+ INSERT INTO `test010` VALUES (4,9223372036854775807);
55
+
56
+ DROP TABLE IF EXISTS `test011`;
57
+ CREATE TABLE `test011` (
58
+ `id` int,
59
+ `col` bigint UNSIGNED DEFAULT NULL
60
+ );
61
+ INSERT INTO `test011` VALUES (1,NULL);
62
+ INSERT INTO `test011` VALUES (3,0);
63
+ INSERT INTO `test011` VALUES (4,18446744073709551615);
64
+
65
+
66
+ DROP TABLE IF EXISTS `test015`;
67
+ CREATE TABLE `test015` (
68
+ `id` int,
69
+ `col` double DEFAULT NULL
70
+ );
71
+ INSERT INTO `test015` VALUES (1,NULL);
72
+ INSERT INTO `test015` VALUES (2,-1.7976931348623157e308);
73
+ INSERT INTO `test015` VALUES (3,-2.2250738585072014e-308);
74
+ INSERT INTO `test015` VALUES (4,0);
75
+ INSERT INTO `test015` VALUES (5,2.2250738585072014e-308);
76
+ INSERT INTO `test015` VALUES (6,1.7976931348623157e308);
77
+
78
+
79
+ DROP TABLE IF EXISTS `test027`;
80
+ CREATE TABLE `test027` (
81
+ `id` int,
82
+ `col` varchar(6) DEFAULT NULL
83
+ );
84
+ INSERT INTO `test027` VALUES (1,NULL);
85
+ INSERT INTO `test027` VALUES (2,'');
86
+ INSERT INTO `test027` VALUES (3,'0');
87
+ INSERT INTO `test027` VALUES (4,'2e308');
88
+ INSERT INTO `test027` VALUES (5,'999.99');
89
+ INSERT INTO `test027` VALUES (6,'-2e-30');
90
+ INSERT INTO `test027` VALUES (7,'-99.99');
91
+ INSERT INTO `test027` VALUES (8,'0');
92
+ INSERT INTO `test027` VALUES (9,'0abcde');
93
+ INSERT INTO `test027` VALUES (10,'123');
94
+
95
+ DROP TABLE IF EXISTS `test029`;
96
+ CREATE TABLE `test029` (
97
+ `id` int,
98
+ `col` blob NOT NULL
99
+ );
100
+ INSERT INTO `test029` VALUES (1,0x00010203040506070809909192939495969798A9);
101
+ INSERT INTO `test029` VALUES (2,'');
102
+
103
+ DROP TABLE IF EXISTS `test033`;
104
+ CREATE TABLE `test033` (
105
+ `id` int,
106
+ `col` text NOT NULL
107
+ );
108
+ INSERT INTO `test033` VALUES (1,'test test test');
109
+
110
+
111
+ DROP VIEW IF EXISTS `test100`;
112
+ CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `test100` AS select `test000`.`id` AS `id`,`test000`.`col01` AS `col01`,`test000`.`col02` AS `col02`,`test000`.`col03` AS `col03`,`test000`.`col10` AS `col10`,`test000`.`col11` AS `col11`,`test000`.`col15` AS `col15`,`test000`.`col27` AS `col27` from `test000`;
113
+
114
+ DROP VIEW IF EXISTS `test127`;
115
+ CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `test127` AS select `test027`.`id` AS `id`,`test027`.`col` AS `col` from `test027`;
116
+
117
+
118
+ DROP TABLE IF EXISTS `test200`;
119
+ CREATE TABLE `test200` (
120
+ `id` int,
121
+ `col` tinyint(4) DEFAULT NULL
122
+ );
123
+
124
+ CREATE TRIGGER before_test200_insert
125
+ BEFORE insert ON `test200`
126
+ FOR EACH ROW set NEW.col = NEW.col + 1;
127
+
128
+ -- INSERT INTO `test200` VALUES (1,1); -- trigger tests
129
+
130
+ /*!50003 DROP PROCEDURE IF EXISTS `GetAllFromTest000` */;
131
+ DELIMITER //
132
+ CREATE PROCEDURE GetAllFromTest000()
133
+ BEGIN
134
+ SELECT * FROM test000;
135
+ END //
136
+ DELIMITER ;
vendor/ifsnop/mysqldump-php/tests/test002.src.sql ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ DROP DATABASE IF EXISTS `test002`;
2
+ CREATE DATABASE `test002`;
3
+ USE `test002`;
4
+
5
+ DROP TABLE IF EXISTS `test201`;
6
+ CREATE TABLE `test201` (
7
+ `col` text COLLATE utf8mb4_unicode_ci
8
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
9
+
10
+ INSERT INTO `test201` VALUES ('áéíóú');
11
+ INSERT INTO `test201` VALUES ('🎲');
12
+ INSERT INTO `test201` VALUES ('🎭');
13
+ INSERT INTO `test201` VALUES ('💩');
14
+ INSERT INTO `test201` VALUES ('🐈');
vendor/ifsnop/mysqldump-php/tests/test005.src.sql ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ DROP DATABASE IF EXISTS `test005`;
2
+ CREATE DATABASE `test005`;
3
+ USE `test005`;
4
+
5
+ SET TIME_ZONE='+07:00';
6
+ DROP TABLE IF EXISTS `test000`;
7
+ CREATE TABLE `test000`(
8
+ `id` int,
9
+ `col` TIMESTAMP NOT NULL
10
+ );
11
+ INSERT INTO `test000` VALUES (1,'2014-01-01 00:00:00');
12
+ SET TIME_ZONE='+00:00';
vendor/ifsnop/mysqldump-php/tests/test006.src.sql ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -- phpMyAdmin SQL Dump
2
+ -- version 4.4.0
3
+ -- http://www.phpmyadmin.net
4
+ --
5
+ -- Servidor: localhost
6
+ -- Tiempo de generación: 31-08-2015 a las 19:26:58
7
+ -- Versión del servidor: 5.5.42
8
+ -- Versión de PHP: 5.6.7
9
+
10
+ DROP DATABASE IF EXISTS `test006a`;
11
+ CREATE DATABASE `test006a`;
12
+
13
+ DROP DATABASE IF EXISTS `test006b`;
14
+ CREATE DATABASE `test006b`;
15
+
16
+ USE `test006a`;
17
+
18
+ SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
19
+ SET time_zone = "+00:00";
20
+
21
+
22
+ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
23
+ /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
24
+ /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
25
+ /*!40101 SET NAMES utf8 */;
26
+
27
+ --
28
+ -- Base de datos: `my_test_db`
29
+ --
30
+
31
+ -- --------------------------------------------------------
32
+
33
+ --
34
+ -- Estructura de tabla para la tabla `my_table`
35
+ --
36
+
37
+ CREATE TABLE IF NOT EXISTS `my_table` (
38
+ `id` int(11) NOT NULL,
39
+ `name` varchar(300) DEFAULT NULL,
40
+ `lastname` varchar(300) DEFAULT NULL,
41
+ `username` varchar(300) DEFAULT NULL
42
+ ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
43
+
44
+ -- --------------------------------------------------------
45
+
46
+ --
47
+ -- Estructura Stand-in para la vista `my_view`
48
+ --
49
+ CREATE TABLE IF NOT EXISTS `my_view` (
50
+ `id` int(11)
51
+ ,`name` varchar(300)
52
+ ,`lastname` varchar(300)
53
+ ,`username` varchar(300)
54
+ );
55
+
56
+ -- --------------------------------------------------------
57
+
58
+ --
59
+ -- Estructura Stand-in para la vista `view_of_my_table`
60
+ --
61
+ CREATE TABLE IF NOT EXISTS `view_of_my_table` (
62
+ `id` int(11)
63
+ ,`name` varchar(300)
64
+ ,`lastname` varchar(300)
65
+ ,`username` varchar(300)
66
+ );
67
+
68
+ -- --------------------------------------------------------
69
+
70
+ --
71
+ -- Estructura para la vista `my_view`
72
+ --
73
+ DROP TABLE IF EXISTS `my_view`;
74
+
75
+ CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `my_view` AS select `view_of_my_table`.`id` AS `id`,`view_of_my_table`.`name` AS `name`,`view_of_my_table`.`lastname` AS `lastname`,`view_of_my_table`.`username` AS `username` from `view_of_my_table`;
76
+
77
+ -- --------------------------------------------------------
78
+
79
+ --
80
+ -- Estructura para la vista `view_of_my_table`
81
+ --
82
+ DROP TABLE IF EXISTS `view_of_my_table`;
83
+
84
+ CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `view_of_my_table` AS select `my_table`.`id` AS `id`,`my_table`.`name` AS `name`,`my_table`.`lastname` AS `lastname`,`my_table`.`username` AS `username` from `my_table`;
85
+
86
+ --
87
+ -- Índices para tablas volcadas
88
+ --
89
+
90
+ --
91
+ -- Indices de la tabla `my_table`
92
+ --
93
+ ALTER TABLE `my_table`
94
+ ADD PRIMARY KEY (`id`);
95
+
96
+ --
97
+ -- AUTO_INCREMENT de las tablas volcadas
98
+ --
99
+
100
+ --
101
+ -- AUTO_INCREMENT de la tabla `my_table`
102
+ --
103
+ ALTER TABLE `my_table`
104
+ MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
105
+ /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
106
+ /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
107
+ /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
vendor/symfony/finder/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ vendor/
2
+ composer.lock
3
+ phpunit.xml
vendor/symfony/finder/README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Finder Component
2
+ ================
3
+
4
+ The Finder component finds files and directories via an intuitive fluent
5
+ interface.
6
+
7
+ Resources
8
+ ---------
9
+
10
+ * [Documentation](https://symfony.com/doc/current/components/finder.html)
11
+ * [Contributing](https://symfony.com/doc/current/contributing/index.html)
12
+ * [Report issues](https://github.com/symfony/symfony/issues) and
13
+ [send Pull Requests](https://github.com/symfony/symfony/pulls)
14
+ in the [main Symfony repository](https://github.com/symfony/symfony)
vendor/symfony/finder/Tests/BsdFinderTest.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests;
13
+
14
+ use Symfony\Component\Finder\Adapter\BsdFindAdapter;
15
+ use Symfony\Component\Finder\Finder;
16
+
17
+ /**
18
+ * @group legacy
19
+ */
20
+ class BsdFinderTest extends FinderTest
21
+ {
22
+ protected function buildFinder()
23
+ {
24
+ $adapter = new BsdFindAdapter();
25
+
26
+ if (!$adapter->isSupported()) {
27
+ $this->markTestSkipped(get_class($adapter).' is not supported.');
28
+ }
29
+
30
+ return Finder::create()
31
+ ->removeAdapters()
32
+ ->addAdapter($adapter);
33
+ }
34
+ }
vendor/symfony/finder/Tests/Comparator/ComparatorTest.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Comparator;
13
+
14
+ use Symfony\Component\Finder\Comparator\Comparator;
15
+
16
+ class ComparatorTest extends \PHPUnit_Framework_TestCase
17
+ {
18
+ public function testGetSetOperator()
19
+ {
20
+ $comparator = new Comparator();
21
+ try {
22
+ $comparator->setOperator('foo');
23
+ $this->fail('->setOperator() throws an \InvalidArgumentException if the operator is not valid.');
24
+ } catch (\Exception $e) {
25
+ $this->assertInstanceOf('InvalidArgumentException', $e, '->setOperator() throws an \InvalidArgumentException if the operator is not valid.');
26
+ }
27
+
28
+ $comparator = new Comparator();
29
+ $comparator->setOperator('>');
30
+ $this->assertEquals('>', $comparator->getOperator(), '->getOperator() returns the current operator');
31
+ }
32
+
33
+ public function testGetSetTarget()
34
+ {
35
+ $comparator = new Comparator();
36
+ $comparator->setTarget(8);
37
+ $this->assertEquals(8, $comparator->getTarget(), '->getTarget() returns the target');
38
+ }
39
+
40
+ /**
41
+ * @dataProvider getTestData
42
+ */
43
+ public function testTest($operator, $target, $match, $noMatch)
44
+ {
45
+ $c = new Comparator();
46
+ $c->setOperator($operator);
47
+ $c->setTarget($target);
48
+
49
+ foreach ($match as $m) {
50
+ $this->assertTrue($c->test($m), '->test() tests a string against the expression');
51
+ }
52
+
53
+ foreach ($noMatch as $m) {
54
+ $this->assertFalse($c->test($m), '->test() tests a string against the expression');
55
+ }
56
+ }
57
+
58
+ public function getTestData()
59
+ {
60
+ return array(
61
+ array('<', '1000', array('500', '999'), array('1000', '1500')),
62
+ );
63
+ }
64
+ }
vendor/symfony/finder/Tests/Comparator/DateComparatorTest.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Comparator;
13
+
14
+ use Symfony\Component\Finder\Comparator\DateComparator;
15
+
16
+ class DateComparatorTest extends \PHPUnit_Framework_TestCase
17
+ {
18
+ public function testConstructor()
19
+ {
20
+ try {
21
+ new DateComparator('foobar');
22
+ $this->fail('__construct() throws an \InvalidArgumentException if the test expression is not valid.');
23
+ } catch (\Exception $e) {
24
+ $this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.');
25
+ }
26
+
27
+ try {
28
+ new DateComparator('');
29
+ $this->fail('__construct() throws an \InvalidArgumentException if the test expression is not valid.');
30
+ } catch (\Exception $e) {
31
+ $this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.');
32
+ }
33
+ }
34
+
35
+ /**
36
+ * @dataProvider getTestData
37
+ */
38
+ public function testTest($test, $match, $noMatch)
39
+ {
40
+ $c = new DateComparator($test);
41
+
42
+ foreach ($match as $m) {
43
+ $this->assertTrue($c->test($m), '->test() tests a string against the expression');
44
+ }
45
+
46
+ foreach ($noMatch as $m) {
47
+ $this->assertFalse($c->test($m), '->test() tests a string against the expression');
48
+ }
49
+ }
50
+
51
+ public function getTestData()
52
+ {
53
+ return array(
54
+ array('< 2005-10-10', array(strtotime('2005-10-09')), array(strtotime('2005-10-15'))),
55
+ array('until 2005-10-10', array(strtotime('2005-10-09')), array(strtotime('2005-10-15'))),
56
+ array('before 2005-10-10', array(strtotime('2005-10-09')), array(strtotime('2005-10-15'))),
57
+ array('> 2005-10-10', array(strtotime('2005-10-15')), array(strtotime('2005-10-09'))),
58
+ array('after 2005-10-10', array(strtotime('2005-10-15')), array(strtotime('2005-10-09'))),
59
+ array('since 2005-10-10', array(strtotime('2005-10-15')), array(strtotime('2005-10-09'))),
60
+ array('!= 2005-10-10', array(strtotime('2005-10-11')), array(strtotime('2005-10-10'))),
61
+ );
62
+ }
63
+ }
vendor/symfony/finder/Tests/Comparator/NumberComparatorTest.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Comparator;
13
+
14
+ use Symfony\Component\Finder\Comparator\NumberComparator;
15
+
16
+ class NumberComparatorTest extends \PHPUnit_Framework_TestCase
17
+ {
18
+ /**
19
+ * @dataProvider getConstructorTestData
20
+ */
21
+ public function testConstructor($successes, $failures)
22
+ {
23
+ foreach ($successes as $s) {
24
+ new NumberComparator($s);
25
+ }
26
+
27
+ foreach ($failures as $f) {
28
+ try {
29
+ new NumberComparator($f);
30
+ $this->fail('__construct() throws an \InvalidArgumentException if the test expression is not valid.');
31
+ } catch (\Exception $e) {
32
+ $this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the test expression is not valid.');
33
+ }
34
+ }
35
+ }
36
+
37
+ /**
38
+ * @dataProvider getTestData
39
+ */
40
+ public function testTest($test, $match, $noMatch)
41
+ {
42
+ $c = new NumberComparator($test);
43
+
44
+ foreach ($match as $m) {
45
+ $this->assertTrue($c->test($m), '->test() tests a string against the expression');
46
+ }
47
+
48
+ foreach ($noMatch as $m) {
49
+ $this->assertFalse($c->test($m), '->test() tests a string against the expression');
50
+ }
51
+ }
52
+
53
+ public function getTestData()
54
+ {
55
+ return array(
56
+ array('< 1000', array('500', '999'), array('1000', '1500')),
57
+
58
+ array('< 1K', array('500', '999'), array('1000', '1500')),
59
+ array('<1k', array('500', '999'), array('1000', '1500')),
60
+ array(' < 1 K ', array('500', '999'), array('1000', '1500')),
61
+ array('<= 1K', array('1000'), array('1001')),
62
+ array('> 1K', array('1001'), array('1000')),
63
+ array('>= 1K', array('1000'), array('999')),
64
+
65
+ array('< 1KI', array('500', '1023'), array('1024', '1500')),
66
+ array('<= 1KI', array('1024'), array('1025')),
67
+ array('> 1KI', array('1025'), array('1024')),
68
+ array('>= 1KI', array('1024'), array('1023')),
69
+
70
+ array('1KI', array('1024'), array('1023', '1025')),
71
+ array('==1KI', array('1024'), array('1023', '1025')),
72
+
73
+ array('==1m', array('1000000'), array('999999', '1000001')),
74
+ array('==1mi', array(1024 * 1024), array(1024 * 1024 - 1, 1024 * 1024 + 1)),
75
+
76
+ array('==1g', array('1000000000'), array('999999999', '1000000001')),
77
+ array('==1gi', array(1024 * 1024 * 1024), array(1024 * 1024 * 1024 - 1, 1024 * 1024 * 1024 + 1)),
78
+
79
+ array('!= 1000', array('500', '999'), array('1000')),
80
+ );
81
+ }
82
+
83
+ public function getConstructorTestData()
84
+ {
85
+ return array(
86
+ array(
87
+ array(
88
+ '1', '0',
89
+ '3.5', '33.55', '123.456', '123456.78',
90
+ '.1', '.123',
91
+ '.0', '0.0',
92
+ '1.', '0.', '123.',
93
+ '==1', '!=1', '<1', '>1', '<=1', '>=1',
94
+ '==1k', '==1ki', '==1m', '==1mi', '==1g', '==1gi',
95
+ '1k', '1ki', '1m', '1mi', '1g', '1gi',
96
+ ),
97
+ array(
98
+ false, null, '',
99
+ ' ', 'foobar',
100
+ '=1', '===1',
101
+ '0 . 1', '123 .45', '234. 567',
102
+ '..', '.0.', '0.1.2',
103
+ ),
104
+ ),
105
+ );
106
+ }
107
+ }
vendor/symfony/finder/Tests/Expression/ExpressionTest.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Expression;
13
+
14
+ use Symfony\Component\Finder\Expression\Expression;
15
+
16
+ /**
17
+ * @group legacy
18
+ */
19
+ class ExpressionTest extends \PHPUnit_Framework_TestCase
20
+ {
21
+ /**
22
+ * @dataProvider getTypeGuesserData
23
+ */
24
+ public function testTypeGuesser($expr, $type)
25
+ {
26
+ $this->assertEquals($type, Expression::create($expr)->getType());
27
+ }
28
+
29
+ /**
30
+ * @dataProvider getCaseSensitiveData
31
+ */
32
+ public function testCaseSensitive($expr, $isCaseSensitive)
33
+ {
34
+ $this->assertEquals($isCaseSensitive, Expression::create($expr)->isCaseSensitive());
35
+ }
36
+
37
+ /**
38
+ * @dataProvider getRegexRenderingData
39
+ */
40
+ public function testRegexRendering($expr, $body)
41
+ {
42
+ $this->assertEquals($body, Expression::create($expr)->renderPattern());
43
+ }
44
+
45
+ public function getTypeGuesserData()
46
+ {
47
+ return array(
48
+ array('{foo}', Expression::TYPE_REGEX),
49
+ array('/foo/', Expression::TYPE_REGEX),
50
+ array('foo', Expression::TYPE_GLOB),
51
+ array('foo*', Expression::TYPE_GLOB),
52
+ );
53
+ }
54
+
55
+ public function getCaseSensitiveData()
56
+ {
57
+ return array(
58
+ array('{foo}m', true),
59
+ array('/foo/i', false),
60
+ array('foo*', true),
61
+ );
62
+ }
63
+
64
+ public function getRegexRenderingData()
65
+ {
66
+ return array(
67
+ array('{foo}m', 'foo'),
68
+ array('/foo/i', 'foo'),
69
+ );
70
+ }
71
+ }
vendor/symfony/finder/Tests/Expression/GlobTest.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Expression;
13
+
14
+ use Symfony\Component\Finder\Expression\Expression;
15
+
16
+ /**
17
+ * @group legacy
18
+ */
19
+ class GlobTest extends \PHPUnit_Framework_TestCase
20
+ {
21
+ /**
22
+ * @dataProvider getToRegexData
23
+ */
24
+ public function testGlobToRegex($glob, $match, $noMatch)
25
+ {
26
+ foreach ($match as $m) {
27
+ $this->assertRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
28
+ }
29
+
30
+ foreach ($noMatch as $m) {
31
+ $this->assertNotRegExp(Expression::create($glob)->getRegex()->render(), $m, '::toRegex() converts a glob to a regexp');
32
+ }
33
+ }
34
+
35
+ public function getToRegexData()
36
+ {
37
+ return array(
38
+ array('', array(''), array('f', '/')),
39
+ array('*', array('foo'), array('foo/', '/foo')),
40
+ array('foo.*', array('foo.php', 'foo.a', 'foo.'), array('fooo.php', 'foo.php/foo')),
41
+ array('fo?', array('foo', 'fot'), array('fooo', 'ffoo', 'fo/')),
42
+ array('fo{o,t}', array('foo', 'fot'), array('fob', 'fo/')),
43
+ array('foo(bar|foo)', array('foo(bar|foo)'), array('foobar', 'foofoo')),
44
+ array('foo,bar', array('foo,bar'), array('foo', 'bar')),
45
+ array('fo{o,\\,}', array('foo', 'fo,'), array()),
46
+ array('fo{o,\\\\}', array('foo', 'fo\\'), array()),
47
+ array('/foo', array('/foo'), array('foo')),
48
+ );
49
+ }
50
+ }
vendor/symfony/finder/Tests/Expression/RegexTest.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Expression;
13
+
14
+ use Symfony\Component\Finder\Expression\Expression;
15
+
16
+ /**
17
+ * @group legacy
18
+ */
19
+ class RegexTest extends \PHPUnit_Framework_TestCase
20
+ {
21
+ /**
22
+ * @dataProvider getHasFlagsData
23
+ */
24
+ public function testHasFlags($regex, $start, $end)
25
+ {
26
+ $expr = new Expression($regex);
27
+
28
+ $this->assertEquals($start, $expr->getRegex()->hasStartFlag());
29
+ $this->assertEquals($end, $expr->getRegex()->hasEndFlag());
30
+ }
31
+
32
+ /**
33
+ * @dataProvider getHasJokersData
34
+ */
35
+ public function testHasJokers($regex, $start, $end)
36
+ {
37
+ $expr = new Expression($regex);
38
+
39
+ $this->assertEquals($start, $expr->getRegex()->hasStartJoker());
40
+ $this->assertEquals($end, $expr->getRegex()->hasEndJoker());
41
+ }
42
+
43
+ /**
44
+ * @dataProvider getSetFlagsData
45
+ */
46
+ public function testSetFlags($regex, $start, $end, $expected)
47
+ {
48
+ $expr = new Expression($regex);
49
+ $expr->getRegex()->setStartFlag($start)->setEndFlag($end);
50
+
51
+ $this->assertEquals($expected, $expr->render());
52
+ }
53
+
54
+ /**
55
+ * @dataProvider getSetJokersData
56
+ */
57
+ public function testSetJokers($regex, $start, $end, $expected)
58
+ {
59
+ $expr = new Expression($regex);
60
+ $expr->getRegex()->setStartJoker($start)->setEndJoker($end);
61
+
62
+ $this->assertEquals($expected, $expr->render());
63
+ }
64
+
65
+ public function testOptions()
66
+ {
67
+ $expr = new Expression('~abc~is');
68
+ $expr->getRegex()->removeOption('i')->addOption('m');
69
+
70
+ $this->assertEquals('~abc~sm', $expr->render());
71
+ }
72
+
73
+ public function testMixFlagsAndJokers()
74
+ {
75
+ $expr = new Expression('~^.*abc.*$~is');
76
+
77
+ $expr->getRegex()->setStartFlag(false)->setEndFlag(false)->setStartJoker(false)->setEndJoker(false);
78
+ $this->assertEquals('~abc~is', $expr->render());
79
+
80
+ $expr->getRegex()->setStartFlag(true)->setEndFlag(true)->setStartJoker(true)->setEndJoker(true);
81
+ $this->assertEquals('~^.*abc.*$~is', $expr->render());
82
+ }
83
+
84
+ /**
85
+ * @dataProvider getReplaceJokersTestData
86
+ */
87
+ public function testReplaceJokers($regex, $expected)
88
+ {
89
+ $expr = new Expression($regex);
90
+ $expr = $expr->getRegex()->replaceJokers('@');
91
+
92
+ $this->assertEquals($expected, $expr->renderPattern());
93
+ }
94
+
95
+ public function getHasFlagsData()
96
+ {
97
+ return array(
98
+ array('~^abc~', true, false),
99
+ array('~abc$~', false, true),
100
+ array('~abc~', false, false),
101
+ array('~^abc$~', true, true),
102
+ array('~^abc\\$~', true, false),
103
+ );
104
+ }
105
+
106
+ public function getHasJokersData()
107
+ {
108
+ return array(
109
+ array('~.*abc~', true, false),
110
+ array('~abc.*~', false, true),
111
+ array('~abc~', false, false),
112
+ array('~.*abc.*~', true, true),
113
+ array('~.*abc\\.*~', true, false),
114
+ );
115
+ }
116
+
117
+ public function getSetFlagsData()
118
+ {
119
+ return array(
120
+ array('~abc~', true, false, '~^abc~'),
121
+ array('~abc~', false, true, '~abc$~'),
122
+ array('~abc~', false, false, '~abc~'),
123
+ array('~abc~', true, true, '~^abc$~'),
124
+ );
125
+ }
126
+
127
+ public function getSetJokersData()
128
+ {
129
+ return array(
130
+ array('~abc~', true, false, '~.*abc~'),
131
+ array('~abc~', false, true, '~abc.*~'),
132
+ array('~abc~', false, false, '~abc~'),
133
+ array('~abc~', true, true, '~.*abc.*~'),
134
+ );
135
+ }
136
+
137
+ public function getReplaceJokersTestData()
138
+ {
139
+ return array(
140
+ array('~.abc~', '@abc'),
141
+ array('~\\.abc~', '\\.abc'),
142
+ array('~\\\\.abc~', '\\\\@abc'),
143
+ array('~\\\\\\.abc~', '\\\\\\.abc'),
144
+ );
145
+ }
146
+ }
vendor/symfony/finder/Tests/FakeAdapter/DummyAdapter.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\FakeAdapter;
13
+
14
+ use Symfony\Component\Finder\Adapter\AbstractAdapter;
15
+
16
+ /**
17
+ * @author Jean-François Simon <contact@jfsimon.fr>
18
+ */
19
+ class DummyAdapter extends AbstractAdapter
20
+ {
21
+ /**
22
+ * @var \Iterator
23
+ */
24
+ private $iterator;
25
+
26
+ /**
27
+ * @param \Iterator $iterator
28
+ */
29
+ public function __construct(\Iterator $iterator)
30
+ {
31
+ $this->iterator = $iterator;
32
+ }
33
+
34
+ /**
35
+ * {@inheritdoc}
36
+ */
37
+ public function searchInDirectory($dir)
38
+ {
39
+ return $this->iterator;
40
+ }
41
+
42
+ /**
43
+ * {@inheritdoc}
44
+ */
45
+ public function getName()
46
+ {
47
+ return 'yes';
48
+ }
49
+
50
+ /**
51
+ * {@inheritdoc}
52
+ */
53
+ protected function canBeUsed()
54
+ {
55
+ return true;
56
+ }
57
+ }
vendor/symfony/finder/Tests/FakeAdapter/FailingAdapter.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\FakeAdapter;
13
+
14
+ use Symfony\Component\Finder\Adapter\AbstractAdapter;
15
+ use Symfony\Component\Finder\Exception\AdapterFailureException;
16
+
17
+ /**
18
+ * @author Jean-François Simon <contact@jfsimon.fr>
19
+ */
20
+ class FailingAdapter extends AbstractAdapter
21
+ {
22
+ /**
23
+ * {@inheritdoc}
24
+ */
25
+ public function searchInDirectory($dir)
26
+ {
27
+ throw new AdapterFailureException($this);
28
+ }
29
+
30
+ /**
31
+ * {@inheritdoc}
32
+ */
33
+ public function getName()
34
+ {
35
+ return 'failing';
36
+ }
37
+
38
+ /**
39
+ * {@inheritdoc}
40
+ */
41
+ protected function canBeUsed()
42
+ {
43
+ return true;
44
+ }
45
+ }
vendor/symfony/finder/Tests/FakeAdapter/NamedAdapter.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\FakeAdapter;
13
+
14
+ use Symfony\Component\Finder\Adapter\AbstractAdapter;
15
+
16
+ /**
17
+ * @author Jean-François Simon <contact@jfsimon.fr>
18
+ */
19
+ class NamedAdapter extends AbstractAdapter
20
+ {
21
+ /**
22
+ * @var string
23
+ */
24
+ private $name;
25
+
26
+ /**
27
+ * @param string $name
28
+ */
29
+ public function __construct($name)
30
+ {
31
+ $this->name = $name;
32
+ }
33
+
34
+ /**
35
+ * {@inheritdoc}
36
+ */
37
+ public function searchInDirectory($dir)
38
+ {
39
+ return new \ArrayIterator(array());
40
+ }
41
+
42
+ /**
43
+ * {@inheritdoc}
44
+ */
45
+ public function getName()
46
+ {
47
+ return $this->name;
48
+ }
49
+
50
+ /**
51
+ * {@inheritdoc}
52
+ */
53
+ protected function canBeUsed()
54
+ {
55
+ return true;
56
+ }
57
+ }
vendor/symfony/finder/Tests/FakeAdapter/UnsupportedAdapter.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\FakeAdapter;
13
+
14
+ use Symfony\Component\Finder\Adapter\AbstractAdapter;
15
+
16
+ /**
17
+ * @author Jean-François Simon <contact@jfsimon.fr>
18
+ */
19
+ class UnsupportedAdapter extends AbstractAdapter
20
+ {
21
+ /**
22
+ * {@inheritdoc}
23
+ */
24
+ public function searchInDirectory($dir)
25
+ {
26
+ return new \ArrayIterator(array());
27
+ }
28
+
29
+ /**
30
+ * {@inheritdoc}
31
+ */
32
+ public function getName()
33
+ {
34
+ return 'unsupported';
35
+ }
36
+
37
+ /**
38
+ * {@inheritdoc}
39
+ */
40
+ protected function canBeUsed()
41
+ {
42
+ return false;
43
+ }
44
+ }
vendor/symfony/finder/Tests/FinderTest.php ADDED
@@ -0,0 +1,745 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests;
13
+
14
+ use Symfony\Component\Finder\Adapter\AdapterInterface;
15
+ use Symfony\Component\Finder\Adapter\GnuFindAdapter;
16
+ use Symfony\Component\Finder\Adapter\PhpAdapter;
17
+ use Symfony\Component\Finder\Finder;
18
+
19
+ class FinderTest extends Iterator\RealIteratorTestCase
20
+ {
21
+ public function testCreate()
22
+ {
23
+ $this->assertInstanceOf('Symfony\Component\Finder\Finder', Finder::create());
24
+ }
25
+
26
+ public function testDirectories()
27
+ {
28
+ $finder = $this->buildFinder();
29
+ $this->assertSame($finder, $finder->directories());
30
+ $this->assertIterator($this->toAbsolute(array('foo', 'toto')), $finder->in(self::$tmpDir)->getIterator());
31
+
32
+ $finder = $this->buildFinder();
33
+ $finder->directories();
34
+ $finder->files();
35
+ $finder->directories();
36
+ $this->assertIterator($this->toAbsolute(array('foo', 'toto')), $finder->in(self::$tmpDir)->getIterator());
37
+ }
38
+
39
+ public function testFiles()
40
+ {
41
+ $finder = $this->buildFinder();
42
+ $this->assertSame($finder, $finder->files());
43
+ $this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
44
+
45
+ $finder = $this->buildFinder();
46
+ $finder->files();
47
+ $finder->directories();
48
+ $finder->files();
49
+ $this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
50
+ }
51
+
52
+ public function testDepth()
53
+ {
54
+ $finder = $this->buildFinder();
55
+ $this->assertSame($finder, $finder->depth('< 1'));
56
+ $this->assertIterator($this->toAbsolute(array('foo', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
57
+
58
+ $finder = $this->buildFinder();
59
+ $this->assertSame($finder, $finder->depth('<= 0'));
60
+ $this->assertIterator($this->toAbsolute(array('foo', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
61
+
62
+ $finder = $this->buildFinder();
63
+ $this->assertSame($finder, $finder->depth('>= 1'));
64
+ $this->assertIterator($this->toAbsolute(array('foo/bar.tmp')), $finder->in(self::$tmpDir)->getIterator());
65
+
66
+ $finder = $this->buildFinder();
67
+ $finder->depth('< 1')->depth('>= 1');
68
+ $this->assertIterator(array(), $finder->in(self::$tmpDir)->getIterator());
69
+ }
70
+
71
+ public function testName()
72
+ {
73
+ $finder = $this->buildFinder();
74
+ $this->assertSame($finder, $finder->name('*.php'));
75
+ $this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
76
+
77
+ $finder = $this->buildFinder();
78
+ $finder->name('test.ph*');
79
+ $finder->name('test.py');
80
+ $this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
81
+
82
+ $finder = $this->buildFinder();
83
+ $finder->name('~^test~i');
84
+ $this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
85
+
86
+ $finder = $this->buildFinder();
87
+ $finder->name('~\\.php$~i');
88
+ $this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
89
+
90
+ $finder = $this->buildFinder();
91
+ $finder->name('test.p{hp,y}');
92
+ $this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
93
+ }
94
+
95
+ public function testNotName()
96
+ {
97
+ $finder = $this->buildFinder();
98
+ $this->assertSame($finder, $finder->notName('*.php'));
99
+ $this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
100
+
101
+ $finder = $this->buildFinder();
102
+ $finder->notName('*.php');
103
+ $finder->notName('*.py');
104
+ $this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
105
+
106
+ $finder = $this->buildFinder();
107
+ $finder->name('test.ph*');
108
+ $finder->name('test.py');
109
+ $finder->notName('*.php');
110
+ $finder->notName('*.py');
111
+ $this->assertIterator(array(), $finder->in(self::$tmpDir)->getIterator());
112
+
113
+ $finder = $this->buildFinder();
114
+ $finder->name('test.ph*');
115
+ $finder->name('test.py');
116
+ $finder->notName('*.p{hp,y}');
117
+ $this->assertIterator(array(), $finder->in(self::$tmpDir)->getIterator());
118
+ }
119
+
120
+ /**
121
+ * @dataProvider getRegexNameTestData
122
+ */
123
+ public function testRegexName($regex)
124
+ {
125
+ $finder = $this->buildFinder();
126
+ $finder->name($regex);
127
+ $this->assertIterator($this->toAbsolute(array('test.py', 'test.php')), $finder->in(self::$tmpDir)->getIterator());
128
+ }
129
+
130
+ public function testSize()
131
+ {
132
+ $finder = $this->buildFinder();
133
+ $this->assertSame($finder, $finder->files()->size('< 1K')->size('> 500'));
134
+ $this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
135
+ }
136
+
137
+ public function testDate()
138
+ {
139
+ $finder = $this->buildFinder();
140
+ $this->assertSame($finder, $finder->files()->date('until last month'));
141
+ $this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php')), $finder->in(self::$tmpDir)->getIterator());
142
+ }
143
+
144
+ public function testExclude()
145
+ {
146
+ $finder = $this->buildFinder();
147
+ $this->assertSame($finder, $finder->exclude('foo'));
148
+ $this->assertIterator($this->toAbsolute(array('test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
149
+ }
150
+
151
+ public function testIgnoreVCS()
152
+ {
153
+ $finder = $this->buildFinder();
154
+ $this->assertSame($finder, $finder->ignoreVCS(false)->ignoreDotFiles(false));
155
+ $this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
156
+
157
+ $finder = $this->buildFinder();
158
+ $finder->ignoreVCS(false)->ignoreVCS(false)->ignoreDotFiles(false);
159
+ $this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
160
+
161
+ $finder = $this->buildFinder();
162
+ $this->assertSame($finder, $finder->ignoreVCS(true)->ignoreDotFiles(false));
163
+ $this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
164
+ }
165
+
166
+ public function testIgnoreDotFiles()
167
+ {
168
+ $finder = $this->buildFinder();
169
+ $this->assertSame($finder, $finder->ignoreDotFiles(false)->ignoreVCS(false));
170
+ $this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
171
+
172
+ $finder = $this->buildFinder();
173
+ $finder->ignoreDotFiles(false)->ignoreDotFiles(false)->ignoreVCS(false);
174
+ $this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
175
+
176
+ $finder = $this->buildFinder();
177
+ $this->assertSame($finder, $finder->ignoreDotFiles(true)->ignoreVCS(false));
178
+ $this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
179
+ }
180
+
181
+ public function testSortByName()
182
+ {
183
+ $finder = $this->buildFinder();
184
+ $this->assertSame($finder, $finder->sortByName());
185
+ $this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
186
+ }
187
+
188
+ public function testSortByType()
189
+ {
190
+ $finder = $this->buildFinder();
191
+ $this->assertSame($finder, $finder->sortByType());
192
+ $this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'toto', 'foo/bar.tmp', 'test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
193
+ }
194
+
195
+ public function testSortByAccessedTime()
196
+ {
197
+ $finder = $this->buildFinder();
198
+ $this->assertSame($finder, $finder->sortByAccessedTime());
199
+ $this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'toto', 'test.py', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
200
+ }
201
+
202
+ public function testSortByChangedTime()
203
+ {
204
+ $finder = $this->buildFinder();
205
+ $this->assertSame($finder, $finder->sortByChangedTime());
206
+ $this->assertIterator($this->toAbsolute(array('toto', 'test.py', 'test.php', 'foo/bar.tmp', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
207
+ }
208
+
209
+ public function testSortByModifiedTime()
210
+ {
211
+ $finder = $this->buildFinder();
212
+ $this->assertSame($finder, $finder->sortByModifiedTime());
213
+ $this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'toto', 'test.py', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
214
+ }
215
+
216
+ public function testSort()
217
+ {
218
+ $finder = $this->buildFinder();
219
+ $this->assertSame($finder, $finder->sort(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }));
220
+ $this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
221
+ }
222
+
223
+ public function testFilter()
224
+ {
225
+ $finder = $this->buildFinder();
226
+ $this->assertSame($finder, $finder->filter(function (\SplFileInfo $f) { return false !== strpos($f, 'test'); }));
227
+ $this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
228
+ }
229
+
230
+ public function testFollowLinks()
231
+ {
232
+ if ('\\' == DIRECTORY_SEPARATOR) {
233
+ $this->markTestSkipped('symlinks are not supported on Windows');
234
+ }
235
+
236
+ $finder = $this->buildFinder();
237
+ $this->assertSame($finder, $finder->followLinks());
238
+ $this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
239
+ }
240
+
241
+ public function testIn()
242
+ {
243
+ $finder = $this->buildFinder();
244
+ $iterator = $finder->files()->name('*.php')->depth('< 1')->in(array(self::$tmpDir, __DIR__))->getIterator();
245
+
246
+ $expected = array(
247
+ self::$tmpDir.DIRECTORY_SEPARATOR.'test.php',
248
+ __DIR__.DIRECTORY_SEPARATOR.'BsdFinderTest.php',
249
+ __DIR__.DIRECTORY_SEPARATOR.'FinderTest.php',
250
+ __DIR__.DIRECTORY_SEPARATOR.'GnuFinderTest.php',
251
+ __DIR__.DIRECTORY_SEPARATOR.'PhpFinderTest.php',
252
+ __DIR__.DIRECTORY_SEPARATOR.'GlobTest.php',
253
+ );
254
+
255
+ $this->assertIterator($expected, $iterator);
256
+ }
257
+
258
+ /**
259
+ * @expectedException \InvalidArgumentException
260
+ */
261
+ public function testInWithNonExistentDirectory()
262
+ {
263
+ $finder = new Finder();
264
+ $finder->in('foobar');
265
+ }
266
+
267
+ public function testInWithGlob()
268
+ {
269
+ $finder = $this->buildFinder();
270
+ $finder->in(array(__DIR__.'/Fixtures/*/B/C', __DIR__.'/Fixtures/*/*/B/C'))->getIterator();
271
+
272
+ $this->assertIterator($this->toAbsoluteFixtures(array('A/B/C/abc.dat', 'copy/A/B/C/abc.dat.copy')), $finder);
273
+ }
274
+
275
+ /**
276
+ * @expectedException \InvalidArgumentException
277
+ */
278
+ public function testInWithNonDirectoryGlob()
279
+ {
280
+ $finder = new Finder();
281
+ $finder->in(__DIR__.'/Fixtures/A/a*');
282
+ }
283
+
284
+ public function testInWithGlobBrace()
285
+ {
286
+ $finder = $this->buildFinder();
287
+ $finder->in(array(__DIR__.'/Fixtures/{A,copy/A}/B/C'))->getIterator();
288
+
289
+ $this->assertIterator($this->toAbsoluteFixtures(array('A/B/C/abc.dat', 'copy/A/B/C/abc.dat.copy')), $finder);
290
+ }
291
+
292
+ /**
293
+ * @expectedException \LogicException
294
+ */
295
+ public function testGetIteratorWithoutIn()
296
+ {
297
+ $finder = Finder::create();
298
+ $finder->getIterator();
299
+ }
300
+
301
+ public function testGetIterator()
302
+ {
303
+ $finder = $this->buildFinder();
304
+ $dirs = array();
305
+ foreach ($finder->directories()->in(self::$tmpDir) as $dir) {
306
+ $dirs[] = (string) $dir;
307
+ }
308
+
309
+ $expected = $this->toAbsolute(array('foo', 'toto'));
310
+
311
+ sort($dirs);
312
+ sort($expected);
313
+
314
+ $this->assertEquals($expected, $dirs, 'implements the \IteratorAggregate interface');
315
+
316
+ $finder = $this->buildFinder();
317
+ $this->assertEquals(2, iterator_count($finder->directories()->in(self::$tmpDir)), 'implements the \IteratorAggregate interface');
318
+
319
+ $finder = $this->buildFinder();
320
+ $a = iterator_to_array($finder->directories()->in(self::$tmpDir));
321
+ $a = array_values(array_map(function ($a) { return (string) $a; }, $a));
322
+ sort($a);
323
+ $this->assertEquals($expected, $a, 'implements the \IteratorAggregate interface');
324
+ }
325
+
326
+ public function testRelativePath()
327
+ {
328
+ $finder = $this->buildFinder()->in(self::$tmpDir);
329
+
330
+ $paths = array();
331
+
332
+ foreach ($finder as $file) {
333
+ $paths[] = $file->getRelativePath();
334
+ }
335
+
336
+ $ref = array('', '', '', '', 'foo', '');
337
+
338
+ sort($ref);
339
+ sort($paths);
340
+
341
+ $this->assertEquals($ref, $paths);
342
+ }
343
+
344
+ public function testRelativePathname()
345
+ {
346
+ $finder = $this->buildFinder()->in(self::$tmpDir)->sortByName();
347
+
348
+ $paths = array();
349
+
350
+ foreach ($finder as $file) {
351
+ $paths[] = $file->getRelativePathname();
352
+ }
353
+
354
+ $ref = array('test.php', 'toto', 'test.py', 'foo', 'foo'.DIRECTORY_SEPARATOR.'bar.tmp', 'foo bar');
355
+
356
+ sort($paths);
357
+ sort($ref);
358
+
359
+ $this->assertEquals($ref, $paths);
360
+ }
361
+
362
+ public function testAppendWithAFinder()
363
+ {
364
+ $finder = $this->buildFinder();
365
+ $finder->files()->in(self::$tmpDir.DIRECTORY_SEPARATOR.'foo');
366
+
367
+ $finder1 = $this->buildFinder();
368
+ $finder1->directories()->in(self::$tmpDir);
369
+
370
+ $finder = $finder->append($finder1);
371
+
372
+ $this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto')), $finder->getIterator());
373
+ }
374
+
375
+ public function testAppendWithAnArray()
376
+ {
377
+ $finder = $this->buildFinder();
378
+ $finder->files()->in(self::$tmpDir.DIRECTORY_SEPARATOR.'foo');
379
+
380
+ $finder->append($this->toAbsolute(array('foo', 'toto')));
381
+
382
+ $this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto')), $finder->getIterator());
383
+ }
384
+
385
+ public function testAppendReturnsAFinder()
386
+ {
387
+ $this->assertInstanceOf('Symfony\\Component\\Finder\\Finder', Finder::create()->append(array()));
388
+ }
389
+
390
+ public function testAppendDoesNotRequireIn()
391
+ {
392
+ $finder = $this->buildFinder();
393
+ $finder->in(self::$tmpDir.DIRECTORY_SEPARATOR.'foo');
394
+
395
+ $finder1 = Finder::create()->append($finder);
396
+
397
+ $this->assertIterator(iterator_to_array($finder->getIterator()), $finder1->getIterator());
398
+ }
399
+
400
+ public function testCountDirectories()
401
+ {
402
+ $directory = Finder::create()->directories()->in(self::$tmpDir);
403
+ $i = 0;
404
+
405
+ foreach ($directory as $dir) {
406
+ ++$i;
407
+ }
408
+
409
+ $this->assertCount($i, $directory);
410
+ }
411
+
412
+ public function testCountFiles()
413
+ {
414
+ $files = Finder::create()->files()->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures');
415
+ $i = 0;
416
+
417
+ foreach ($files as $file) {
418
+ ++$i;
419
+ }
420
+
421
+ $this->assertCount($i, $files);
422
+ }
423
+
424
+ /**
425
+ * @expectedException \LogicException
426
+ */
427
+ public function testCountWithoutIn()
428
+ {
429
+ $finder = Finder::create()->files();
430
+ count($finder);
431
+ }
432
+
433
+ /**
434
+ * @dataProvider getContainsTestData
435
+ */
436
+ public function testContains($matchPatterns, $noMatchPatterns, $expected)
437
+ {
438
+ $finder = $this->buildFinder();
439
+ $finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures')
440
+ ->name('*.txt')->sortByName()
441
+ ->contains($matchPatterns)
442
+ ->notContains($noMatchPatterns);
443
+
444
+ $this->assertIterator($this->toAbsoluteFixtures($expected), $finder);
445
+ }
446
+
447
+ public function testContainsOnDirectory()
448
+ {
449
+ $finder = $this->buildFinder();
450
+ $finder->in(__DIR__)
451
+ ->directories()
452
+ ->name('Fixtures')
453
+ ->contains('abc');
454
+ $this->assertIterator(array(), $finder);
455
+ }
456
+
457
+ public function testNotContainsOnDirectory()
458
+ {
459
+ $finder = $this->buildFinder();
460
+ $finder->in(__DIR__)
461
+ ->directories()
462
+ ->name('Fixtures')
463
+ ->notContains('abc');
464
+ $this->assertIterator(array(), $finder);
465
+ }
466
+
467
+ /**
468
+ * Searching in multiple locations involves AppendIterator which does an unnecessary rewind which leaves FilterIterator
469
+ * with inner FilesystemIterator in an invalid state.
470
+ *
471
+ * @see https://bugs.php.net/68557
472
+ */
473
+ public function testMultipleLocations()
474
+ {
475
+ $locations = array(
476
+ self::$tmpDir.'/',
477
+ self::$tmpDir.'/toto/',
478
+ );
479
+
480
+ // it is expected that there are test.py test.php in the tmpDir
481
+ $finder = new Finder();
482
+ $finder->in($locations)
483
+ // the default flag IGNORE_DOT_FILES fixes the problem indirectly
484
+ // so we set it to false for better isolation
485
+ ->ignoreDotFiles(false)
486
+ ->depth('< 1')->name('test.php');
487
+
488
+ $this->assertCount(1, $finder);
489
+ }
490
+
491
+ /**
492
+ * Searching in multiple locations with sub directories involves
493
+ * AppendIterator which does an unnecessary rewind which leaves
494
+ * FilterIterator with inner FilesystemIterator in an invalid state.
495
+ *
496
+ * @see https://bugs.php.net/68557
497
+ */
498
+ public function testMultipleLocationsWithSubDirectories()
499
+ {
500
+ $locations = array(
501
+ __DIR__.'/Fixtures/one',
502
+ self::$tmpDir.DIRECTORY_SEPARATOR.'toto',
503
+ );
504
+
505
+ $finder = $this->buildFinder();
506
+ $finder->in($locations)->depth('< 10')->name('*.neon');
507
+
508
+ $expected = array(
509
+ __DIR__.'/Fixtures/one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'c.neon',
510
+ __DIR__.'/Fixtures/one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'d.neon',
511
+ );
512
+
513
+ $this->assertIterator($expected, $finder);
514
+ $this->assertIteratorInForeach($expected, $finder);
515
+ }
516
+
517
+ /**
518
+ * Iterator keys must be the file pathname.
519
+ */
520
+ public function testIteratorKeys()
521
+ {
522
+ $finder = $this->buildFinder()->in(self::$tmpDir);
523
+ foreach ($finder as $key => $file) {
524
+ $this->assertEquals($file->getPathname(), $key);
525
+ }
526
+ }
527
+
528
+ public function testRegexSpecialCharsLocationWithPathRestrictionContainingStartFlag()
529
+ {
530
+ $finder = $this->buildFinder();
531
+ $finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'r+e.gex[c]a(r)s')
532
+ ->path('/^dir/');
533
+
534
+ $expected = array('r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir', 'r+e.gex[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat');
535
+ $this->assertIterator($this->toAbsoluteFixtures($expected), $finder);
536
+ }
537
+
538
+ /**
539
+ * @group legacy
540
+ */
541
+ public function testAdaptersOrdering()
542
+ {
543
+ $finder = Finder::create()
544
+ ->removeAdapters()
545
+ ->addAdapter(new FakeAdapter\NamedAdapter('a'), 0)
546
+ ->addAdapter(new FakeAdapter\NamedAdapter('b'), -50)
547
+ ->addAdapter(new FakeAdapter\NamedAdapter('c'), 50)
548
+ ->addAdapter(new FakeAdapter\NamedAdapter('d'), -25)
549
+ ->addAdapter(new FakeAdapter\NamedAdapter('e'), 25);
550
+
551
+ $this->assertEquals(
552
+ array('c', 'e', 'a', 'd', 'b'),
553
+ array_map(function (AdapterInterface $adapter) {
554
+ return $adapter->getName();
555
+ }, $finder->getAdapters())
556
+ );
557
+ }
558
+
559
+ /**
560
+ * @group legacy
561
+ */
562
+ public function testAdaptersChaining()
563
+ {
564
+ $iterator = new \ArrayIterator(array());
565
+ $filenames = $this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto'));
566
+ foreach ($filenames as $file) {
567
+ $iterator->append(new \Symfony\Component\Finder\SplFileInfo($file, null, null));
568
+ }
569
+
570
+ $finder = Finder::create()
571
+ ->removeAdapters()
572
+ ->addAdapter(new FakeAdapter\UnsupportedAdapter(), 3)
573
+ ->addAdapter(new FakeAdapter\FailingAdapter(), 2)
574
+ ->addAdapter(new FakeAdapter\DummyAdapter($iterator), 1);
575
+
576
+ $this->assertIterator($filenames, $finder->in(sys_get_temp_dir())->getIterator());
577
+ }
578
+
579
+ public function getContainsTestData()
580
+ {
581
+ return array(
582
+ array('', '', array()),
583
+ array('foo', 'bar', array()),
584
+ array('', 'foobar', array('dolor.txt', 'ipsum.txt', 'lorem.txt')),
585
+ array('lorem ipsum dolor sit amet', 'foobar', array('lorem.txt')),
586
+ array('sit', 'bar', array('dolor.txt', 'ipsum.txt', 'lorem.txt')),
587
+ array('dolor sit amet', '@^L@m', array('dolor.txt', 'ipsum.txt')),
588
+ array('/^lorem ipsum dolor sit amet$/m', 'foobar', array('lorem.txt')),
589
+ array('lorem', 'foobar', array('lorem.txt')),
590
+ array('', 'lorem', array('dolor.txt', 'ipsum.txt')),
591
+ array('ipsum dolor sit amet', '/^IPSUM/m', array('lorem.txt')),
592
+ );
593
+ }
594
+
595
+ public function getRegexNameTestData()
596
+ {
597
+ return array(
598
+ array('~.+\\.p.+~i'),
599
+ array('~t.*s~i'),
600
+ );
601
+ }
602
+
603
+ /**
604
+ * @dataProvider getTestPathData
605
+ */
606
+ public function testPath($matchPatterns, $noMatchPatterns, array $expected)
607
+ {
608
+ $finder = $this->buildFinder();
609
+ $finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures')
610
+ ->path($matchPatterns)
611
+ ->notPath($noMatchPatterns);
612
+
613
+ $this->assertIterator($this->toAbsoluteFixtures($expected), $finder);
614
+ }
615
+
616
+ /**
617
+ * @group legacy
618
+ */
619
+ public function testAdapterSelection()
620
+ {
621
+ // test that by default, PhpAdapter is selected
622
+ $adapters = Finder::create()->getAdapters();
623
+ $this->assertTrue($adapters[0] instanceof PhpAdapter);
624
+
625
+ // test another adapter selection
626
+ $adapters = Finder::create()->setAdapter('gnu_find')->getAdapters();
627
+ $this->assertTrue($adapters[0] instanceof GnuFindAdapter);
628
+
629
+ // test that useBestAdapter method removes selection
630
+ $adapters = Finder::create()->useBestAdapter()->getAdapters();
631
+ $this->assertFalse($adapters[0] instanceof PhpAdapter);
632
+ }
633
+
634
+ public function getTestPathData()
635
+ {
636
+ return array(
637
+ array('', '', array()),
638
+ array('/^A\/B\/C/', '/C$/',
639
+ array('A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat'),
640
+ ),
641
+ array('/^A\/B/', 'foobar',
642
+ array(
643
+ 'A'.DIRECTORY_SEPARATOR.'B',
644
+ 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C',
645
+ 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat',
646
+ 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat',
647
+ ),
648
+ ),
649
+ array('A/B/C', 'foobar',
650
+ array(
651
+ 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C',
652
+ 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat',
653
+ 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C',
654
+ 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat.copy',
655
+ ),
656
+ ),
657
+ array('A/B', 'foobar',
658
+ array(
659
+ //dirs
660
+ 'A'.DIRECTORY_SEPARATOR.'B',
661
+ 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C',
662
+ 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B',
663
+ 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C',
664
+ //files
665
+ 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat',
666
+ 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat',
667
+ 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat.copy',
668
+ 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat.copy',
669
+ ),
670
+ ),
671
+ array('/^with space\//', 'foobar',
672
+ array(
673
+ 'with space'.DIRECTORY_SEPARATOR.'foo.txt',
674
+ ),
675
+ ),
676
+ );
677
+ }
678
+
679
+ public function testAccessDeniedException()
680
+ {
681
+ if ('\\' === DIRECTORY_SEPARATOR) {
682
+ $this->markTestSkipped('chmod is not supported on Windows');
683
+ }
684
+
685
+ $finder = $this->buildFinder();
686
+ $finder->files()->in(self::$tmpDir);
687
+
688
+ // make 'foo' directory non-readable
689
+ $testDir = self::$tmpDir.DIRECTORY_SEPARATOR.'foo';
690
+ chmod($testDir, 0333);
691
+
692
+ if (false === $couldRead = is_readable($testDir)) {
693
+ try {
694
+ $this->assertIterator($this->toAbsolute(array('foo bar', 'test.php', 'test.py')), $finder->getIterator());
695
+ $this->fail('Finder should throw an exception when opening a non-readable directory.');
696
+ } catch (\Exception $e) {
697
+ $expectedExceptionClass = 'Symfony\\Component\\Finder\\Exception\\AccessDeniedException';
698
+ if ($e instanceof \PHPUnit_Framework_ExpectationFailedException) {
699
+ $this->fail(sprintf("Expected exception:\n%s\nGot:\n%s\nWith comparison failure:\n%s", $expectedExceptionClass, 'PHPUnit_Framework_ExpectationFailedException', $e->getComparisonFailure()->getExpectedAsString()));
700
+ }
701
+
702
+ $this->assertInstanceOf($expectedExceptionClass, $e);
703
+ }
704
+ }
705
+
706
+ // restore original permissions
707
+ chmod($testDir, 0777);
708
+ clearstatcache($testDir);
709
+
710
+ if ($couldRead) {
711
+ $this->markTestSkipped('could read test files while test requires unreadable');
712
+ }
713
+ }
714
+
715
+ public function testIgnoredAccessDeniedException()
716
+ {
717
+ if ('\\' === DIRECTORY_SEPARATOR) {
718
+ $this->markTestSkipped('chmod is not supported on Windows');
719
+ }
720
+
721
+ $finder = $this->buildFinder();
722
+ $finder->files()->ignoreUnreadableDirs()->in(self::$tmpDir);
723
+
724
+ // make 'foo' directory non-readable
725
+ $testDir = self::$tmpDir.DIRECTORY_SEPARATOR.'foo';
726
+ chmod($testDir, 0333);
727
+
728
+ if (false === ($couldRead = is_readable($testDir))) {
729
+ $this->assertIterator($this->toAbsolute(array('foo bar', 'test.php', 'test.py')), $finder->getIterator());
730
+ }
731
+
732
+ // restore original permissions
733
+ chmod($testDir, 0777);
734
+ clearstatcache($testDir);
735
+
736
+ if ($couldRead) {
737
+ $this->markTestSkipped('could read test files while test requires unreadable');
738
+ }
739
+ }
740
+
741
+ protected function buildFinder()
742
+ {
743
+ return Finder::create();
744
+ }
745
+ }
vendor/symfony/finder/Tests/Fixtures/A/B/C/abc.dat ADDED
File without changes
vendor/symfony/finder/Tests/Fixtures/A/B/ab.dat ADDED
File without changes
vendor/symfony/finder/Tests/Fixtures/A/a.dat ADDED
File without changes
vendor/symfony/finder/Tests/Fixtures/copy/A/B/C/abc.dat.copy ADDED
File without changes
vendor/symfony/finder/Tests/Fixtures/copy/A/B/ab.dat.copy ADDED
File without changes
vendor/symfony/finder/Tests/Fixtures/copy/A/a.dat.copy ADDED
File without changes
vendor/symfony/finder/Tests/Fixtures/dolor.txt ADDED
@@ -0,0 +1,2 @@
 
 
1
+ dolor sit amet
2
+ DOLOR SIT AMET
vendor/symfony/finder/Tests/Fixtures/ipsum.txt ADDED
@@ -0,0 +1,2 @@
 
 
1
+ ipsum dolor sit amet
2
+ IPSUM DOLOR SIT AMET
vendor/symfony/finder/Tests/Fixtures/lorem.txt ADDED
@@ -0,0 +1,2 @@
 
 
1
+ lorem ipsum dolor sit amet
2
+ LOREM IPSUM DOLOR SIT AMET
vendor/symfony/finder/Tests/Fixtures/one/a ADDED
File without changes
vendor/symfony/finder/Tests/Fixtures/one/b/c.neon ADDED
File without changes
vendor/symfony/finder/Tests/Fixtures/one/b/d.neon ADDED
File without changes
vendor/symfony/finder/Tests/Fixtures/r+e.gex[c]a(r)s/dir/bar.dat ADDED
File without changes
vendor/symfony/finder/Tests/Fixtures/with space/foo.txt ADDED
File without changes
vendor/symfony/finder/Tests/GlobTest.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests;
13
+
14
+ use Symfony\Component\Finder\Glob;
15
+
16
+ class GlobTest extends \PHPUnit_Framework_TestCase
17
+ {
18
+ public function testGlobToRegexDelimiters()
19
+ {
20
+ $this->assertEquals('#^(?=[^\.])\#$#', Glob::toRegex('#'));
21
+ $this->assertEquals('#^\.[^/]*$#', Glob::toRegex('.*'));
22
+ $this->assertEquals('^\.[^/]*$', Glob::toRegex('.*', true, true, ''));
23
+ $this->assertEquals('/^\.[^/]*$/', Glob::toRegex('.*', true, true, '/'));
24
+ }
25
+ }
vendor/symfony/finder/Tests/GnuFinderTest.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests;
13
+
14
+ use Symfony\Component\Finder\Adapter\GnuFindAdapter;
15
+ use Symfony\Component\Finder\Finder;
16
+
17
+ /**
18
+ * @group legacy
19
+ */
20
+ class GnuFinderTest extends FinderTest
21
+ {
22
+ protected function buildFinder()
23
+ {
24
+ $adapter = new GnuFindAdapter();
25
+
26
+ if (!$adapter->isSupported()) {
27
+ $this->markTestSkipped(get_class($adapter).' is not supported.');
28
+ }
29
+
30
+ return Finder::create()
31
+ ->removeAdapters()
32
+ ->addAdapter($adapter);
33
+ }
34
+ }
vendor/symfony/finder/Tests/Iterator/CustomFilterIteratorTest.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ use Symfony\Component\Finder\Iterator\CustomFilterIterator;
15
+
16
+ class CustomFilterIteratorTest extends IteratorTestCase
17
+ {
18
+ /**
19
+ * @expectedException \InvalidArgumentException
20
+ */
21
+ public function testWithInvalidFilter()
22
+ {
23
+ new CustomFilterIterator(new Iterator(), array('foo'));
24
+ }
25
+
26
+ /**
27
+ * @dataProvider getAcceptData
28
+ */
29
+ public function testAccept($filters, $expected)
30
+ {
31
+ $inner = new Iterator(array('test.php', 'test.py', 'foo.php'));
32
+
33
+ $iterator = new CustomFilterIterator($inner, $filters);
34
+
35
+ $this->assertIterator($expected, $iterator);
36
+ }
37
+
38
+ public function getAcceptData()
39
+ {
40
+ return array(
41
+ array(array(function (\SplFileInfo $fileinfo) { return false; }), array()),
42
+ array(array(function (\SplFileInfo $fileinfo) { return 0 === strpos($fileinfo, 'test'); }), array('test.php', 'test.py')),
43
+ array(array('is_dir'), array()),
44
+ );
45
+ }
46
+ }
vendor/symfony/finder/Tests/Iterator/DateRangeFilterIteratorTest.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
15
+ use Symfony\Component\Finder\Comparator\DateComparator;
16
+
17
+ class DateRangeFilterIteratorTest extends RealIteratorTestCase
18
+ {
19
+ /**
20
+ * @dataProvider getAcceptData
21
+ */
22
+ public function testAccept($size, $expected)
23
+ {
24
+ $files = self::$files;
25
+ $files[] = self::toAbsolute('doesnotexist');
26
+ $inner = new Iterator($files);
27
+
28
+ $iterator = new DateRangeFilterIterator($inner, $size);
29
+
30
+ $this->assertIterator($expected, $iterator);
31
+ }
32
+
33
+ public function getAcceptData()
34
+ {
35
+ $since20YearsAgo = array(
36
+ '.git',
37
+ 'test.py',
38
+ 'foo',
39
+ 'foo/bar.tmp',
40
+ 'test.php',
41
+ 'toto',
42
+ 'toto/.git',
43
+ '.bar',
44
+ '.foo',
45
+ '.foo/.bar',
46
+ 'foo bar',
47
+ '.foo/bar',
48
+ );
49
+
50
+ $since2MonthsAgo = array(
51
+ '.git',
52
+ 'test.py',
53
+ 'foo',
54
+ 'toto',
55
+ 'toto/.git',
56
+ '.bar',
57
+ '.foo',
58
+ '.foo/.bar',
59
+ 'foo bar',
60
+ '.foo/bar',
61
+ );
62
+
63
+ $untilLastMonth = array(
64
+ 'foo/bar.tmp',
65
+ 'test.php',
66
+ );
67
+
68
+ return array(
69
+ array(array(new DateComparator('since 20 years ago')), $this->toAbsolute($since20YearsAgo)),
70
+ array(array(new DateComparator('since 2 months ago')), $this->toAbsolute($since2MonthsAgo)),
71
+ array(array(new DateComparator('until last month')), $this->toAbsolute($untilLastMonth)),
72
+ );
73
+ }
74
+ }
vendor/symfony/finder/Tests/Iterator/DepthRangeFilterIteratorTest.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
15
+
16
+ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
17
+ {
18
+ /**
19
+ * @dataProvider getAcceptData
20
+ */
21
+ public function testAccept($minDepth, $maxDepth, $expected)
22
+ {
23
+ $inner = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->toAbsolute(), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
24
+
25
+ $iterator = new DepthRangeFilterIterator($inner, $minDepth, $maxDepth);
26
+
27
+ $actual = array_keys(iterator_to_array($iterator));
28
+ sort($expected);
29
+ sort($actual);
30
+ $this->assertEquals($expected, $actual);
31
+ }
32
+
33
+ public function getAcceptData()
34
+ {
35
+ $lessThan1 = array(
36
+ '.git',
37
+ 'test.py',
38
+ 'foo',
39
+ 'test.php',
40
+ 'toto',
41
+ '.foo',
42
+ '.bar',
43
+ 'foo bar',
44
+ );
45
+
46
+ $lessThanOrEqualTo1 = array(
47
+ '.git',
48
+ 'test.py',
49
+ 'foo',
50
+ 'foo/bar.tmp',
51
+ 'test.php',
52
+ 'toto',
53
+ 'toto/.git',
54
+ '.foo',
55
+ '.foo/.bar',
56
+ '.bar',
57
+ 'foo bar',
58
+ '.foo/bar',
59
+ );
60
+
61
+ $graterThanOrEqualTo1 = array(
62
+ 'toto/.git',
63
+ 'foo/bar.tmp',
64
+ '.foo/.bar',
65
+ '.foo/bar',
66
+ );
67
+
68
+ $equalTo1 = array(
69
+ 'toto/.git',
70
+ 'foo/bar.tmp',
71
+ '.foo/.bar',
72
+ '.foo/bar',
73
+ );
74
+
75
+ return array(
76
+ array(0, 0, $this->toAbsolute($lessThan1)),
77
+ array(0, 1, $this->toAbsolute($lessThanOrEqualTo1)),
78
+ array(2, PHP_INT_MAX, array()),
79
+ array(1, PHP_INT_MAX, $this->toAbsolute($graterThanOrEqualTo1)),
80
+ array(1, 1, $this->toAbsolute($equalTo1)),
81
+ );
82
+ }
83
+ }
vendor/symfony/finder/Tests/Iterator/ExcludeDirectoryFilterIteratorTest.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
15
+ use Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator;
16
+
17
+ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
18
+ {
19
+ /**
20
+ * @dataProvider getAcceptData
21
+ */
22
+ public function testAccept($directories, $expected)
23
+ {
24
+ $inner = new \RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->toAbsolute(), \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST);
25
+
26
+ $iterator = new ExcludeDirectoryFilterIterator($inner, $directories);
27
+
28
+ $this->assertIterator($expected, $iterator);
29
+ }
30
+
31
+ public function getAcceptData()
32
+ {
33
+ $foo = array(
34
+ '.bar',
35
+ '.foo',
36
+ '.foo/.bar',
37
+ '.foo/bar',
38
+ '.git',
39
+ 'test.py',
40
+ 'test.php',
41
+ 'toto',
42
+ 'toto/.git',
43
+ 'foo bar',
44
+ );
45
+
46
+ $fo = array(
47
+ '.bar',
48
+ '.foo',
49
+ '.foo/.bar',
50
+ '.foo/bar',
51
+ '.git',
52
+ 'test.py',
53
+ 'foo',
54
+ 'foo/bar.tmp',
55
+ 'test.php',
56
+ 'toto',
57
+ 'toto/.git',
58
+ 'foo bar',
59
+ );
60
+
61
+ return array(
62
+ array(array('foo'), $this->toAbsolute($foo)),
63
+ array(array('fo'), $this->toAbsolute($fo)),
64
+ );
65
+ }
66
+ }
vendor/symfony/finder/Tests/Iterator/FilePathsIteratorTest.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ use Symfony\Component\Finder\Iterator\FilePathsIterator;
15
+
16
+ /**
17
+ * @group legacy
18
+ */
19
+ class FilePathsIteratorTest extends RealIteratorTestCase
20
+ {
21
+ /**
22
+ * @dataProvider getSubPathData
23
+ */
24
+ public function testSubPath($baseDir, array $paths, array $subPaths, array $subPathnames)
25
+ {
26
+ $iterator = new FilePathsIterator($paths, $baseDir);
27
+
28
+ foreach ($iterator as $index => $file) {
29
+ $this->assertEquals($paths[$index], $file->getPathname());
30
+ $this->assertEquals($subPaths[$index], $iterator->getSubPath());
31
+ $this->assertEquals($subPathnames[$index], $iterator->getSubPathname());
32
+ }
33
+ }
34
+
35
+ public function getSubPathData()
36
+ {
37
+ $tmpDir = sys_get_temp_dir().'/symfony_finder';
38
+
39
+ return array(
40
+ array(
41
+ $tmpDir,
42
+ array(
43
+ // paths
44
+ $tmpDir.DIRECTORY_SEPARATOR.'.git' => $tmpDir.DIRECTORY_SEPARATOR.'.git',
45
+ $tmpDir.DIRECTORY_SEPARATOR.'test.py' => $tmpDir.DIRECTORY_SEPARATOR.'test.py',
46
+ $tmpDir.DIRECTORY_SEPARATOR.'foo' => $tmpDir.DIRECTORY_SEPARATOR.'foo',
47
+ $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp' => $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp',
48
+ $tmpDir.DIRECTORY_SEPARATOR.'test.php' => $tmpDir.DIRECTORY_SEPARATOR.'test.php',
49
+ $tmpDir.DIRECTORY_SEPARATOR.'toto' => $tmpDir.DIRECTORY_SEPARATOR.'toto',
50
+ ),
51
+ array(
52
+ // subPaths
53
+ $tmpDir.DIRECTORY_SEPARATOR.'.git' => '',
54
+ $tmpDir.DIRECTORY_SEPARATOR.'test.py' => '',
55
+ $tmpDir.DIRECTORY_SEPARATOR.'foo' => '',
56
+ $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp' => 'foo',
57
+ $tmpDir.DIRECTORY_SEPARATOR.'test.php' => '',
58
+ $tmpDir.DIRECTORY_SEPARATOR.'toto' => '',
59
+ ),
60
+ array(
61
+ // subPathnames
62
+ $tmpDir.DIRECTORY_SEPARATOR.'.git' => '.git',
63
+ $tmpDir.DIRECTORY_SEPARATOR.'test.py' => 'test.py',
64
+ $tmpDir.DIRECTORY_SEPARATOR.'foo' => 'foo',
65
+ $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp' => 'foo'.DIRECTORY_SEPARATOR.'bar.tmp',
66
+ $tmpDir.DIRECTORY_SEPARATOR.'test.php' => 'test.php',
67
+ $tmpDir.DIRECTORY_SEPARATOR.'toto' => 'toto',
68
+ ),
69
+ ),
70
+ );
71
+ }
72
+ }
vendor/symfony/finder/Tests/Iterator/FileTypeFilterIteratorTest.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ use Symfony\Component\Finder\Iterator\FileTypeFilterIterator;
15
+
16
+ class FileTypeFilterIteratorTest extends RealIteratorTestCase
17
+ {
18
+ /**
19
+ * @dataProvider getAcceptData
20
+ */
21
+ public function testAccept($mode, $expected)
22
+ {
23
+ $inner = new InnerTypeIterator(self::$files);
24
+
25
+ $iterator = new FileTypeFilterIterator($inner, $mode);
26
+
27
+ $this->assertIterator($expected, $iterator);
28
+ }
29
+
30
+ public function getAcceptData()
31
+ {
32
+ $onlyFiles = array(
33
+ 'test.py',
34
+ 'foo/bar.tmp',
35
+ 'test.php',
36
+ '.bar',
37
+ '.foo/.bar',
38
+ '.foo/bar',
39
+ 'foo bar',
40
+ );
41
+
42
+ $onlyDirectories = array(
43
+ '.git',
44
+ 'foo',
45
+ 'toto',
46
+ 'toto/.git',
47
+ '.foo',
48
+ );
49
+
50
+ return array(
51
+ array(FileTypeFilterIterator::ONLY_FILES, $this->toAbsolute($onlyFiles)),
52
+ array(FileTypeFilterIterator::ONLY_DIRECTORIES, $this->toAbsolute($onlyDirectories)),
53
+ );
54
+ }
55
+ }
56
+
57
+ class InnerTypeIterator extends \ArrayIterator
58
+ {
59
+ public function current()
60
+ {
61
+ return new \SplFileInfo(parent::current());
62
+ }
63
+
64
+ public function isFile()
65
+ {
66
+ return $this->current()->isFile();
67
+ }
68
+
69
+ public function isDir()
70
+ {
71
+ return $this->current()->isDir();
72
+ }
73
+ }
vendor/symfony/finder/Tests/Iterator/FilecontentFilterIteratorTest.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
15
+
16
+ class FilecontentFilterIteratorTest extends IteratorTestCase
17
+ {
18
+ public function testAccept()
19
+ {
20
+ $inner = new MockFileListIterator(array('test.txt'));
21
+ $iterator = new FilecontentFilterIterator($inner, array(), array());
22
+ $this->assertIterator(array('test.txt'), $iterator);
23
+ }
24
+
25
+ public function testDirectory()
26
+ {
27
+ $inner = new MockFileListIterator(array('directory'));
28
+ $iterator = new FilecontentFilterIterator($inner, array('directory'), array());
29
+ $this->assertIterator(array(), $iterator);
30
+ }
31
+
32
+ public function testUnreadableFile()
33
+ {
34
+ $inner = new MockFileListIterator(array('file r-'));
35
+ $iterator = new FilecontentFilterIterator($inner, array('file r-'), array());
36
+ $this->assertIterator(array(), $iterator);
37
+ }
38
+
39
+ /**
40
+ * @dataProvider getTestFilterData
41
+ */
42
+ public function testFilter(\Iterator $inner, array $matchPatterns, array $noMatchPatterns, array $resultArray)
43
+ {
44
+ $iterator = new FilecontentFilterIterator($inner, $matchPatterns, $noMatchPatterns);
45
+ $this->assertIterator($resultArray, $iterator);
46
+ }
47
+
48
+ public function getTestFilterData()
49
+ {
50
+ $inner = new MockFileListIterator();
51
+
52
+ $inner[] = new MockSplFileInfo(array(
53
+ 'name' => 'a.txt',
54
+ 'contents' => 'Lorem ipsum...',
55
+ 'type' => 'file',
56
+ 'mode' => 'r+', )
57
+ );
58
+
59
+ $inner[] = new MockSplFileInfo(array(
60
+ 'name' => 'b.yml',
61
+ 'contents' => 'dolor sit...',
62
+ 'type' => 'file',
63
+ 'mode' => 'r+', )
64
+ );
65
+
66
+ $inner[] = new MockSplFileInfo(array(
67
+ 'name' => 'some/other/dir/third.php',
68
+ 'contents' => 'amet...',
69
+ 'type' => 'file',
70
+ 'mode' => 'r+', )
71
+ );
72
+
73
+ $inner[] = new MockSplFileInfo(array(
74
+ 'name' => 'unreadable-file.txt',
75
+ 'contents' => false,
76
+ 'type' => 'file',
77
+ 'mode' => 'r+', )
78
+ );
79
+
80
+ return array(
81
+ array($inner, array('.'), array(), array('a.txt', 'b.yml', 'some/other/dir/third.php')),
82
+ array($inner, array('ipsum'), array(), array('a.txt')),
83
+ array($inner, array('i', 'amet'), array('Lorem', 'amet'), array('b.yml')),
84
+ );
85
+ }
86
+ }
vendor/symfony/finder/Tests/Iterator/FilenameFilterIteratorTest.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
15
+
16
+ class FilenameFilterIteratorTest extends IteratorTestCase
17
+ {
18
+ /**
19
+ * @dataProvider getAcceptData
20
+ */
21
+ public function testAccept($matchPatterns, $noMatchPatterns, $expected)
22
+ {
23
+ $inner = new InnerNameIterator(array('test.php', 'test.py', 'foo.php'));
24
+
25
+ $iterator = new FilenameFilterIterator($inner, $matchPatterns, $noMatchPatterns);
26
+
27
+ $this->assertIterator($expected, $iterator);
28
+ }
29
+
30
+ public function getAcceptData()
31
+ {
32
+ return array(
33
+ array(array('test.*'), array(), array('test.php', 'test.py')),
34
+ array(array(), array('test.*'), array('foo.php')),
35
+ array(array('*.php'), array('test.*'), array('foo.php')),
36
+ array(array('*.php', '*.py'), array('foo.*'), array('test.php', 'test.py')),
37
+ array(array('/\.php$/'), array(), array('test.php', 'foo.php')),
38
+ array(array(), array('/\.php$/'), array('test.py')),
39
+ );
40
+ }
41
+ }
42
+
43
+ class InnerNameIterator extends \ArrayIterator
44
+ {
45
+ public function current()
46
+ {
47
+ return new \SplFileInfo(parent::current());
48
+ }
49
+
50
+ public function getFilename()
51
+ {
52
+ return parent::current();
53
+ }
54
+ }
vendor/symfony/finder/Tests/Iterator/FilterIteratorTest.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ /**
15
+ * @author Alex Bogomazov
16
+ */
17
+ class FilterIteratorTest extends RealIteratorTestCase
18
+ {
19
+ public function testFilterFilesystemIterators()
20
+ {
21
+ $i = new \FilesystemIterator($this->toAbsolute());
22
+
23
+ // it is expected that there are test.py test.php in the tmpDir
24
+ $i = $this->getMockForAbstractClass('Symfony\Component\Finder\Iterator\FilterIterator', array($i));
25
+ $i->expects($this->any())
26
+ ->method('accept')
27
+ ->will($this->returnCallback(function () use ($i) {
28
+ return (bool) preg_match('/\.php/', (string) $i->current());
29
+ })
30
+ );
31
+
32
+ $c = 0;
33
+ foreach ($i as $item) {
34
+ ++$c;
35
+ }
36
+
37
+ $this->assertEquals(1, $c);
38
+
39
+ $i->rewind();
40
+
41
+ $c = 0;
42
+ foreach ($i as $item) {
43
+ ++$c;
44
+ }
45
+
46
+ // This would fail in php older than 5.5.23/5.6.7 with \FilterIterator
47
+ // but works with Symfony\Component\Finder\Iterator\FilterIterator
48
+ // see https://bugs.php.net/68557
49
+ $this->assertEquals(1, $c);
50
+ }
51
+ }
vendor/symfony/finder/Tests/Iterator/Iterator.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ class Iterator implements \Iterator
15
+ {
16
+ protected $values = array();
17
+
18
+ public function __construct(array $values = array())
19
+ {
20
+ foreach ($values as $value) {
21
+ $this->attach(new \SplFileInfo($value));
22
+ }
23
+ $this->rewind();
24
+ }
25
+
26
+ public function attach(\SplFileInfo $fileinfo)
27
+ {
28
+ $this->values[] = $fileinfo;
29
+ }
30
+
31
+ public function rewind()
32
+ {
33
+ reset($this->values);
34
+ }
35
+
36
+ public function valid()
37
+ {
38
+ return false !== $this->current();
39
+ }
40
+
41
+ public function next()
42
+ {
43
+ next($this->values);
44
+ }
45
+
46
+ public function current()
47
+ {
48
+ return current($this->values);
49
+ }
50
+
51
+ public function key()
52
+ {
53
+ return key($this->values);
54
+ }
55
+ }
vendor/symfony/finder/Tests/Iterator/IteratorTestCase.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ abstract class IteratorTestCase extends \PHPUnit_Framework_TestCase
15
+ {
16
+ protected function assertIterator($expected, \Traversable $iterator)
17
+ {
18
+ // set iterator_to_array $use_key to false to avoid values merge
19
+ // this made FinderTest::testAppendWithAnArray() fail with GnuFinderAdapter
20
+ $values = array_map(function (\SplFileInfo $fileinfo) { return str_replace('/', DIRECTORY_SEPARATOR, $fileinfo->getPathname()); }, iterator_to_array($iterator, false));
21
+
22
+ $expected = array_map(function ($path) { return str_replace('/', DIRECTORY_SEPARATOR, $path); }, $expected);
23
+
24
+ sort($values);
25
+ sort($expected);
26
+
27
+ $this->assertEquals($expected, array_values($values));
28
+ }
29
+
30
+ protected function assertOrderedIterator($expected, \Traversable $iterator)
31
+ {
32
+ $values = array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator));
33
+
34
+ $this->assertEquals($expected, array_values($values));
35
+ }
36
+
37
+ /**
38
+ * Same as assertOrderedIterator, but checks the order of groups of
39
+ * array elements.
40
+ *
41
+ * @param array $expected - an array of arrays. For any two subarrays
42
+ * $a and $b such that $a goes before $b in $expected, the method
43
+ * asserts that any element of $a goes before any element of $b
44
+ * in the sequence generated by $iterator
45
+ * @param \Traversable $iterator
46
+ */
47
+ protected function assertOrderedIteratorForGroups($expected, \Traversable $iterator)
48
+ {
49
+ $values = array_values(array_map(function (\SplFileInfo $fileinfo) { return $fileinfo->getPathname(); }, iterator_to_array($iterator)));
50
+
51
+ foreach ($expected as $subarray) {
52
+ $temp = array();
53
+ while (count($values) && count($temp) < count($subarray)) {
54
+ $temp[] = array_shift($values);
55
+ }
56
+ sort($temp);
57
+ sort($subarray);
58
+ $this->assertEquals($subarray, $temp);
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Same as IteratorTestCase::assertIterator with foreach usage.
64
+ *
65
+ * @param array $expected
66
+ * @param \Traversable $iterator
67
+ */
68
+ protected function assertIteratorInForeach($expected, \Traversable $iterator)
69
+ {
70
+ $values = array();
71
+ foreach ($iterator as $file) {
72
+ $this->assertInstanceOf('Symfony\\Component\\Finder\\SplFileInfo', $file);
73
+ $values[] = $file->getPathname();
74
+ }
75
+
76
+ sort($values);
77
+ sort($expected);
78
+
79
+ $this->assertEquals($expected, array_values($values));
80
+ }
81
+
82
+ /**
83
+ * Same as IteratorTestCase::assertOrderedIterator with foreach usage.
84
+ *
85
+ * @param array $expected
86
+ * @param \Traversable $iterator
87
+ */
88
+ protected function assertOrderedIteratorInForeach($expected, \Traversable $iterator)
89
+ {
90
+ $values = array();
91
+ foreach ($iterator as $file) {
92
+ $this->assertInstanceOf('Symfony\\Component\\Finder\\SplFileInfo', $file);
93
+ $values[] = $file->getPathname();
94
+ }
95
+
96
+ $this->assertEquals($expected, array_values($values));
97
+ }
98
+ }
vendor/symfony/finder/Tests/Iterator/MockFileListIterator.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ class MockFileListIterator extends \ArrayIterator
15
+ {
16
+ public function __construct(array $filesArray = array())
17
+ {
18
+ $files = array_map(function ($file) { return new MockSplFileInfo($file); }, $filesArray);
19
+ parent::__construct($files);
20
+ }
21
+ }
vendor/symfony/finder/Tests/Iterator/MockSplFileInfo.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ class MockSplFileInfo extends \SplFileInfo
15
+ {
16
+ const TYPE_DIRECTORY = 1;
17
+ const TYPE_FILE = 2;
18
+ const TYPE_UNKNOWN = 3;
19
+
20
+ private $contents = null;
21
+ private $mode = null;
22
+ private $type = null;
23
+ private $relativePath = null;
24
+ private $relativePathname = null;
25
+
26
+ public function __construct($param)
27
+ {
28
+ if (is_string($param)) {
29
+ parent::__construct($param);
30
+ } elseif (is_array($param)) {
31
+ $defaults = array(
32
+ 'name' => 'file.txt',
33
+ 'contents' => null,
34
+ 'mode' => null,
35
+ 'type' => null,
36
+ 'relativePath' => null,
37
+ 'relativePathname' => null,
38
+ );
39
+ $defaults = array_merge($defaults, $param);
40
+ parent::__construct($defaults['name']);
41
+ $this->setContents($defaults['contents']);
42
+ $this->setMode($defaults['mode']);
43
+ $this->setType($defaults['type']);
44
+ $this->setRelativePath($defaults['relativePath']);
45
+ $this->setRelativePathname($defaults['relativePathname']);
46
+ } else {
47
+ throw new \RuntimeException(sprintf('Incorrect parameter "%s"', $param));
48
+ }
49
+ }
50
+
51
+ public function isFile()
52
+ {
53
+ if (null === $this->type) {
54
+ return false !== strpos($this->getFilename(), 'file');
55
+ }
56
+
57
+ return self::TYPE_FILE === $this->type;
58
+ }
59
+
60
+ public function isDir()
61
+ {
62
+ if (null === $this->type) {
63
+ return false !== strpos($this->getFilename(), 'directory');
64
+ }
65
+
66
+ return self::TYPE_DIRECTORY === $this->type;
67
+ }
68
+
69
+ public function isReadable()
70
+ {
71
+ if (null === $this->mode) {
72
+ return preg_match('/r\+/', $this->getFilename());
73
+ }
74
+
75
+ return preg_match('/r\+/', $this->mode);
76
+ }
77
+
78
+ public function getContents()
79
+ {
80
+ return $this->contents;
81
+ }
82
+
83
+ public function setContents($contents)
84
+ {
85
+ $this->contents = $contents;
86
+ }
87
+
88
+ public function setMode($mode)
89
+ {
90
+ $this->mode = $mode;
91
+ }
92
+
93
+ public function setType($type)
94
+ {
95
+ if (is_string($type)) {
96
+ switch ($type) {
97
+ case 'directory':
98
+ $this->type = self::TYPE_DIRECTORY;
99
+ case 'd':
100
+ $this->type = self::TYPE_DIRECTORY;
101
+ break;
102
+ case 'file':
103
+ $this->type = self::TYPE_FILE;
104
+ case 'f':
105
+ $this->type = self::TYPE_FILE;
106
+ break;
107
+ default:
108
+ $this->type = self::TYPE_UNKNOWN;
109
+ }
110
+ } else {
111
+ $this->type = $type;
112
+ }
113
+ }
114
+
115
+ public function setRelativePath($relativePath)
116
+ {
117
+ $this->relativePath = $relativePath;
118
+ }
119
+
120
+ public function setRelativePathname($relativePathname)
121
+ {
122
+ $this->relativePathname = $relativePathname;
123
+ }
124
+
125
+ public function getRelativePath()
126
+ {
127
+ return $this->relativePath;
128
+ }
129
+
130
+ public function getRelativePathname()
131
+ {
132
+ return $this->relativePathname;
133
+ }
134
+ }
vendor/symfony/finder/Tests/Iterator/MultiplePcreFilterIteratorTest.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ use Symfony\Component\Finder\Iterator\MultiplePcreFilterIterator;
15
+
16
+ class MultiplePcreFilterIteratorTest extends \PHPUnit_Framework_TestCase
17
+ {
18
+ /**
19
+ * @dataProvider getIsRegexFixtures
20
+ */
21
+ public function testIsRegex($string, $isRegex, $message)
22
+ {
23
+ $testIterator = new TestMultiplePcreFilterIterator();
24
+ $this->assertEquals($isRegex, $testIterator->isRegex($string), $message);
25
+ }
26
+
27
+ public function getIsRegexFixtures()
28
+ {
29
+ return array(
30
+ array('foo', false, 'string'),
31
+ array(' foo ', false, '" " is not a valid delimiter'),
32
+ array('\\foo\\', false, '"\\" is not a valid delimiter'),
33
+ array('afooa', false, '"a" is not a valid delimiter'),
34
+ array('//', false, 'the pattern should contain at least 1 character'),
35
+ array('/a/', true, 'valid regex'),
36
+ array('/foo/', true, 'valid regex'),
37
+ array('/foo/i', true, 'valid regex with a single modifier'),
38
+ array('/foo/imsxu', true, 'valid regex with multiple modifiers'),
39
+ array('#foo#', true, '"#" is a valid delimiter'),
40
+ array('{foo}', true, '"{,}" is a valid delimiter pair'),
41
+ array('[foo]', true, '"[,]" is a valid delimiter pair'),
42
+ array('(foo)', true, '"(,)" is a valid delimiter pair'),
43
+ array('<foo>', true, '"<,>" is a valid delimiter pair'),
44
+ array('*foo.*', false, '"*" is not considered as a valid delimiter'),
45
+ array('?foo.?', false, '"?" is not considered as a valid delimiter'),
46
+ );
47
+ }
48
+ }
49
+
50
+ class TestMultiplePcreFilterIterator extends MultiplePcreFilterIterator
51
+ {
52
+ public function __construct()
53
+ {
54
+ }
55
+
56
+ public function accept()
57
+ {
58
+ throw new \BadFunctionCallException('Not implemented');
59
+ }
60
+
61
+ public function isRegex($str)
62
+ {
63
+ return parent::isRegex($str);
64
+ }
65
+
66
+ public function toRegex($str)
67
+ {
68
+ throw new \BadFunctionCallException('Not implemented');
69
+ }
70
+ }
vendor/symfony/finder/Tests/Iterator/PathFilterIteratorTest.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ use Symfony\Component\Finder\Iterator\PathFilterIterator;
15
+
16
+ class PathFilterIteratorTest extends IteratorTestCase
17
+ {
18
+ /**
19
+ * @dataProvider getTestFilterData
20
+ */
21
+ public function testFilter(\Iterator $inner, array $matchPatterns, array $noMatchPatterns, array $resultArray)
22
+ {
23
+ $iterator = new PathFilterIterator($inner, $matchPatterns, $noMatchPatterns);
24
+ $this->assertIterator($resultArray, $iterator);
25
+ }
26
+
27
+ public function getTestFilterData()
28
+ {
29
+ $inner = new MockFileListIterator();
30
+
31
+ //PATH: A/B/C/abc.dat
32
+ $inner[] = new MockSplFileInfo(array(
33
+ 'name' => 'abc.dat',
34
+ 'relativePathname' => 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat',
35
+ ));
36
+
37
+ //PATH: A/B/ab.dat
38
+ $inner[] = new MockSplFileInfo(array(
39
+ 'name' => 'ab.dat',
40
+ 'relativePathname' => 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat',
41
+ ));
42
+
43
+ //PATH: A/a.dat
44
+ $inner[] = new MockSplFileInfo(array(
45
+ 'name' => 'a.dat',
46
+ 'relativePathname' => 'A'.DIRECTORY_SEPARATOR.'a.dat',
47
+ ));
48
+
49
+ //PATH: copy/A/B/C/abc.dat.copy
50
+ $inner[] = new MockSplFileInfo(array(
51
+ 'name' => 'abc.dat.copy',
52
+ 'relativePathname' => 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat',
53
+ ));
54
+
55
+ //PATH: copy/A/B/ab.dat.copy
56
+ $inner[] = new MockSplFileInfo(array(
57
+ 'name' => 'ab.dat.copy',
58
+ 'relativePathname' => 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat',
59
+ ));
60
+
61
+ //PATH: copy/A/a.dat.copy
62
+ $inner[] = new MockSplFileInfo(array(
63
+ 'name' => 'a.dat.copy',
64
+ 'relativePathname' => 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'a.dat',
65
+ ));
66
+
67
+ return array(
68
+ array($inner, array('/^A/'), array(), array('abc.dat', 'ab.dat', 'a.dat')),
69
+ array($inner, array('/^A\/B/'), array(), array('abc.dat', 'ab.dat')),
70
+ array($inner, array('/^A\/B\/C/'), array(), array('abc.dat')),
71
+ array($inner, array('/A\/B\/C/'), array(), array('abc.dat', 'abc.dat.copy')),
72
+
73
+ array($inner, array('A'), array(), array('abc.dat', 'ab.dat', 'a.dat', 'abc.dat.copy', 'ab.dat.copy', 'a.dat.copy')),
74
+ array($inner, array('A/B'), array(), array('abc.dat', 'ab.dat', 'abc.dat.copy', 'ab.dat.copy')),
75
+ array($inner, array('A/B/C'), array(), array('abc.dat', 'abc.dat.copy')),
76
+
77
+ array($inner, array('copy/A'), array(), array('abc.dat.copy', 'ab.dat.copy', 'a.dat.copy')),
78
+ array($inner, array('copy/A/B'), array(), array('abc.dat.copy', 'ab.dat.copy')),
79
+ array($inner, array('copy/A/B/C'), array(), array('abc.dat.copy')),
80
+
81
+ );
82
+ }
83
+ }
vendor/symfony/finder/Tests/Iterator/RealIteratorTestCase.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ abstract class RealIteratorTestCase extends IteratorTestCase
15
+ {
16
+ protected static $tmpDir;
17
+ protected static $files;
18
+
19
+ public static function setUpBeforeClass()
20
+ {
21
+ self::$tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'symfony_finder';
22
+
23
+ self::$files = array(
24
+ '.git/',
25
+ '.foo/',
26
+ '.foo/.bar',
27
+ '.foo/bar',
28
+ '.bar',
29
+ 'test.py',
30
+ 'foo/',
31
+ 'foo/bar.tmp',
32
+ 'test.php',
33
+ 'toto/',
34
+ 'toto/.git/',
35
+ 'foo bar',
36
+ );
37
+
38
+ self::$files = self::toAbsolute(self::$files);
39
+
40
+ if (is_dir(self::$tmpDir)) {
41
+ self::tearDownAfterClass();
42
+ } else {
43
+ mkdir(self::$tmpDir);
44
+ }
45
+
46
+ foreach (self::$files as $file) {
47
+ if (DIRECTORY_SEPARATOR === $file[strlen($file) - 1]) {
48
+ mkdir($file);
49
+ } else {
50
+ touch($file);
51
+ }
52
+ }
53
+
54
+ file_put_contents(self::toAbsolute('test.php'), str_repeat(' ', 800));
55
+ file_put_contents(self::toAbsolute('test.py'), str_repeat(' ', 2000));
56
+
57
+ touch(self::toAbsolute('foo/bar.tmp'), strtotime('2005-10-15'));
58
+ touch(self::toAbsolute('test.php'), strtotime('2005-10-15'));
59
+ }
60
+
61
+ public static function tearDownAfterClass()
62
+ {
63
+ foreach (array_reverse(self::$files) as $file) {
64
+ if (DIRECTORY_SEPARATOR === $file[strlen($file) - 1]) {
65
+ @rmdir($file);
66
+ } else {
67
+ @unlink($file);
68
+ }
69
+ }
70
+ }
71
+
72
+ protected static function toAbsolute($files = null)
73
+ {
74
+ /*
75
+ * Without the call to setUpBeforeClass() property can be null.
76
+ */
77
+ if (!self::$tmpDir) {
78
+ self::$tmpDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'symfony_finder';
79
+ }
80
+
81
+ if (is_array($files)) {
82
+ $f = array();
83
+ foreach ($files as $file) {
84
+ if (is_array($file)) {
85
+ $f[] = self::toAbsolute($file);
86
+ } else {
87
+ $f[] = self::$tmpDir.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $file);
88
+ }
89
+ }
90
+
91
+ return $f;
92
+ }
93
+
94
+ if (is_string($files)) {
95
+ return self::$tmpDir.DIRECTORY_SEPARATOR.str_replace('/', DIRECTORY_SEPARATOR, $files);
96
+ }
97
+
98
+ return self::$tmpDir;
99
+ }
100
+
101
+ protected static function toAbsoluteFixtures($files)
102
+ {
103
+ $f = array();
104
+ foreach ($files as $file) {
105
+ $f[] = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.$file);
106
+ }
107
+
108
+ return $f;
109
+ }
110
+ }
vendor/symfony/finder/Tests/Iterator/RecursiveDirectoryIteratorTest.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ use Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator;
15
+
16
+ class RecursiveDirectoryIteratorTest extends IteratorTestCase
17
+ {
18
+ /**
19
+ * @group network
20
+ */
21
+ public function testRewindOnFtp()
22
+ {
23
+ try {
24
+ $i = new RecursiveDirectoryIterator('ftp://speedtest.tele2.net/', \RecursiveDirectoryIterator::SKIP_DOTS);
25
+ } catch (\UnexpectedValueException $e) {
26
+ $this->markTestSkipped('Unsupported stream "ftp".');
27
+ }
28
+
29
+ $i->rewind();
30
+
31
+ $this->assertTrue(true);
32
+ }
33
+
34
+ /**
35
+ * @group network
36
+ */
37
+ public function testSeekOnFtp()
38
+ {
39
+ try {
40
+ $i = new RecursiveDirectoryIterator('ftp://speedtest.tele2.net/', \RecursiveDirectoryIterator::SKIP_DOTS);
41
+ } catch (\UnexpectedValueException $e) {
42
+ $this->markTestSkipped('Unsupported stream "ftp".');
43
+ }
44
+
45
+ $contains = array(
46
+ 'ftp://speedtest.tele2.net'.DIRECTORY_SEPARATOR.'1000GB.zip',
47
+ 'ftp://speedtest.tele2.net'.DIRECTORY_SEPARATOR.'100GB.zip',
48
+ );
49
+ $actual = array();
50
+
51
+ $i->seek(0);
52
+ $actual[] = $i->getPathname();
53
+
54
+ $i->seek(1);
55
+ $actual[] = $i->getPathname();
56
+
57
+ $this->assertEquals($contains, $actual);
58
+ }
59
+ }
vendor/symfony/finder/Tests/Iterator/SizeRangeFilterIteratorTest.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
15
+ use Symfony\Component\Finder\Comparator\NumberComparator;
16
+
17
+ class SizeRangeFilterIteratorTest extends RealIteratorTestCase
18
+ {
19
+ /**
20
+ * @dataProvider getAcceptData
21
+ */
22
+ public function testAccept($size, $expected)
23
+ {
24
+ $inner = new InnerSizeIterator(self::$files);
25
+
26
+ $iterator = new SizeRangeFilterIterator($inner, $size);
27
+
28
+ $this->assertIterator($expected, $iterator);
29
+ }
30
+
31
+ public function getAcceptData()
32
+ {
33
+ $lessThan1KGreaterThan05K = array(
34
+ '.foo',
35
+ '.git',
36
+ 'foo',
37
+ 'test.php',
38
+ 'toto',
39
+ 'toto/.git',
40
+ );
41
+
42
+ return array(
43
+ array(array(new NumberComparator('< 1K'), new NumberComparator('> 0.5K')), $this->toAbsolute($lessThan1KGreaterThan05K)),
44
+ );
45
+ }
46
+ }
47
+
48
+ class InnerSizeIterator extends \ArrayIterator
49
+ {
50
+ public function current()
51
+ {
52
+ return new \SplFileInfo(parent::current());
53
+ }
54
+
55
+ public function getFilename()
56
+ {
57
+ return parent::current();
58
+ }
59
+
60
+ public function isFile()
61
+ {
62
+ return $this->current()->isFile();
63
+ }
64
+
65
+ public function getSize()
66
+ {
67
+ return $this->current()->getSize();
68
+ }
69
+ }
vendor/symfony/finder/Tests/Iterator/SortableIteratorTest.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Iterator;
13
+
14
+ use Symfony\Component\Finder\Iterator\SortableIterator;
15
+
16
+ class SortableIteratorTest extends RealIteratorTestCase
17
+ {
18
+ public function testConstructor()
19
+ {
20
+ try {
21
+ new SortableIterator(new Iterator(array()), 'foobar');
22
+ $this->fail('__construct() throws an \InvalidArgumentException exception if the mode is not valid');
23
+ } catch (\Exception $e) {
24
+ $this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException exception if the mode is not valid');
25
+ }
26
+ }
27
+
28
+ /**
29
+ * @dataProvider getAcceptData
30
+ */
31
+ public function testAccept($mode, $expected)
32
+ {
33
+ if (!is_callable($mode)) {
34
+ switch ($mode) {
35
+ case SortableIterator::SORT_BY_ACCESSED_TIME :
36
+ if ('\\' === DIRECTORY_SEPARATOR) {
37
+ touch(self::toAbsolute('.git'));
38
+ } else {
39
+ file_get_contents(self::toAbsolute('.git'));
40
+ }
41
+ sleep(1);
42
+ file_get_contents(self::toAbsolute('.bar'));
43
+ break;
44
+ case SortableIterator::SORT_BY_CHANGED_TIME :
45
+ file_put_contents(self::toAbsolute('test.php'), 'foo');
46
+ sleep(1);
47
+ file_put_contents(self::toAbsolute('test.py'), 'foo');
48
+ break;
49
+ case SortableIterator::SORT_BY_MODIFIED_TIME :
50
+ file_put_contents(self::toAbsolute('test.php'), 'foo');
51
+ sleep(1);
52
+ file_put_contents(self::toAbsolute('test.py'), 'foo');
53
+ break;
54
+ }
55
+ }
56
+
57
+ $inner = new Iterator(self::$files);
58
+
59
+ $iterator = new SortableIterator($inner, $mode);
60
+
61
+ if ($mode === SortableIterator::SORT_BY_ACCESSED_TIME
62
+ || $mode === SortableIterator::SORT_BY_CHANGED_TIME
63
+ || $mode === SortableIterator::SORT_BY_MODIFIED_TIME
64
+ ) {
65
+ if ('\\' === DIRECTORY_SEPARATOR && SortableIterator::SORT_BY_MODIFIED_TIME !== $mode) {
66
+ $this->markTestSkipped('Sorting by atime or ctime is not supported on Windows');
67
+ }
68
+ $this->assertOrderedIteratorForGroups($expected, $iterator);
69
+ } else {
70
+ $this->assertOrderedIterator($expected, $iterator);
71
+ }
72
+ }
73
+
74
+ public function getAcceptData()
75
+ {
76
+ $sortByName = array(
77
+ '.bar',
78
+ '.foo',
79
+ '.foo/.bar',
80
+ '.foo/bar',
81
+ '.git',
82
+ 'foo',
83
+ 'foo bar',
84
+ 'foo/bar.tmp',
85
+ 'test.php',
86
+ 'test.py',
87
+ 'toto',
88
+ 'toto/.git',
89
+ );
90
+
91
+ $sortByType = array(
92
+ '.foo',
93
+ '.git',
94
+ 'foo',
95
+ 'toto',
96
+ 'toto/.git',
97
+ '.bar',
98
+ '.foo/.bar',
99
+ '.foo/bar',
100
+ 'foo bar',
101
+ 'foo/bar.tmp',
102
+ 'test.php',
103
+ 'test.py',
104
+ );
105
+
106
+ $customComparison = array(
107
+ '.bar',
108
+ '.foo',
109
+ '.foo/.bar',
110
+ '.foo/bar',
111
+ '.git',
112
+ 'foo',
113
+ 'foo bar',
114
+ 'foo/bar.tmp',
115
+ 'test.php',
116
+ 'test.py',
117
+ 'toto',
118
+ 'toto/.git',
119
+ );
120
+
121
+ $sortByAccessedTime = array(
122
+ // For these two files the access time was set to 2005-10-15
123
+ array('foo/bar.tmp', 'test.php'),
124
+ // These files were created more or less at the same time
125
+ array(
126
+ '.git',
127
+ '.foo',
128
+ '.foo/.bar',
129
+ '.foo/bar',
130
+ 'test.py',
131
+ 'foo',
132
+ 'toto',
133
+ 'toto/.git',
134
+ 'foo bar',
135
+ ),
136
+ // This file was accessed after sleeping for 1 sec
137
+ array('.bar'),
138
+ );
139
+
140
+ $sortByChangedTime = array(
141
+ array(
142
+ '.git',
143
+ '.foo',
144
+ '.foo/.bar',
145
+ '.foo/bar',
146
+ '.bar',
147
+ 'foo',
148
+ 'foo/bar.tmp',
149
+ 'toto',
150
+ 'toto/.git',
151
+ 'foo bar',
152
+ ),
153
+ array('test.php'),
154
+ array('test.py'),
155
+ );
156
+
157
+ $sortByModifiedTime = array(
158
+ array(
159
+ '.git',
160
+ '.foo',
161
+ '.foo/.bar',
162
+ '.foo/bar',
163
+ '.bar',
164
+ 'foo',
165
+ 'foo/bar.tmp',
166
+ 'toto',
167
+ 'toto/.git',
168
+ 'foo bar',
169
+ ),
170
+ array('test.php'),
171
+ array('test.py'),
172
+ );
173
+
174
+ return array(
175
+ array(SortableIterator::SORT_BY_NAME, $this->toAbsolute($sortByName)),
176
+ array(SortableIterator::SORT_BY_TYPE, $this->toAbsolute($sortByType)),
177
+ array(SortableIterator::SORT_BY_ACCESSED_TIME, $this->toAbsolute($sortByAccessedTime)),
178
+ array(SortableIterator::SORT_BY_CHANGED_TIME, $this->toAbsolute($sortByChangedTime)),
179
+ array(SortableIterator::SORT_BY_MODIFIED_TIME, $this->toAbsolute($sortByModifiedTime)),
180
+ array(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }, $this->toAbsolute($customComparison)),
181
+ );
182
+ }
183
+ }
vendor/symfony/finder/Tests/PhpFinderTest.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests;
13
+
14
+ use Symfony\Component\Finder\Adapter\PhpAdapter;
15
+ use Symfony\Component\Finder\Finder;
16
+
17
+ /**
18
+ * @group legacy
19
+ */
20
+ class PhpFinderTest extends FinderTest
21
+ {
22
+ public function testImplementationsAreSynchronized()
23
+ {
24
+ $adapterReflector = new \ReflectionMethod('Symfony\Component\Finder\Adapter\PhpAdapter', 'searchInDirectory');
25
+ $finderReflector = new \ReflectionMethod('Symfony\Component\Finder\Finder', 'searchInDirectory');
26
+
27
+ $adapterSource = array_slice(file($adapterReflector->getFileName()), $adapterReflector->getStartLine() + 1, $adapterReflector->getEndLine() - $adapterReflector->getStartLine() - 1);
28
+ $adapterSource = implode('', $adapterSource);
29
+ $adapterSource = str_replace(array('$this->minDepth', '$this->maxDepth'), array('$minDepth', '$maxDepth'), $adapterSource);
30
+
31
+ $finderSource = array_slice(file($finderReflector->getFileName()), $finderReflector->getStartLine() + 1, $finderReflector->getEndLine() - $finderReflector->getStartLine() - 1);
32
+ $finderSource = implode('', $finderSource);
33
+
34
+ $this->assertStringEndsWith($adapterSource, $finderSource);
35
+ }
36
+
37
+ protected function buildFinder()
38
+ {
39
+ $adapter = new PhpAdapter();
40
+
41
+ return Finder::create()
42
+ ->removeAdapters()
43
+ ->addAdapter($adapter);
44
+ }
45
+ }
vendor/symfony/finder/Tests/Shell/CommandTest.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Component\Finder\Tests\Shell;
13
+
14
+ use Symfony\Component\Finder\Shell\Command;
15
+
16
+ /**
17
+ * @group legacy
18
+ */
19
+ class CommandTest extends \PHPUnit_Framework_TestCase
20
+ {
21
+ public function testCreate()
22
+ {
23
+ $this->assertInstanceOf('Symfony\Component\Finder\Shell\Command', Command::create());
24
+ }
25
+
26
+ public function testAdd()
27
+ {
28
+ $cmd = Command::create()->add('--force');
29
+ $this->assertSame('--force', $cmd->join());
30
+ }
31
+
32
+ public function testAddAsFirst()
33
+ {
34
+ $cmd = Command::create()->add('--force');
35
+
36
+ $cmd->addAtIndex(Command::create()->add('-F'), 0);
37
+ $this->assertSame('-F --force', $cmd->join());
38
+ }
39
+
40
+ public function testAddAsLast()
41
+ {
42
+ $cmd = Command::create()->add('--force');
43
+
44
+ $cmd->addAtIndex(Command::create()->add('-F'), 1);
45
+ $this->assertSame('--force -F', $cmd->join());
46
+ }
47
+
48
+ public function testAddInBetween()
49
+ {
50
+ $cmd = Command::create()->add('--force');
51
+ $cmd->addAtIndex(Command::create()->add('-F'), 0);
52
+
53
+ $cmd->addAtIndex(Command::create()->add('-X'), 1);
54
+ $this->assertSame('-F -X --force', $cmd->join());
55
+ }
56
+
57
+ public function testCount()
58
+ {
59
+ $cmd = Command::create();
60
+ $this->assertSame(0, $cmd->length());
61
+
62
+ $cmd->add('--force');
63
+ $this->assertSame(1, $cmd->length());
64
+
65
+ $cmd->add('--run');
66
+ $this->assertSame(2, $cmd->length());
67
+ }
68
+
69
+ public function testTop()
70
+ {
71
+ $cmd = Command::create()->add('--force');
72
+
73
+ $cmd->top('--run');
74
+ $this->assertSame('--run --force', $cmd->join());
75
+ }
76
+
77
+ public function testTopLabeled()
78
+ {
79
+ $cmd = Command::create()->add('--force');
80
+
81
+ $cmd->top('--run');
82
+ $cmd->ins('--something');
83
+ $cmd->top('--something');
84
+ $this->assertSame('--something --run --force ', $cmd->join());
85
+ }
86
+
87
+ public function testArg()
88
+ {
89
+ $cmd = Command::create()->add('--force');
90
+
91
+ $cmd->arg('--run');
92
+ $this->assertSame('--force '.escapeshellarg('--run'), $cmd->join());
93
+ }
94
+
95
+ public function testCmd()
96
+ {
97
+ $cmd = Command::create()->add('--force');
98
+
99
+ $cmd->cmd('run');
100
+ $this->assertSame('--force run', $cmd->join());
101
+ }
102
+
103
+ public function testInsDuplicateLabelException()
104
+ {
105
+ $cmd = Command::create()->add('--force');
106
+
107
+ $cmd->ins('label');
108
+ $this->setExpectedException('RuntimeException');
109
+ $cmd->ins('label');
110
+ }
111
+
112
+ public function testEnd()
113
+ {
114
+ $parent = Command::create();
115
+ $cmd = Command::create($parent);
116
+
117
+ $this->assertSame($parent, $cmd->end());
118
+ }
119
+
120
+ public function testEndNoParentException()
121
+ {
122
+ $cmd = Command::create();
123
+
124
+ $this->setExpectedException('RuntimeException');
125
+ $cmd->end();
126
+ }
127
+
128
+ public function testGetMissingLabelException()
129
+ {
130
+ $cmd = Command::create();
131
+
132
+ $this->setExpectedException('RuntimeException');
133
+ $cmd->get('invalid');
134
+ }
135
+
136
+ public function testErrorHandler()
137
+ {
138
+ $cmd = Command::create();
139
+ $handler = function () { return 'error-handler'; };
140
+ $cmd->setErrorHandler($handler);
141
+
142
+ $this->assertSame($handler, $cmd->getErrorHandler());
143
+ }
144
+
145
+ public function testExecute()
146
+ {
147
+ $cmd = Command::create();
148
+ $cmd->add('php');
149
+ $cmd->add('--version');
150
+ $result = $cmd->execute();
151
+
152
+ $this->assertInternalType('array', $result);
153
+ $this->assertNotEmpty($result);
154
+ $this->assertRegexp('/PHP|HipHop/', $result[0]);
155
+ }
156
+
157
+ public function testCastToString()
158
+ {
159
+ $cmd = Command::create();
160
+ $cmd->add('--force');
161
+ $cmd->add('--run');
162
+
163
+ $this->assertSame('--force --run', (string) $cmd);
164
+ }
165
+ }
vendor/symfony/process/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ vendor/
2
+ composer.lock
3
+ phpunit.xml
vendor/symfony/process/README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Process Component
2
+ =================
3
+
4
+ The Process component executes commands in sub-processes.
5
+
6
+ Resources
7
+ ---------
8
+
9
+ * [Documentation](https://symfony.com/doc/current/components/process.html)
10
+ * [Contributing](https://symfony.com/doc/current/contributing/index.html)
11
+ * [Report issues](https://github.com/symfony/symfony/issues) and
12
+ [send Pull Requests](https://github.com/symfony/symfony/pulls)
13
+ in the [main Symfony repository](https://github.com/symfony/symfony)