Skip to content

Commit 71f8ae6

Browse files
committed
PHPLIB-294: Make test suite compatible with PHPUnit 6.4
1 parent 5772c11 commit 71f8ae6

8 files changed

+35
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"ext-mongodb": "^1.4.0"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^4.8.36"
19+
"phpunit/phpunit": "^6.4"
2020
},
2121
"autoload": {
2222
"psr-4": { "MongoDB\\": "src/" },

tests/GridFS/BucketFunctionalTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ class BucketFunctionalTest extends FunctionalTestCase
1919
{
2020
public function testValidConstructorOptions()
2121
{
22-
new Bucket($this->manager, $this->getDatabaseName(), [
22+
$bucket = new Bucket($this->manager, $this->getDatabaseName(), [
2323
'bucketName' => 'test',
2424
'chunkSizeBytes' => 8192,
2525
'readConcern' => new ReadConcern(ReadConcern::LOCAL),
2626
'readPreference' => new ReadPreference(ReadPreference::RP_PRIMARY),
2727
'writeConcern' => new WriteConcern(WriteConcern::MAJORITY, 1000),
2828
]);
29+
$this->assertSame('test', $bucket->getBucketName());
2930
}
3031

3132
/**

tests/GridFS/ReadableStreamFunctionalTest.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ public function setUp()
4040

4141
public function testValidConstructorFileDocument()
4242
{
43-
new ReadableStream($this->collectionWrapper, (object) ['_id' => null, 'chunkSize' => 1, 'length' => 0]);
43+
$fileDocument = (object) ['_id' => null, 'chunkSize' => 1, 'length' => 0];
44+
$stream = new ReadableStream($this->collectionWrapper, $fileDocument);
45+
$this->assertSame($fileDocument, $stream->getFile());
4446
}
4547

4648
/**
@@ -108,14 +110,34 @@ public function provideFileIdAndExpectedBytes()
108110
];
109111
}
110112

113+
public function provideFilteredFileIdAndExpectedBytes()
114+
{
115+
return [
116+
['length-0', 2, ''],
117+
['length-0-with-empty-chunk', 2, ''],
118+
['length-2', 2, 'ab'],
119+
['length-2', 4, 'ab'],
120+
['length-8', 2, 'ab'],
121+
['length-8', 4, 'abcd'],
122+
['length-8', 6, 'abcdef'],
123+
['length-8', 8, 'abcdefgh'],
124+
['length-8', 10, 'abcdefgh'],
125+
['length-10', 2, 'ab'],
126+
['length-10', 4, 'abcd'],
127+
['length-10', 6, 'abcdef'],
128+
['length-10', 8, 'abcdefgh'],
129+
['length-10', 10, 'abcdefghij'],
130+
['length-10', 12, 'abcdefghij'],
131+
];
132+
}
133+
111134
/**
112-
* @dataProvider provideFileIdAndExpectedBytes
135+
* @dataProvider provideFilteredFileIdAndExpectedBytes
113136
*/
114137
public function testReadBytesCalledMultipleTimes($fileId, $length, $expectedBytes)
115138
{
116139
$fileDocument = $this->collectionWrapper->findFileById($fileId);
117140
$stream = new ReadableStream($this->collectionWrapper, $fileDocument);
118-
119141
for ($i = 0; $i < $length; $i++) {
120142
$expectedByte = isset($expectedBytes[$i]) ? $expectedBytes[$i] : '';
121143
$this->assertSame($expectedByte, $stream->readBytes(1));

tests/GridFS/WritableStreamFunctionalTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ public function setUp()
2121

2222
public function testValidConstructorOptions()
2323
{
24-
new WritableStream($this->collectionWrapper, 'filename', [
24+
$stream = new WritableStream($this->collectionWrapper, 'filename', [
2525
'_id' => 'custom-id',
2626
'chunkSizeBytes' => 2,
2727
'metadata' => ['foo' => 'bar'],
2828
]);
29+
$this->assertSame(0, $stream->getSize());
2930
}
3031

3132
/**

tests/Operation/ReplaceOneTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function testConstructorReplacementArgumentTypeCheck($replacement)
2727

2828
/**
2929
* @dataProvider provideReplacementDocuments
30+
* @doesNotPerformAssertions
3031
*/
3132
public function testConstructorReplacementArgument($replacement)
3233
{

tests/Operation/UpdateManyTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function testConstructorUpdateArgumentTypeCheck($update)
2727

2828
/**
2929
* @dataProvider provideUpdateDocuments
30+
* @doesNotPerformAssertions
3031
*/
3132
public function testConstructorUpdateArgument($update)
3233
{

tests/Operation/UpdateOneTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function testConstructorUpdateArgumentTypeCheck($update)
2727

2828
/**
2929
* @dataProvider provideUpdateDocuments
30+
* @doesNotPerformAssertions
3031
*/
3132
public function testConstructorUpdateArgument($update)
3233
{

tests/bootstrap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
} else {
1010
throw new Exception('Can\'t find autoload.php. Did you install dependencies with Composer?');
1111
}
12+
13+
class_alias("PHPUnit\Framework\Error\Warning", "PHPUnit_Framework_Error_Warning");

0 commit comments

Comments
 (0)