mirror of
https://codeberg.org/icewind/streams.git
synced 2026-06-03 16:44:07 +02:00
fix 5.3 compatiblity of tests
This commit is contained in:
parent
2e2fe951e9
commit
f8cbccabd5
3 changed files with 14 additions and 11 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue