fix 5.3 compatiblity of tests

This commit is contained in:
Robin Appelman 2015-10-16 15:55:10 +02:00
commit f8cbccabd5
3 changed files with 14 additions and 11 deletions

View file

@ -9,33 +9,36 @@ namespace Icewind\Streams\Tests;
class DirectoryFilter extends \PHPUnit_Framework_TestCase {
public function testFilterAcceptAll() {
$this->filter(['a', 'b', 'c'],
$this->filter(array('a', 'b', 'c'),
function () {
return true;
},
['a', 'b', 'c']);
array('a', 'b', 'c')
);
}
public function testFilterRejectAll() {
$this->filter(['a', 'b', 'c'],
$this->filter(array('a', 'b', 'c'),
function () {
return false;
},
[]);
array()
);
}
public function testFilterRejectLong() {
$this->filter(['a', 'bb', 'c'],
$this->filter(array('a', 'bb', 'c'),
function ($file) {
return strlen($file) < 2;
},
['a', 'c']);
array('a', 'c')
);
}
private function filter(array $files, callable $filter, array $expected) {
$source = \Icewind\Streams\IteratorDirectory::wrap($files);
$filtered = \Icewind\Streams\DirectoryFilter::wrap($source, $filter);
$result = [];
$result = array();
while (($file = readdir($filtered)) !== false) {
$result[] = $file;
}

View file

@ -47,12 +47,12 @@ class DirectoryWrapper extends IteratorDirectory {
}
public function testManipulateContent() {
$source = \Icewind\Streams\IteratorDirectory::wrap(['asd', 'bar']);
$source = \Icewind\Streams\IteratorDirectory::wrap(array('asd', 'bar'));
$wrapped = DirectoryWrapperDummy::wrap($source);
$result = [];
$result = array();
while (($file = readdir($wrapped)) !== false) {
$result[] = $file;
}
$this->assertEquals(['asd_', 'bar_'], $result);
$this->assertEquals(array('asd_', 'bar_'), $result);
}
}