Skip to content

Commit 5c7ce60

Browse files
committed
Test for invalid typeMap options
1 parent e4511d9 commit 5c7ce60

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

tests/ClientTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@ public function testConstructorDefaultUri()
1919
$this->assertEquals('mongodb://localhost:27017', (string) $client);
2020
}
2121

22+
/**
23+
* @expectedException MongoDB\Exception\InvalidArgumentException
24+
* @dataProvider provideInvalidConstructorDriverOptions
25+
*/
26+
public function testConstructorDriverOptionTypeChecks(array $driverOptions)
27+
{
28+
new Client($this->getUri(), [], $driverOptions);
29+
}
30+
31+
public function provideInvalidConstructorDriverOptions()
32+
{
33+
$options = [];
34+
35+
foreach ($this->getInvalidArrayValues() as $value) {
36+
$options[][] = ['typeMap' => $value];
37+
}
38+
39+
return $options;
40+
}
41+
2242
public function testToString()
2343
{
2444
$client = new Client($this->getUri());

tests/Collection/CollectionFunctionalTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public function provideInvalidConstructorOptions()
5555
$options[][] = ['readPreference' => $value];
5656
}
5757

58+
foreach ($this->getInvalidArrayValues() as $value) {
59+
$options[][] = ['typeMap' => $value];
60+
}
61+
5862
foreach ($this->getInvalidWriteConcernValues() as $value) {
5963
$options[][] = ['writeConcern' => $value];
6064
}

tests/Database/DatabaseFunctionalTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public function provideInvalidConstructorOptions()
5252
$options[][] = ['readPreference' => $value];
5353
}
5454

55+
foreach ($this->getInvalidArrayValues() as $value) {
56+
$options[][] = ['typeMap' => $value];
57+
}
58+
5559
foreach ($this->getInvalidWriteConcernValues() as $value) {
5660
$options[][] = ['writeConcern' => $value];
5761
}

0 commit comments

Comments
 (0)