Commit a8b48629 authored by Katherine Walker's avatar Katherine Walker

PHPLIB-294: Make test suite compatible with PHPUnit 6.4

parent 3f82285e
......@@ -16,7 +16,7 @@
"ext-mongodb": "^1.4.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36"
"phpunit/phpunit": "^4.8.36 || ^6.4"
},
"autoload": {
"psr-4": { "MongoDB\\": "src/" },
......
......@@ -17,6 +17,9 @@ use MongoDB\Operation\ListIndexes;
*/
class BucketFunctionalTest extends FunctionalTestCase
{
/**
* @doesNotPerformAssertions
*/
public function testValidConstructorOptions()
{
new Bucket($this->manager, $this->getDatabaseName(), [
......@@ -138,7 +141,7 @@ class BucketFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedException PHPUnit\Framework\Error\Warning
*/
public function testDownloadingFileWithMissingChunk()
{
......@@ -150,7 +153,7 @@ class BucketFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedException PHPUnit\Framework\Error\Warning
*/
public function testDownloadingFileWithUnexpectedChunkIndex()
{
......@@ -165,7 +168,7 @@ class BucketFunctionalTest extends FunctionalTestCase
}
/**
* @expectedException PHPUnit_Framework_Error_Warning
* @expectedException PHPUnit\Framework\Error\Warning
*/
public function testDownloadingFileWithUnexpectedChunkSize()
{
......
......@@ -38,9 +38,11 @@ class ReadableStreamFunctionalTest extends FunctionalTestCase
]);
}
public function testValidConstructorFileDocument()
public function testGetFile()
{
new ReadableStream($this->collectionWrapper, (object) ['_id' => null, 'chunkSize' => 1, 'length' => 0]);
$fileDocument = (object) ['_id' => null, 'chunkSize' => 1, 'length' => 0];
$stream = new ReadableStream($this->collectionWrapper, $fileDocument);
$this->assertSame($fileDocument, $stream->getFile());
}
/**
......@@ -108,14 +110,22 @@ class ReadableStreamFunctionalTest extends FunctionalTestCase
];
}
public function provideFilteredFileIdAndExpectedBytes()
{
return array_filter($this->provideFileIdAndExpectedBytes(),
function(array $args) {
return $args[1] > 0;
}
);
}
/**
* @dataProvider provideFileIdAndExpectedBytes
* @dataProvider provideFilteredFileIdAndExpectedBytes
*/
public function testReadBytesCalledMultipleTimes($fileId, $length, $expectedBytes)
{
$fileDocument = $this->collectionWrapper->findFileById($fileId);
$stream = new ReadableStream($this->collectionWrapper, $fileDocument);
for ($i = 0; $i < $length; $i++) {
$expectedByte = isset($expectedBytes[$i]) ? $expectedBytes[$i] : '';
$this->assertSame($expectedByte, $stream->readBytes(1));
......
......@@ -330,7 +330,7 @@ class SpecFunctionalTest extends FunctionalTestCase
/* Although ReadableStream throws a CorruptFileException, the
* stream wrapper will convert it to a PHP error of type
* E_USER_WARNING. */
return 'PHPUnit_Framework_Error_Warning';
return 'PHPUnit\Framework\Error\Warning';
default:
throw new LogicException('Unsupported error: ' . $error);
......
......@@ -19,6 +19,9 @@ class WritableStreamFunctionalTest extends FunctionalTestCase
$this->collectionWrapper = new CollectionWrapper($this->manager, $this->getDatabaseName(), 'fs');
}
/**
* @doesNotPerformAssertions
*/
public function testValidConstructorOptions()
{
new WritableStream($this->collectionWrapper, 'filename', [
......
......@@ -27,6 +27,7 @@ class ReplaceOneTest extends TestCase
/**
* @dataProvider provideReplacementDocuments
* @doesNotPerformAssertions
*/
public function testConstructorReplacementArgument($replacement)
{
......
......@@ -27,6 +27,7 @@ class UpdateManyTest extends TestCase
/**
* @dataProvider provideUpdateDocuments
* @doesNotPerformAssertions
*/
public function testConstructorUpdateArgument($update)
{
......
......@@ -27,6 +27,7 @@ class UpdateOneTest extends TestCase
/**
* @dataProvider provideUpdateDocuments
* @doesNotPerformAssertions
*/
public function testConstructorUpdateArgument($update)
{
......
......@@ -9,3 +9,7 @@ if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
} else {
throw new Exception('Can\'t find autoload.php. Did you install dependencies with Composer?');
}
if ( ! class_exists('PHPUnit\Framework\Error\Warning')) {
class_alias('PHPUnit_Framework_Error_Warning', 'PHPUnit\Framework\Error\Warning');
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment