1--TEST-- 2PEAR_PackageFileManager_File->_setupDirs, proof-of-concept 3--SKIPIF-- 4<?php 5if (@file_exists(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'CVS')) { 6 echo 'skip cannot run in CVS'; 7} 8?> 9--FILE-- 10<?php 11require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'setup.php.inc'; 12$pfm->_options['addhiddenfiles'] = false; 13$pfm->_options['ignore'] = 14$pfm->_options['include'] = false; 15$pfm->_setupIgnore(false, 0); 16$pfm->_setupIgnore(false, 1); 17$list = $pfm->dirList($package_directory = 18 dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest'); 19$struc = array(); 20foreach($list as $file) { 21 $path = substr(dirname($file), strlen(str_replace(DIRECTORY_SEPARATOR, 22 '/', 23 realpath($package_directory))) + 1); 24 if (!$path) { 25 $path = '/'; 26 } 27 $a = explode('.', $file); 28 $ext = array_pop($a); 29 if (strlen($ext) == strlen($file)) { 30 $ext = ''; 31 } 32 $struc[$path][] = array('file' => basename($file), 33 'ext' => $ext, 34 'path' => (($path == '/') ? basename($file) : $path . '/' . basename($file)), 35 'fullpath' => $file); 36} 37$phpunit->assertEquals( 38 array( 39 'blarfoo' => 40 array( 41 array('file' => 'blartest.txt', 42 'ext' => 'txt', 43 'path' => 'blarfoo/blartest.txt', 44 'fullpath' => dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/blarfoo/blartest.txt') 45 ), 46 'subfoo/subsubfoo' => 47 array( 48 array('file' => 'boo.txt', 49 'ext' => 'txt', 50 'path' => 'subfoo/subsubfoo/boo.txt', 51 'fullpath' =>dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/subfoo/subsubfoo/boo.txt') 52 ), 53 'subfoo' => 54 array( 55 array('file' => 'test11.txt', 56 'ext' => 'txt', 57 'path' => 'subfoo/test11.txt', 58 'fullpath' =>dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/subfoo/test11.txt'), 59 array('file' => 'test12.txt', 60 'ext' => 'txt', 61 'path' => 'subfoo/test12.txt', 62 'fullpath' =>dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/subfoo/test12.txt'), 63 ), 64 '/' => 65 array( 66 array('file' => 'test1.txt', 67 'ext' => 'txt', 68 'path' => 'test1.txt', 69 'fullpath' =>dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/test1.txt'), 70 array('file' => 'test2.txt', 71 'ext' => 'txt', 72 'path' => 'test2.txt', 73 'fullpath' =>dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/test2.txt'), 74 ), 75 'testCVS' => 76 array( 77 0 => 78 array( 79 'file' => 'testEntries', 80 'ext' => '', 81 'path' => 'testCVS/testEntries', 82 'fullpath' => dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/testCVS/testEntries', 83 ), 84 array( 85 'file' => 'testEntries.Extra', 86 'ext' => 'Extra', 87 'path' => 'testCVS/testEntries.Extra', 88 'fullpath' => dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/testCVS/testEntries.Extra', 89 ), 90 ), 91 ), $struc, 'wrong basic structure'); 92uksort($struc,'strnatcasecmp'); 93foreach($struc as $key => $ind) { 94 usort($ind, array($pfm, 'sortfiles')); 95 $struc[$key] = $ind; 96} 97$phpunit->assertEquals( 98array ( 99 '/' => 100 array ( 101 0 => 102 array ( 103 'file' => 'test1.txt', 104 'ext' => 'txt', 105 'path' => 'test1.txt', 106 'fullpath' => dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/test1.txt', 107 ), 108 1 => 109 array ( 110 'file' => 'test2.txt', 111 'ext' => 'txt', 112 'path' => 'test2.txt', 113 'fullpath' => dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/test2.txt', 114 ), 115 ), 116 'blarfoo' => 117 array ( 118 0 => 119 array ( 120 'file' => 'blartest.txt', 121 'ext' => 'txt', 122 'path' => 'blarfoo/blartest.txt', 123 'fullpath' => dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/blarfoo/blartest.txt', 124 ), 125 ), 126 'subfoo' => 127 array ( 128 0 => 129 array ( 130 'file' => 'test11.txt', 131 'ext' => 'txt', 132 'path' => 'subfoo/test11.txt', 133 'fullpath' => dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/subfoo/test11.txt', 134 ), 135 1 => 136 array ( 137 'file' => 'test12.txt', 138 'ext' => 'txt', 139 'path' => 'subfoo/test12.txt', 140 'fullpath' => dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/subfoo/test12.txt', 141 ), 142 ), 143 'subfoo/subsubfoo' => 144 array ( 145 0 => 146 array ( 147 'file' => 'boo.txt', 148 'ext' => 'txt', 149 'path' => 'subfoo/subsubfoo/boo.txt', 150 'fullpath' => dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/subfoo/subsubfoo/boo.txt', 151 ), 152 ), 153 'testCVS' => 154 array ( 155 0 => 156 array ( 157 'file' => 'testEntries', 158 'ext' => '', 159 'path' => 'testCVS/testEntries', 160 'fullpath' => dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/testCVS/testEntries', 161 ), 162 1 => 163 array ( 164 'file' => 'testEntries.Extra', 165 'ext' => 'Extra', 166 'path' => 'testCVS/testEntries.Extra', 167 'fullpath' => dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'footest/testCVS/testEntries.Extra', 168 ), 169 ), 170), $struc, 'wrong sorted structure'); 171echo 'tests done'; 172?> 173--EXPECT-- 174tests done 175