Пример #1
0
$finder = nbFileFinder::create('file');
$names = array('Class1.php', 'Class2.php', 'Class3.php');
$finder->sortByName();
$files = $finder->add('*.php')->in($dataDir);
$t->is(count($files), 3, '->add() found 3 files');
for ($i = 0; $i != count($files); ++$i) {
    $t->is(nbFileSystem::getFileName($files[$i]), $names[$i], '->add() found ' . $names[$i]);
}
$t->comment('nbFileFinder - Test discard and sort');
$finder = nbFileFinder::create('file');
$names = array('Class1.php', 'Class2.php', 'Class3.php');
$finder->sortByName();
$files = $finder->discard('Class.java')->in($dataDir);
$t->is(count($files), 3, '->discard() found 3 files');
for ($i = 0; $i != count($files); ++$i) {
    $t->is(nbFileSystem::getFileName($files[$i]), $names[$i], '->discard() found ' . $names[$i]);
}
$t->comment('nbFileFinder - Test execute function or method');
$GLOBALS['callbackFunctionCount'] = 0;
function callbackFunction()
{
    ++$GLOBALS['callbackFunctionCount'];
}
class CallbackClass
{
    public $callbackMethodCount = 0;
    public function callbackMethod()
    {
        ++$this->callbackMethodCount;
    }
}