1
0
mirror of https://github.com/danog/file.git synced 2025-01-22 21:31:15 +01:00

Update tests for PHPUnit deprecations

This commit is contained in:
Aaron Piotrowski 2019-08-23 13:23:33 -05:00
parent 1bce4b075d
commit 6f11e413e9
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB
3 changed files with 31 additions and 40 deletions

View File

@ -3,14 +3,14 @@
namespace Amp\File\Test;
use Amp\File;
use Amp\File\PendingOperationError;
abstract class AsyncHandleTest extends HandleTest
{
/**
* @expectedException \Amp\File\PendingOperationError
*/
public function testSimultaneousReads()
{
$this->expectException(PendingOperationError::class);
$this->execute(function () {
/** @var \Amp\File\Handle $handle */
$handle = yield File\open(__FILE__, "r");
@ -25,11 +25,10 @@ abstract class AsyncHandleTest extends HandleTest
});
}
/**
* @expectedException \Amp\File\PendingOperationError
*/
public function testSeekWhileReading()
{
$this->expectException(PendingOperationError::class);
$this->execute(function () {
/** @var \Amp\File\Handle $handle */
$handle = yield File\open(__FILE__, "r");
@ -44,11 +43,10 @@ abstract class AsyncHandleTest extends HandleTest
});
}
/**
* @expectedException \Amp\File\PendingOperationError
*/
public function testReadWhileWriting()
{
$this->expectException(PendingOperationError::class);
$this->execute(function () {
/** @var \Amp\File\Handle $handle */
$handle = yield File\open(__FILE__, "r");
@ -64,11 +62,10 @@ abstract class AsyncHandleTest extends HandleTest
});
}
/**
* @expectedException \Amp\File\PendingOperationError
*/
public function testWriteWhileReading()
{
$this->expectException(PendingOperationError::class);
$this->execute(function () {
/** @var \Amp\File\Handle $handle */
$handle = yield File\open(__FILE__, "r");

View File

@ -3,6 +3,7 @@
namespace Amp\File\Test;
use Amp\File;
use Amp\File\FilesystemException;
use Amp\PHPUnit\TestCase;
abstract class DriverTest extends TestCase
@ -30,21 +31,19 @@ abstract class DriverTest extends TestCase
});
}
/**
* @expectedException \Amp\File\FilesystemException
*/
public function testScandirThrowsIfPathNotADirectory()
{
$this->expectException(FilesystemException::class);
$this->execute(function () {
(yield File\scandir(__FILE__));
});
}
/**
* @expectedException \Amp\File\FilesystemException
*/
public function testScandirThrowsIfPathDoesntExist()
{
$this->expectException(FilesystemException::class);
$this->execute(function () {
$path = Fixture::path() . "/nonexistent";
(yield File\scandir($path));
@ -91,12 +90,13 @@ abstract class DriverTest extends TestCase
/**
* @dataProvider readlinkPathProvider
* @expectedException \Amp\File\FilesystemException
*
* @param \Closure $linkResolver
*/
public function testReadlinkError(\Closure $linkResolver)
{
$this->expectException(FilesystemException::class);
$this->execute(function () use ($linkResolver) {
$link = $linkResolver();
@ -112,7 +112,7 @@ abstract class DriverTest extends TestCase
$target = "{$fixtureDir}/small.txt";
$link = "{$fixtureDir}/symlink.txt";
$this->assertTrue(yield File\symlink($target, $link));
$this->assertInternalType('array', yield File\lstat($link));
$this->assertIsArray(yield File\lstat($link));
yield File\unlink($link);
});
}
@ -122,7 +122,7 @@ abstract class DriverTest extends TestCase
$this->execute(function () {
$fixtureDir = Fixture::path();
$stat = (yield File\stat("{$fixtureDir}/small.txt"));
$this->assertInternalType("array", $stat);
$this->assertIsArray($stat);
$this->assertStatSame(\stat("{$fixtureDir}/small.txt"), $stat);
});
}
@ -132,7 +132,7 @@ abstract class DriverTest extends TestCase
$this->execute(function () {
$fixtureDir = Fixture::path();
$stat = (yield File\stat("{$fixtureDir}/dir"));
$this->assertInternalType("array", $stat);
$this->assertIsArray($stat);
$this->assertStatSame(\stat("{$fixtureDir}/dir"), $stat);
});
}
@ -175,11 +175,10 @@ abstract class DriverTest extends TestCase
});
}
/**
* @expectedException \Amp\File\FilesystemException
*/
public function testSizeFailsOnNonexistentPath()
{
$this->expectException(FilesystemException::class);
$this->execute(function () {
$fixtureDir = Fixture::path();
$path = "{$fixtureDir}/nonexistent";
@ -187,11 +186,10 @@ abstract class DriverTest extends TestCase
});
}
/**
* @expectedException \Amp\File\FilesystemException
*/
public function testSizeFailsOnDirectoryPath()
{
$this->expectException(FilesystemException::class);
$this->execute(function () {
$fixtureDir = Fixture::path();
$path = "{$fixtureDir}/dir";
@ -320,11 +318,10 @@ abstract class DriverTest extends TestCase
});
}
/**
* @expectedException \Amp\File\FilesystemException
*/
public function testMtimeFailsOnNonexistentPath()
{
$this->expectException(FilesystemException::class);
$this->execute(function () {
$fixtureDir = Fixture::path();
$path = "{$fixtureDir}/nonexistent";
@ -344,11 +341,10 @@ abstract class DriverTest extends TestCase
});
}
/**
* @expectedException \Amp\File\FilesystemException
*/
public function testAtimeFailsOnNonexistentPath()
{
$this->expectException(FilesystemException::class);
$this->execute(function () {
$fixtureDir = Fixture::path();
$path = "{$fixtureDir}/nonexistent";
@ -368,11 +364,10 @@ abstract class DriverTest extends TestCase
});
}
/**
* @expectedException \Amp\File\FilesystemException
*/
public function testCtimeFailsOnNonexistentPath()
{
$this->expectException(FilesystemException::class);
$this->execute(function () {
$fixtureDir = Fixture::path();
$path = "{$fixtureDir}/nonexistent";

View File

@ -170,11 +170,10 @@ abstract class HandleTest extends TestCase
});
}
/**
* @expectedException \Error
*/
public function testSeekThrowsOnInvalidWhence()
{
$this->expectException(\Error::class);
$this->execute(function () {
try {
/** @var \Amp\File\Handle $handle */