Skip to content

Commit 1f32e97

Browse files
committed
Unit tests for Find operation
1 parent a197569 commit 1f32e97

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

tests/Operation/FindTest.php

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
3+
namespace MongoDB\Tests\Operation;
4+
5+
use MongoDB\Operation\Find;
6+
use stdClass;
7+
8+
class FindTest extends TestCase
9+
{
10+
/**
11+
* @expectedException MongoDB\Exception\InvalidArgumentTypeException
12+
* @dataProvider provideInvalidDocumentValues
13+
*/
14+
public function testConstructorFilterArgumentTypeCheck($filter)
15+
{
16+
new Find($this->getDatabaseName(), $this->getCollectionName(), $filter);
17+
}
18+
19+
/**
20+
* @expectedException MongoDB\Exception\InvalidArgumentTypeException
21+
* @dataProvider provideInvalidConstructorOptions
22+
*/
23+
public function testConstructorOptionTypeChecks(array $options)
24+
{
25+
new Find($this->getDatabaseName(), $this->getCollectionName(), array(), $options);
26+
}
27+
28+
public function provideInvalidConstructorOptions()
29+
{
30+
$options = array();
31+
32+
foreach ($this->getInvalidBooleanValues() as $value) {
33+
$options[][] = array('allowPartialResults' => $value);
34+
}
35+
36+
foreach ($this->getInvalidIntegerValues() as $value) {
37+
$options[][] = array('batchSize' => $value);
38+
}
39+
40+
foreach ($this->getInvalidStringValues() as $value) {
41+
$options[][] = array('comment' => $value);
42+
}
43+
44+
foreach ($this->getInvalidIntegerValues() as $value) {
45+
$options[][] = array('cursorType' => $value);
46+
}
47+
48+
foreach ($this->getInvalidIntegerValues() as $value) {
49+
$options[][] = array('limit' => $value);
50+
}
51+
52+
foreach ($this->getInvalidIntegerValues() as $value) {
53+
$options[][] = array('maxTimeMS' => $value);
54+
}
55+
56+
foreach ($this->getInvalidDocumentValues() as $value) {
57+
$options[][] = array('modifiers' => $value);
58+
}
59+
60+
foreach ($this->getInvalidBooleanValues() as $value) {
61+
$options[][] = array('oplogReplay' => $value);
62+
}
63+
64+
foreach ($this->getInvalidDocumentValues() as $value) {
65+
$options[][] = array('projection' => $value);
66+
}
67+
68+
foreach ($this->getInvalidIntegerValues() as $value) {
69+
$options[][] = array('skip' => $value);
70+
}
71+
72+
foreach ($this->getInvalidDocumentValues() as $value) {
73+
$options[][] = array('sort' => $value);
74+
}
75+
76+
return $options;
77+
}
78+
79+
/**
80+
* @expectedException MongoDB\Exception\InvalidArgumentException
81+
* @dataProvider provideInvalidConstructorCursorTypeOptions
82+
*/
83+
public function testConstructorCursorTypeOption($cursorType)
84+
{
85+
new Find($this->getDatabaseName(), $this->getCollectionName(), array(), array('cursorType' => $cursorType));
86+
}
87+
88+
public function provideInvalidConstructorCursorTypeOptions()
89+
{
90+
return $this->wrapValuesForDataProvider(array(-1, 0, 4));
91+
}
92+
}

0 commit comments

Comments
 (0)