mirror of
https://codeberg.org/icewind/streams.git
synced 2026-06-03 16:44:07 +02:00
fixup tests
This commit is contained in:
parent
b8bea69ea6
commit
1c6d18170e
7 changed files with 25 additions and 20 deletions
|
|
@ -7,7 +7,9 @@
|
||||||
|
|
||||||
namespace Icewind\Streams\Tests;
|
namespace Icewind\Streams\Tests;
|
||||||
|
|
||||||
class DirectoryFilter extends \PHPUnit_Framework_TestCase {
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class DirectoryFilterTest extends TestCase {
|
||||||
public function testFilterAcceptAll() {
|
public function testFilterAcceptAll() {
|
||||||
$this->filter(
|
$this->filter(
|
||||||
['a', 'b', 'c'],
|
['a', 'b', 'c'],
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
namespace Icewind\Streams\Tests;
|
namespace Icewind\Streams\Tests;
|
||||||
|
|
||||||
class DirectoryWrapper extends IteratorDirectory {
|
class DirectoryTestWrapperTest extends IteratorDirectoryTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Iterator | array $source
|
* @param \Iterator | array $source
|
||||||
|
|
@ -7,7 +7,10 @@
|
||||||
|
|
||||||
namespace Icewind\Streams\Tests;
|
namespace Icewind\Streams\Tests;
|
||||||
|
|
||||||
class IteratorDirectory extends \PHPUnit_Framework_TestCase {
|
use \BadMethodCallException;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class IteratorDirectoryTest extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Iterator | array $source
|
* @param \Iterator | array $source
|
||||||
|
|
@ -17,10 +20,8 @@ class IteratorDirectory extends \PHPUnit_Framework_TestCase {
|
||||||
return \Icewind\Streams\IteratorDirectory::wrap($source);
|
return \Icewind\Streams\IteratorDirectory::wrap($source);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \BadMethodCallException
|
|
||||||
*/
|
|
||||||
public function testNoContext() {
|
public function testNoContext() {
|
||||||
|
$this->expectException(BadMethodCallException::class);
|
||||||
$context = stream_context_create([]);
|
$context = stream_context_create([]);
|
||||||
stream_wrapper_register('iterator', '\Icewind\Streams\IteratorDirectory');
|
stream_wrapper_register('iterator', '\Icewind\Streams\IteratorDirectory');
|
||||||
try {
|
try {
|
||||||
|
|
@ -32,10 +33,8 @@ class IteratorDirectory extends \PHPUnit_Framework_TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \BadMethodCallException
|
|
||||||
*/
|
|
||||||
public function testNoSource() {
|
public function testNoSource() {
|
||||||
|
$this->expectException(BadMethodCallException::class);
|
||||||
$context = stream_context_create([
|
$context = stream_context_create([
|
||||||
'dir' => [
|
'dir' => [
|
||||||
'foo' => 'bar'
|
'foo' => 'bar'
|
||||||
|
|
@ -51,10 +50,8 @@ class IteratorDirectory extends \PHPUnit_Framework_TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \BadMethodCallException
|
|
||||||
*/
|
|
||||||
public function testWrapInvalidSource() {
|
public function testWrapInvalidSource() {
|
||||||
|
$this->expectException(BadMethodCallException::class);
|
||||||
$this->wrapSource(2);
|
$this->wrapSource(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -7,7 +7,9 @@
|
||||||
|
|
||||||
namespace Icewind\Streams\Tests;
|
namespace Icewind\Streams\Tests;
|
||||||
|
|
||||||
class PathWrapper extends \PHPUnit_Framework_TestCase {
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class PathWrapperTest extends TestCase {
|
||||||
private function getDataStream($data) {
|
private function getDataStream($data) {
|
||||||
$stream = fopen('php://temp', 'w+');
|
$stream = fopen('php://temp', 'w+');
|
||||||
fwrite($stream, $data);
|
fwrite($stream, $data);
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
namespace Icewind\Streams\Tests;
|
namespace Icewind\Streams\Tests;
|
||||||
|
|
||||||
class RetryWrapper extends WrapperTest {
|
class RetryWrapperTest extends WrapperTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param resource $source
|
* @param resource $source
|
||||||
|
|
@ -34,6 +34,6 @@ class RetryWrapper extends WrapperTest {
|
||||||
public function testFailedWrite() {
|
public function testFailedWrite() {
|
||||||
$source = fopen('php://temp', 'w');
|
$source = fopen('php://temp', 'w');
|
||||||
$wrapped = \Icewind\Streams\RetryWrapper::wrap(FailWrapper::wrap($source));
|
$wrapped = \Icewind\Streams\RetryWrapper::wrap(FailWrapper::wrap($source));
|
||||||
fwrite($wrapped, 'foo');
|
$this->assertFalse(fwrite($wrapped, 'foo'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,9 @@
|
||||||
|
|
||||||
namespace Icewind\Streams\Tests;
|
namespace Icewind\Streams\Tests;
|
||||||
|
|
||||||
class SeekableWrapper extends \PHPUnit_Framework_TestCase {
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class SeekableWrapperTest extends TestCase {
|
||||||
/**
|
/**
|
||||||
* @param resource $source
|
* @param resource $source
|
||||||
* @return resource
|
* @return resource
|
||||||
|
|
@ -7,7 +7,9 @@
|
||||||
|
|
||||||
namespace Icewind\Streams\Tests;
|
namespace Icewind\Streams\Tests;
|
||||||
|
|
||||||
class UrlCallback extends \PHPUnit_Framework_TestCase {
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class UrlCallbackTest extends TestCase {
|
||||||
protected $tempDirs = [];
|
protected $tempDirs = [];
|
||||||
|
|
||||||
protected function getTempDir() {
|
protected function getTempDir() {
|
||||||
|
|
@ -17,7 +19,7 @@ class UrlCallback extends \PHPUnit_Framework_TestCase {
|
||||||
return $dir;
|
return $dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
public function tearDown(): void {
|
||||||
foreach ($this->tempDirs as $dir) {
|
foreach ($this->tempDirs as $dir) {
|
||||||
$this->rmdir($dir);
|
$this->rmdir($dir);
|
||||||
}
|
}
|
||||||
|
|
@ -83,7 +85,7 @@ class UrlCallback extends \PHPUnit_Framework_TestCase {
|
||||||
mkdir($dir);
|
mkdir($dir);
|
||||||
$path = \Icewind\Streams\UrlCallback::wrap($dir, null, null, null, null, $callback);
|
$path = \Icewind\Streams\UrlCallback::wrap($dir, null, null, null, null, $callback);
|
||||||
rmdir($path);
|
rmdir($path);
|
||||||
$this->assertFileNotExists($dir);
|
$this->assertFileDoesNotExist($dir);
|
||||||
$this->assertTrue($called);
|
$this->assertTrue($called);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,7 +112,7 @@ class UrlCallback extends \PHPUnit_Framework_TestCase {
|
||||||
touch($file);
|
touch($file);
|
||||||
$path = \Icewind\Streams\UrlCallback::wrap($file, null, null, null, null, null, $callback);
|
$path = \Icewind\Streams\UrlCallback::wrap($file, null, null, null, null, null, $callback);
|
||||||
unlink($path);
|
unlink($path);
|
||||||
$this->assertFileNotExists($file);
|
$this->assertFileDoesNotExist($file);
|
||||||
$this->assertTrue($called);
|
$this->assertTrue($called);
|
||||||
}
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue