Skip to content

Commit a44c71f

Browse files
committed
Restore PackedArray as invalid document in tests
1 parent 1b70949 commit a44c71f

19 files changed

+45
-25
lines changed

tests/Database/DatabaseFunctionalTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace MongoDB\Tests\Database;
44

5+
use MongoDB\BSON\PackedArray;
56
use MongoDB\Collection;
67
use MongoDB\Database;
78
use MongoDB\Driver\BulkWrite;
@@ -124,7 +125,7 @@ public function testCommandAppliesTypeMapToCursor(): void
124125
/** @dataProvider provideInvalidDocumentValues */
125126
public function testCommandCommandArgumentTypeCheck($command): void
126127
{
127-
$this->expectException(TypeError::class);
128+
$this->expectException($command instanceof PackedArray ? InvalidArgumentException::class : TypeError::class);
128129
$this->database->command($command);
129130
}
130131

tests/Model/ChangeStreamIteratorTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
namespace MongoDB\Tests\Model;
99

10+
use MongoDB\BSON\PackedArray;
1011
use MongoDB\Collection;
1112
use MongoDB\Driver\Exception\LogicException;
13+
use MongoDB\Exception\InvalidArgumentException;
1214
use MongoDB\Model\ChangeStreamIterator;
1315
use MongoDB\Operation\Find;
1416
use MongoDB\Tests\CommandObserver;
@@ -51,7 +53,7 @@ public function testInitialResumeToken(): void
5153
/** @dataProvider provideInvalidDocumentValues */
5254
public function testInitialResumeTokenArgumentTypeCheck($initialResumeToken): void
5355
{
54-
$this->expectException(TypeError::class);
56+
$this->expectException($initialResumeToken instanceof PackedArray ? InvalidArgumentException::class : TypeError::class);
5557
new ChangeStreamIterator($this->collection->find(), 0, $initialResumeToken, null);
5658
}
5759

tests/Operation/BulkWriteTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace MongoDB\Tests\Operation;
44

5+
use MongoDB\BSON\PackedArray;
56
use MongoDB\Exception\InvalidArgumentException;
67
use MongoDB\Exception\UnsupportedValueException;
78
use MongoDB\Operation\BulkWrite;
@@ -288,7 +289,7 @@ public function testUpdateManyUpdateArgumentMissing(): void
288289
/** @dataProvider provideInvalidDocumentValues */
289290
public function testUpdateManyUpdateArgumentTypeCheck($update): void
290291
{
291-
$this->expectException(TypeError::class);
292+
$this->expectException($update instanceof PackedArray ? InvalidArgumentException::class : TypeError::class);
292293
new BulkWrite($this->getDatabaseName(), $this->getCollectionName(), [
293294
[BulkWrite::UPDATE_MANY => [['x' => 1], $update]],
294295
]);
@@ -380,7 +381,7 @@ public function testUpdateOneUpdateArgumentMissing(): void
380381
/** @dataProvider provideInvalidDocumentValues */
381382
public function testUpdateOneUpdateArgumentTypeCheck($update): void
382383
{
383-
$this->expectException(TypeError::class);
384+
$this->expectException($update instanceof PackedArray ? InvalidArgumentException::class : TypeError::class);
384385
new BulkWrite($this->getDatabaseName(), $this->getCollectionName(), [
385386
[BulkWrite::UPDATE_ONE => [['x' => 1], $update]],
386387
]);

tests/Operation/CountDocumentsTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace MongoDB\Tests\Operation;
44

5+
use MongoDB\BSON\PackedArray;
56
use MongoDB\Exception\InvalidArgumentException;
67
use MongoDB\Operation\CountDocuments;
78
use TypeError;
@@ -11,7 +12,7 @@ class CountDocumentsTest extends TestCase
1112
/** @dataProvider provideInvalidDocumentValues */
1213
public function testConstructorFilterArgumentTypeCheck($filter): void
1314
{
14-
$this->expectException(TypeError::class);
15+
$this->expectException($filter instanceof PackedArray ? InvalidArgumentException::class : TypeError::class);
1516
new CountDocuments($this->getDatabaseName(), $this->getCollectionName(), $filter);
1617
}
1718

tests/Operation/CountTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace MongoDB\Tests\Operation;
44

5+
use MongoDB\BSON\PackedArray;
56
use MongoDB\Driver\ReadConcern;
67
use MongoDB\Exception\InvalidArgumentException;
78
use MongoDB\Operation\Count;
@@ -12,7 +13,7 @@ class CountTest extends TestCase
1213
/** @dataProvider provideInvalidDocumentValues */
1314
public function testConstructorFilterArgumentTypeCheck($filter): void
1415
{
15-
$this->expectException(TypeError::class);
16+
$this->expectException($filter instanceof PackedArray ? InvalidArgumentException::class : TypeError::class);
1617
new Count($this->getDatabaseName(), $this->getCollectionName(), $filter);
1718
}
1819

tests/Operation/DatabaseCommandTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace MongoDB\Tests\Operation;
44

5+
use MongoDB\BSON\PackedArray;
56
use MongoDB\Exception\InvalidArgumentException;
67
use MongoDB\Operation\DatabaseCommand;
78
use TypeError;
@@ -11,7 +12,7 @@ class DatabaseCommandTest extends TestCase
1112
/** @dataProvider provideInvalidDocumentValues */
1213
public function testConstructorCommandArgumentTypeCheck($command): void
1314
{
14-
$this->expectException(TypeError::class);
15+
$this->expectException($command instanceof PackedArray ? InvalidArgumentException::class : TypeError::class);
1516
new DatabaseCommand($this->getDatabaseName(), $command);
1617
}
1718

tests/Operation/DeleteTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace MongoDB\Tests\Operation;
99

10+
use MongoDB\BSON\PackedArray;
1011
use MongoDB\Driver\WriteConcern;
1112
use MongoDB\Exception\InvalidArgumentException;
1213
use MongoDB\Operation\Delete;
@@ -17,7 +18,7 @@ class DeleteTest extends TestCase
1718
/** @dataProvider provideInvalidDocumentValues */
1819
public function testConstructorFilterArgumentTypeCheck($filter): void
1920
{
20-
$this->expectException(TypeError::class);
21+
$this->expectException($filter instanceof PackedArray ? InvalidArgumentException::class : TypeError::class);
2122
new Delete($this->getDatabaseName(), $this->getCollectionName(), $filter, 0);
2223
}
2324

tests/Operation/DistinctTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace MongoDB\Tests\Operation;
44

5+
use MongoDB\BSON\PackedArray;
56
use MongoDB\Driver\ReadConcern;
67
use MongoDB\Driver\ReadPreference;
78
use MongoDB\Exception\InvalidArgumentException;
@@ -13,7 +14,7 @@ class DistinctTest extends TestCase
1314
/** @dataProvider provideInvalidDocumentValues */
1415
public function testConstructorFilterArgumentTypeCheck($filter): void
1516
{
16-
$this->expectException(TypeError::class);
17+
$this->expectException($filter instanceof PackedArray ? InvalidArgumentException::class : TypeError::class);
1718
new Distinct($this->getDatabaseName(), $this->getCollectionName(), 'x', $filter);
1819
}
1920

tests/Operation/FindOneAndDeleteTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace MongoDB\Tests\Operation;
44

5+
use MongoDB\BSON\PackedArray;
56
use MongoDB\Driver\WriteConcern;
67
use MongoDB\Exception\InvalidArgumentException;
78
use MongoDB\Operation\FindOneAndDelete;
@@ -12,7 +13,7 @@ class FindOneAndDeleteTest extends TestCase
1213
/** @dataProvider provideInvalidDocumentValues */
1314
public function testConstructorFilterArgumentTypeCheck($filter): void
1415
{
15-
$this->expectException(TypeError::class);
16+
$this->expectException($filter instanceof PackedArray ? InvalidArgumentException::class : TypeError::class);
1617
new FindOneAndDelete($this->getDatabaseName(), $this->getCollectionName(), $filter);
1718
}
1819

tests/Operation/FindOneAndReplaceTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace MongoDB\Tests\Operation;
44

5+
use MongoDB\BSON\PackedArray;
56
use MongoDB\Driver\WriteConcern;
67
use MongoDB\Exception\InvalidArgumentException;
78
use MongoDB\Operation\FindOneAndReplace;
@@ -12,14 +13,14 @@ class FindOneAndReplaceTest extends TestCase
1213
/** @dataProvider provideInvalidDocumentValues */
1314
public function testConstructorFilterArgumentTypeCheck($filter): void
1415
{
15-
$this->expectException(TypeError::class);
16+
$this->expectException($filter instanceof PackedArray ? InvalidArgumentException::class : TypeError::class);
1617
new FindOneAndReplace($this->getDatabaseName(), $this->getCollectionName(), $filter, []);
1718
}
1819

1920
/** @dataProvider provideInvalidDocumentValues */
2021
public function testConstructorReplacementArgumentTypeCheck($replacement): void
2122
{
22-
$this->expectException(TypeError::class);
23+
$this->expectException($replacement instanceof PackedArray ? InvalidArgumentException::class : TypeError::class);
2324
new FindOneAndReplace($this->getDatabaseName(), $this->getCollectionName(), [], $replacement);
2425
}
2526

0 commit comments

Comments
 (0)