Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 778723a

Browse files
author
Jamie Snape
committed
Update PHPUnit to 3.7.35
1 parent 33e2aec commit 778723a

File tree

411 files changed

+23960
-18332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

411 files changed

+23960
-18332
lines changed

tests/library/PHPUnit/File/Iterator.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* php-file-iterator
44
*
5-
* Copyright (c) 2009-2011, Sebastian Bergmann <sb@sebastian-bergmann.de>.
5+
* Copyright (c) 2009-2013, Sebastian Bergmann <sebastian@phpunit.de>.
66
* All rights reserved.
77
*
88
* Redistribution and use in source and binary forms, with or without
@@ -35,20 +35,20 @@
3535
* POSSIBILITY OF SUCH DAMAGE.
3636
*
3737
* @package File
38-
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
39-
* @copyright 2009-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
40-
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
38+
* @author Sebastian Bergmann <sebastian@phpunit.de>
39+
* @copyright 2009-2013 Sebastian Bergmann <sebastian@phpunit.de>
40+
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
4141
* @since File available since Release 1.0.0
4242
*/
4343

4444
/**
4545
* FilterIterator implementation that filters files based on prefix(es) and/or
4646
* suffix(es). Hidden files and files from hidden directories are also filtered.
4747
*
48-
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
49-
* @copyright 2009-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
50-
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
51-
* @version Release: 1.2.6
48+
* @author Sebastian Bergmann <sebastian@phpunit.de>
49+
* @copyright 2009-2013 Sebastian Bergmann <sebastian@phpunit.de>
50+
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
51+
* @version Release: 1.3.4
5252
* @link http://github.com/sebastianbergmann/php-file-iterator/tree
5353
* @since Class available since Release 1.0.0
5454
*/
@@ -194,4 +194,3 @@ protected function acceptSubString($filename, array $subStrings, $type)
194194
return $matched;
195195
}
196196
}
197-
?>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* php-file-iterator
4+
*
5+
* Copyright (c) 2009-2013, Sebastian Bergmann <sebastian@phpunit.de>.
6+
* All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions
10+
* are met:
11+
*
12+
* * Redistributions of source code must retain the above copyright
13+
* notice, this list of conditions and the following disclaimer.
14+
*
15+
* * Redistributions in binary form must reproduce the above copyright
16+
* notice, this list of conditions and the following disclaimer in
17+
* the documentation and/or other materials provided with the
18+
* distribution.
19+
*
20+
* * Neither the name of Sebastian Bergmann nor the names of his
21+
* contributors may be used to endorse or promote products derived
22+
* from this software without specific prior written permission.
23+
*
24+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35+
* POSSIBILITY OF SUCH DAMAGE.
36+
*
37+
* @package File
38+
* @author Sebastian Bergmann <sebastian@phpunit.de>
39+
* @copyright 2009-2013 Sebastian Bergmann <sebastian@phpunit.de>
40+
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
41+
* @since File available since Release 1.3.0
42+
*/
43+
44+
spl_autoload_register(
45+
function ($class)
46+
{
47+
static $classes = NULL;
48+
static $path = NULL;
49+
50+
if ($classes === NULL) {
51+
$classes = array(
52+
'file_iterator' => '/Iterator.php',
53+
'file_iterator_facade' => '/Iterator/Facade.php',
54+
'file_iterator_factory' => '/Iterator/Factory.php'
55+
);
56+
57+
$path = dirname(dirname(__FILE__));
58+
}
59+
60+
$cn = strtolower($class);
61+
62+
if (isset($classes[$cn])) {
63+
require $path . $classes[$cn];
64+
}
65+
}
66+
);
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
<?php
2+
/**
3+
* php-file-iterator
4+
*
5+
* Copyright (c) 2009-2013, Sebastian Bergmann <sebastian@phpunit.de>.
6+
* All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions
10+
* are met:
11+
*
12+
* * Redistributions of source code must retain the above copyright
13+
* notice, this list of conditions and the following disclaimer.
14+
*
15+
* * Redistributions in binary form must reproduce the above copyright
16+
* notice, this list of conditions and the following disclaimer in
17+
* the documentation and/or other materials provided with the
18+
* distribution.
19+
*
20+
* * Neither the name of Sebastian Bergmann nor the names of his
21+
* contributors may be used to endorse or promote products derived
22+
* from this software without specific prior written permission.
23+
*
24+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35+
* POSSIBILITY OF SUCH DAMAGE.
36+
*
37+
* @package File
38+
* @author Sebastian Bergmann <sebastian@phpunit.de>
39+
* @copyright 2009-2013 Sebastian Bergmann <sebastian@phpunit.de>
40+
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
41+
* @since File available since Release 1.3.0
42+
*/
43+
44+
/**
45+
* Façade implementation that uses File_Iterator_Factory to create a
46+
* File_Iterator that operates on an AppendIterator that contains an
47+
* RecursiveDirectoryIterator for each given path. The list of unique
48+
* files is returned as an array.
49+
*
50+
* @author Sebastian Bergmann <sebastian@phpunit.de>
51+
* @copyright 2009-2013 Sebastian Bergmann <sebastian@phpunit.de>
52+
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
53+
* @version Release: 1.3.4
54+
* @link http://github.com/sebastianbergmann/php-file-iterator/tree
55+
* @since Class available since Release 1.3.0
56+
*/
57+
class File_Iterator_Facade
58+
{
59+
/**
60+
* @param array|string $paths
61+
* @param array|string $suffixes
62+
* @param array|string $prefixes
63+
* @param array $exclude
64+
* @param boolean $commonPath
65+
* @return array
66+
*/
67+
public function getFilesAsArray($paths, $suffixes = '', $prefixes = '', array $exclude = array(), $commonPath = FALSE)
68+
{
69+
if (is_string($paths)) {
70+
$paths = array($paths);
71+
}
72+
73+
$factory = new File_Iterator_Factory;
74+
$iterator = $factory->getFileIterator(
75+
$paths, $suffixes, $prefixes, $exclude
76+
);
77+
78+
$files = array();
79+
80+
foreach ($iterator as $file) {
81+
$file = $file->getRealPath();
82+
83+
if ($file) {
84+
$files[] = $file;
85+
}
86+
}
87+
88+
foreach ($paths as $path) {
89+
if (is_file($path)) {
90+
$files[] = realpath($path);
91+
}
92+
}
93+
94+
$files = array_unique($files);
95+
sort($files);
96+
97+
if ($commonPath) {
98+
return array(
99+
'commonPath' => $this->getCommonPath($files),
100+
'files' => $files
101+
);
102+
} else {
103+
return $files;
104+
}
105+
}
106+
107+
/**
108+
* Returns the common path of a set of files.
109+
*
110+
* @param array $files
111+
* @return string
112+
*/
113+
protected function getCommonPath(array $files)
114+
{
115+
$count = count($files);
116+
117+
if ($count == 0) {
118+
return '';
119+
}
120+
121+
if ($count == 1) {
122+
return dirname($files[0]) . DIRECTORY_SEPARATOR;
123+
}
124+
125+
$_files = array();
126+
127+
foreach ($files as $file) {
128+
$_files[] = $_fileParts = explode(DIRECTORY_SEPARATOR, $file);
129+
130+
if (empty($_fileParts[0])) {
131+
$_fileParts[0] = DIRECTORY_SEPARATOR;
132+
}
133+
}
134+
135+
$common = '';
136+
$done = FALSE;
137+
$j = 0;
138+
$count--;
139+
140+
while (!$done) {
141+
for ($i = 0; $i < $count; $i++) {
142+
if ($_files[$i][$j] != $_files[$i+1][$j]) {
143+
$done = TRUE;
144+
break;
145+
}
146+
}
147+
148+
if (!$done) {
149+
$common .= $_files[0][$j];
150+
151+
if ($j > 0) {
152+
$common .= DIRECTORY_SEPARATOR;
153+
}
154+
}
155+
156+
$j++;
157+
}
158+
159+
return DIRECTORY_SEPARATOR . $common;
160+
}
161+
}

tests/library/PHPUnit/File/Iterator/Factory.php

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* php-file-iterator
44
*
5-
* Copyright (c) 2009-2011, Sebastian Bergmann <sb@sebastian-bergmann.de>.
5+
* Copyright (c) 2009-2013, Sebastian Bergmann <sebastian@phpunit.de>.
66
* All rights reserved.
77
*
88
* Redistribution and use in source and binary forms, with or without
@@ -35,23 +35,21 @@
3535
* POSSIBILITY OF SUCH DAMAGE.
3636
*
3737
* @package File
38-
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
39-
* @copyright 2009-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
40-
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
38+
* @author Sebastian Bergmann <sebastian@phpunit.de>
39+
* @copyright 2009-2013 Sebastian Bergmann <sebastian@phpunit.de>
40+
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
4141
* @since File available since Release 1.1.0
4242
*/
4343

44-
require_once 'File/Iterator.php';
45-
4644
/**
4745
* Factory Method implementation that creates a File_Iterator that operates on
4846
* an AppendIterator that contains an RecursiveDirectoryIterator for each given
4947
* path.
5048
*
51-
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
52-
* @copyright 2009-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
53-
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
54-
* @version Release: 1.2.6
49+
* @author Sebastian Bergmann <sebastian@phpunit.de>
50+
* @copyright 2009-2013 Sebastian Bergmann <sebastian@phpunit.de>
51+
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
52+
* @version Release: 1.3.4
5553
* @link http://github.com/sebastianbergmann/php-file-iterator/tree
5654
* @since Class available since Release 1.1.0
5755
*/
@@ -64,7 +62,7 @@ class File_Iterator_Factory
6462
* @param array $exclude
6563
* @return AppendIterator
6664
*/
67-
public static function getFileIterator($paths, $suffixes = '', $prefixes = '', array $exclude = array())
65+
public function getFileIterator($paths, $suffixes = '', $prefixes = '', array $exclude = array())
6866
{
6967
if (is_string($paths)) {
7068
$paths = array($paths);
@@ -106,7 +104,7 @@ public static function getFileIterator($paths, $suffixes = '', $prefixes = '', a
106104
$iterator->append(
107105
new File_Iterator(
108106
new RecursiveIteratorIterator(
109-
new RecursiveDirectoryIterator($path)
107+
new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::FOLLOW_SYMLINKS)
110108
),
111109
$suffixes,
112110
$prefixes,
@@ -119,41 +117,4 @@ public static function getFileIterator($paths, $suffixes = '', $prefixes = '', a
119117

120118
return $iterator;
121119
}
122-
123-
/**
124-
* @param array|string $paths
125-
* @param array|string $suffixes
126-
* @param array|string $prefixes
127-
* @param array $exclude
128-
* @return array
129-
*/
130-
public static function getFilesAsArray($paths, $suffixes = '', $prefixes = '', array $exclude = array())
131-
{
132-
if (is_string($paths)) {
133-
$paths = array($paths);
134-
}
135-
136-
$result = array();
137-
138-
$iterator = self::getFileIterator(
139-
$paths, $suffixes, $prefixes, $exclude
140-
);
141-
142-
foreach ($iterator as $file) {
143-
$file = $file->getRealPath();
144-
145-
if ($file) {
146-
$result[] = $file;
147-
}
148-
}
149-
150-
foreach ($paths as $path) {
151-
if (is_file($path)) {
152-
$result[] = realpath($path);
153-
}
154-
}
155-
156-
return array_unique($result);
157-
}
158120
}
159-
?>

0 commit comments

Comments
 (0)