fixup tests

This commit is contained in:
Robin Appelman 2021-03-02 20:07:51 +01:00
commit 1c6d18170e
7 changed files with 25 additions and 20 deletions

View file

@ -7,7 +7,9 @@
namespace Icewind\Streams\Tests;
class DirectoryFilter extends \PHPUnit_Framework_TestCase {
use PHPUnit\Framework\TestCase;
class DirectoryFilterTest extends TestCase {
public function testFilterAcceptAll() {
$this->filter(
['a', 'b', 'c'],

View file

@ -7,7 +7,7 @@
namespace Icewind\Streams\Tests;
class DirectoryWrapper extends IteratorDirectory {
class DirectoryTestWrapperTest extends IteratorDirectoryTest {
/**
* @param \Iterator | array $source

View file

@ -7,7 +7,10 @@
namespace Icewind\Streams\Tests;
class IteratorDirectory extends \PHPUnit_Framework_TestCase {
use \BadMethodCallException;
use PHPUnit\Framework\TestCase;
class IteratorDirectoryTest extends TestCase {
/**
* @param \Iterator | array $source
@ -17,10 +20,8 @@ class IteratorDirectory extends \PHPUnit_Framework_TestCase {
return \Icewind\Streams\IteratorDirectory::wrap($source);
}
/**
* @expectedException \BadMethodCallException
*/
public function testNoContext() {
$this->expectException(BadMethodCallException::class);
$context = stream_context_create([]);
stream_wrapper_register('iterator', '\Icewind\Streams\IteratorDirectory');
try {
@ -32,10 +33,8 @@ class IteratorDirectory extends \PHPUnit_Framework_TestCase {
}
}
/**
* @expectedException \BadMethodCallException
*/
public function testNoSource() {
$this->expectException(BadMethodCallException::class);
$context = stream_context_create([
'dir' => [
'foo' => 'bar'
@ -51,10 +50,8 @@ class IteratorDirectory extends \PHPUnit_Framework_TestCase {
}
}
/**
* @expectedException \BadMethodCallException
*/
public function testWrapInvalidSource() {
$this->expectException(BadMethodCallException::class);
$this->wrapSource(2);
}

View file

@ -7,7 +7,9 @@
namespace Icewind\Streams\Tests;
class PathWrapper extends \PHPUnit_Framework_TestCase {
use PHPUnit\Framework\TestCase;
class PathWrapperTest extends TestCase {
private function getDataStream($data) {
$stream = fopen('php://temp', 'w+');
fwrite($stream, $data);

View file

@ -7,7 +7,7 @@
namespace Icewind\Streams\Tests;
class RetryWrapper extends WrapperTest {
class RetryWrapperTest extends WrapperTest {
/**
* @param resource $source
@ -34,6 +34,6 @@ class RetryWrapper extends WrapperTest {
public function testFailedWrite() {
$source = fopen('php://temp', 'w');
$wrapped = \Icewind\Streams\RetryWrapper::wrap(FailWrapper::wrap($source));
fwrite($wrapped, 'foo');
$this->assertFalse(fwrite($wrapped, 'foo'));
}
}

View file

@ -7,7 +7,9 @@
namespace Icewind\Streams\Tests;
class SeekableWrapper extends \PHPUnit_Framework_TestCase {
use PHPUnit\Framework\TestCase;
class SeekableWrapperTest extends TestCase {
/**
* @param resource $source
* @return resource

View file

@ -7,7 +7,9 @@
namespace Icewind\Streams\Tests;
class UrlCallback extends \PHPUnit_Framework_TestCase {
use PHPUnit\Framework\TestCase;
class UrlCallbackTest extends TestCase {
protected $tempDirs = [];
protected function getTempDir() {
@ -17,7 +19,7 @@ class UrlCallback extends \PHPUnit_Framework_TestCase {
return $dir;
}
public function tearDown() {
public function tearDown(): void {
foreach ($this->tempDirs as $dir) {
$this->rmdir($dir);
}
@ -83,7 +85,7 @@ class UrlCallback extends \PHPUnit_Framework_TestCase {
mkdir($dir);
$path = \Icewind\Streams\UrlCallback::wrap($dir, null, null, null, null, $callback);
rmdir($path);
$this->assertFileNotExists($dir);
$this->assertFileDoesNotExist($dir);
$this->assertTrue($called);
}
@ -110,7 +112,7 @@ class UrlCallback extends \PHPUnit_Framework_TestCase {
touch($file);
$path = \Icewind\Streams\UrlCallback::wrap($file, null, null, null, null, null, $callback);
unlink($path);
$this->assertFileNotExists($file);
$this->assertFileDoesNotExist($file);
$this->assertTrue($called);
}