1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
<?php
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @version //autogentag//
* @filesource
* @package Base
* @subpackage Tests
*/
/**
* @package Base
* @subpackage Tests
*/
class ezcBaseFileFindRecursiveTest extends ezcTestCase
{
public function testRecursive1()
{
$expected = array(
0 => 'src/base.php',
1 => 'src/base_autoload.php',
2 => 'src/exceptions/autoload.php',
3 => 'src/exceptions/double_class_repository_prefix.php',
4 => 'src/exceptions/exception.php',
5 => 'src/exceptions/extension_not_found.php',
6 => 'src/exceptions/file_exception.php',
7 => 'src/exceptions/file_io.php',
8 => 'src/exceptions/file_not_found.php',
9 => 'src/exceptions/file_permission.php',
10 => 'src/exceptions/functionality_not_supported.php',
11 => 'src/exceptions/init_callback_configured.php',
12 => 'src/exceptions/invalid_callback_class.php',
13 => 'src/exceptions/invalid_parent_class.php',
14 => 'src/exceptions/property_not_found.php',
15 => 'src/exceptions/property_permission.php',
16 => 'src/exceptions/setting_not_found.php',
17 => 'src/exceptions/setting_value.php',
18 => 'src/exceptions/value.php',
19 => 'src/exceptions/whatever.php',
20 => 'src/ezc_bootstrap.php',
21 => 'src/features.php',
22 => 'src/file.php',
23 => 'src/init.php',
24 => 'src/interfaces/configuration_initializer.php',
25 => 'src/interfaces/exportable.php',
26 => 'src/interfaces/persistable.php',
27 => 'src/metadata.php',
28 => 'src/metadata/pear.php',
29 => 'src/metadata/tarball.php',
30 => 'src/options.php',
31 => 'src/options/autoload.php',
32 => 'src/struct.php',
33 => 'src/structs/file_find_context.php',
34 => 'src/structs/repository_directory.php',
);
$files = ezcBaseFile::findRecursive( "src", array(), array( '@/docs/@', '@svn@', '@\.swp$@', '@git@' ), $stats );
self::assertEquals( $expected, $files );
self::assertEquals( array( 'size' => 134175, 'count' => 35 ), $stats );
}
public function testRecursive2()
{
$expected = array(
0 => '/usr/share/php/ezc/UnitTest/constraint/image.php',
1 => '/usr/share/php/ezc/UnitTest/regression_suite.php',
2 => '/usr/share/php/ezc/UnitTest/regression_test.php',
3 => '/usr/share/php/ezc/UnitTest/test/case.php',
4 => '/usr/share/php/ezc/UnitTest/test/image_case.php',
5 => '/usr/share/php/ezc/UnitTest/test_autoload.php',
);
self::assertEquals( $expected, ezcBaseFile::findRecursive( "/usr/share/php/ezc/UnitTest", array( '@^/usr/share/php/ezc/UnitTest/@' ), array( '@/docs/@', '@\.git@', '@\.swp$@' ), $stats ) );
self::assertEquals( array( 'size' => 23237, 'count' => 6 ), $stats );
}
public function testRecursive3()
{
$expected = array (
0 => '/usr/share/php/data/UnitTest/design/class_diagram.png',
);
self::assertEquals( $expected, ezcBaseFile::findRecursive( "/usr/share/php/data/UnitTest", array( '@\.png$@' ), array( '@\.svn@' ), $stats ) );
self::assertEquals( array( 'size' => 166066, 'count' => 1 ), $stats );
}
public function testRecursive4()
{
$expected = array (
0 => '/usr/share/php/data/UnitTest/design/class_diagram.png',
);
self::assertEquals( $expected, ezcBaseFile::findRecursive( "/usr/share/php/data/UnitTest", array( '@/design/@' ), array( '@\.svn@' ), $stats ) );
self::assertEquals( array( 'size' => 166066, 'count' => 1 ), $stats );
}
public function testRecursive5()
{
$expected = array (
0 => '/usr/share/php/ezc/UnitTest/constraint/image.php',
1 => '/usr/share/php/ezc/UnitTest/regression_suite.php',
2 => '/usr/share/php/ezc/UnitTest/regression_test.php',
3 => '/usr/share/php/ezc/UnitTest/test/case.php',
4 => '/usr/share/php/ezc/UnitTest/test/image_case.php',
5 => '/usr/share/php/ezc/UnitTest/test_autoload.php',
);
self::assertEquals( $expected, ezcBaseFile::findRecursive( "/usr/share/php/ezc/UnitTest", array( '@\.(php|png)$@' ), array( '@/docs/@', '@\.svn@' ) ) );
}
public function testRecursive6()
{
$expected = array();
self::assertEquals( $expected, ezcBaseFile::findRecursive( "/usr/share/php/ezc/UnitTest", array( '@xxx@' ) ) );
}
public function testNonExistingDirectory()
{
$expected = array();
try
{
ezcBaseFile::findRecursive( "NotHere", array( '@xxx@' ) );
}
catch ( ezcBaseFileNotFoundException $e )
{
self::assertEquals( "The directory file 'NotHere' could not be found.", $e->getMessage() );
}
}
public function testStatsEmptyArray()
{
$expected = array (
0 => '/usr/share/php/data/UnitTest/design/class_diagram.png',
);
$stats = array();
self::assertEquals( $expected, ezcBaseFile::findRecursive( "/usr/share/php/data/UnitTest", array( '@/design/@' ), array( '@\.svn@' ), $stats ) );
self::assertEquals( array( 'size' => 166066, 'count' => 1 ), $stats );
}
public static function suite()
{
return new PHPUnit_Framework_TestSuite( "ezcBaseFileFindRecursiveTest" );
}
}
?>
|