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

@ -74,7 +74,7 @@ class DirectoryWrapper implements Directory {
} }
/** /**
* @param string $options the options for the context to wrap the stream with * @param array $options the options for the context to wrap the stream with
* @param string $class * @param string $class
* @return resource * @return resource
*/ */

View file

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

View file

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