Skip to content

Commit

Permalink
fixup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Mar 2, 2021
1 parent b8bea69 commit 1c6d181
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 20 deletions.
4 changes: 3 additions & 1 deletion tests/DirectoryFilter.php → tests/DirectoryFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Icewind\Streams\Tests;

class DirectoryWrapper extends IteratorDirectory {
class DirectoryTestWrapperTest extends IteratorDirectoryTest {

/**
* @param \Iterator | array $source
Expand Down
17 changes: 7 additions & 10 deletions tests/IteratorDirectory.php → tests/IteratorDirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,10 +20,8 @@ protected function wrapSource($source) {
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 {
Expand All @@ -32,10 +33,8 @@ public function testNoContext() {
}
}

/**
* @expectedException \BadMethodCallException
*/
public function testNoSource() {
$this->expectException(BadMethodCallException::class);
$context = stream_context_create([
'dir' => [
'foo' => 'bar'
Expand All @@ -51,10 +50,8 @@ public function testNoSource() {
}
}

/**
* @expectedException \BadMethodCallException
*/
public function testWrapInvalidSource() {
$this->expectException(BadMethodCallException::class);
$this->wrapSource(2);
}

Expand Down
4 changes: 3 additions & 1 deletion tests/PathWrapper.php → tests/PathWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/RetryWrapper.php → tests/RetryWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Icewind\Streams\Tests;

class RetryWrapper extends WrapperTest {
class RetryWrapperTest extends WrapperTest {

/**
* @param resource $source
Expand All @@ -34,6 +34,6 @@ public function testFailedRead() {
public function testFailedWrite() {
$source = fopen('php://temp', 'w');
$wrapped = \Icewind\Streams\RetryWrapper::wrap(FailWrapper::wrap($source));
fwrite($wrapped, 'foo');
$this->assertFalse(fwrite($wrapped, 'foo'));
}
}
4 changes: 3 additions & 1 deletion tests/SeekableWrapper.php → tests/SeekableWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions tests/UrlCallback.php → tests/UrlCallbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -17,7 +19,7 @@ protected function getTempDir() {
return $dir;
}

public function tearDown() {
public function tearDown(): void {
foreach ($this->tempDirs as $dir) {
$this->rmdir($dir);
}
Expand Down Expand Up @@ -83,7 +85,7 @@ public function testRMDirCallBack() {
mkdir($dir);
$path = \Icewind\Streams\UrlCallback::wrap($dir, null, null, null, null, $callback);
rmdir($path);
$this->assertFileNotExists($dir);
$this->assertFileDoesNotExist($dir);
$this->assertTrue($called);
}

Expand All @@ -110,7 +112,7 @@ public function testUnlinkCallBack() {
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);
}

Expand Down

0 comments on commit 1c6d181

Please sign in to comment.