77
88abstract class TestCase extends \PHPUnit_Framework_TestCase
99{
10+ public function provideInvalidDocumentValues ()
11+ {
12+ return $ this ->wrapValuesForDataProvider ($ this ->getInvalidDocumentValues ());
13+ }
14+
1015 /**
1116 * Return the test collection name.
1217 *
@@ -29,11 +34,71 @@ protected function getDatabaseName()
2934 return getenv ('MONGODB_DATABASE ' ) ?: 'phplib_test ' ;
3035 }
3136
37+ /**
38+ * Return a list of invalid array values.
39+ *
40+ * @return array
41+ */
42+ protected function getInvalidArrayValues ()
43+ {
44+ return [123 , 3.14 , 'foo ' , true , new stdClass ];
45+ }
46+
47+ /**
48+ * Return a list of invalid boolean values.
49+ *
50+ * @return array
51+ */
52+ protected function getInvalidBooleanValues ()
53+ {
54+ return [123 , 3.14 , 'foo ' , [], new stdClass ];
55+ }
56+
57+ /**
58+ * Return a list of invalid document values.
59+ *
60+ * @return array
61+ */
62+ protected function getInvalidDocumentValues ()
63+ {
64+ return [123 , 3.14 , 'foo ' , true ];
65+ }
66+
67+ /**
68+ * Return a list of invalid integer values.
69+ *
70+ * @return array
71+ */
72+ protected function getInvalidIntegerValues ()
73+ {
74+ return [3.14 , 'foo ' , true , [], new stdClass ];
75+ }
76+
77+ /**
78+ * Return a list of invalid ReadPreference values.
79+ *
80+ * @return array
81+ */
3282 protected function getInvalidReadPreferenceValues ()
3383 {
3484 return [123 , 3.14 , 'foo ' , true , [], new stdClass ];
3585 }
3686
87+ /**
88+ * Return a list of invalid string values.
89+ *
90+ * @return array
91+ */
92+ protected function getInvalidStringValues ()
93+ {
94+ return [123 , 3.14 , true , [], new stdClass ];
95+ }
96+
97+ /**
98+ * Return a list of invalid WriteConcern values.
99+ *
100+ * @return array
101+ */
37102 protected function getInvalidWriteConcernValues ()
38103 {
39104 return [123 , 3.14 , 'foo ' , true , [], new stdClass ];
@@ -58,4 +123,15 @@ protected function getUri()
58123 {
59124 return getenv ('MONGODB_URI ' ) ?: 'mongodb://127.0.0.1:27017 ' ;
60125 }
126+
127+ /**
128+ * Wrap a list of values for use as a single-argument data provider.
129+ *
130+ * @param array $values List of values
131+ * @return array
132+ */
133+ protected function wrapValuesForDataProvider (array $ values )
134+ {
135+ return array_map (function ($ value ) { return [$ value ]; }, $ values );
136+ }
61137}
0 commit comments