1 | <?php |
||
43 | class PDOTest extends PHPUnit_Framework_TestCase |
||
44 | { |
||
45 | /** |
||
46 | * @var PDO |
||
47 | */ |
||
48 | protected $pdo; |
||
49 | |||
50 | /** |
||
51 | * @var PHPUnit_Framework_MockObject_MockObject|ClientInterface |
||
52 | */ |
||
53 | protected $client; |
||
54 | |||
55 | protected function setUp() |
||
67 | |||
68 | /** |
||
69 | * @covers ::__construct |
||
70 | */ |
||
71 | public function testInstantiation() |
||
78 | |||
79 | public function testInstantiationWithDefaultSchema() |
||
86 | |||
87 | /** |
||
88 | * @covers ::__construct |
||
89 | */ |
||
90 | public function testInstantiationWithTraversableOptions() |
||
95 | |||
96 | /** |
||
97 | * @covers ::__construct |
||
98 | */ |
||
99 | public function testInstantiationWithInvalidOptions() |
||
105 | |||
106 | /** |
||
107 | * @covers ::__construct |
||
108 | */ |
||
109 | public function testInstantiationWithHttpAuth() { |
||
110 | $user = 'crate'; |
||
111 | $passwd = 'secret'; |
||
112 | $pdo = new PDO('crate:localhost:44200', $user, $passwd, []); |
||
113 | $this->assertEquals([$user, $passwd], $pdo->getAttribute(PDO::CRATE_ATTR_HTTP_BASIC_AUTH)); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * @covers ::setAttribute |
||
118 | */ |
||
119 | public function testSetAttributeWithHttpBasicAuth() |
||
139 | |||
140 | /** |
||
141 | * @covers ::setAttribute |
||
142 | */ |
||
143 | public function testSetAttributeWithDefaultSchema() |
||
144 | { |
||
145 | $client = $this->getMock(ClientInterface::class); |
||
146 | $pdo = new PDO('crate:localhost:44200/my_schema', null, null, []); |
||
147 | $reflection = new ReflectionClass(PDO::class); |
||
148 | $property = $reflection->getProperty('client'); |
||
149 | $property->setAccessible(true); |
||
150 | $property->setValue($pdo, $client); |
||
151 | $client |
||
152 | ->expects($this->once()) |
||
153 | ->method('setHttpHeader') |
||
154 | ->with('default-schema', 'my_schema'); |
||
155 | |||
156 | $pdo->setAttribute(PDO::CRATE_ATTR_DEFAULT_SCHEMA, 'my_schema'); |
||
157 | $this->assertEquals('my_schema', $pdo->getAttribute(PDO::CRATE_ATTR_DEFAULT_SCHEMA)); |
||
158 | } |
||
159 | |||
160 | /** |
||
161 | * @covers ::getAttribute |
||
162 | */ |
||
163 | public function testGetAttributeWithInvalidAttribute() |
||
168 | |||
169 | /** |
||
170 | * @covers ::setAttribute |
||
171 | */ |
||
172 | public function testSetAttributeWithInvalidAttribute() |
||
177 | |||
178 | /** |
||
179 | * @covers ::getAttribute |
||
180 | * @covers ::setAttribute |
||
181 | */ |
||
182 | public function testGetAndSetDefaultFetchMode() |
||
188 | |||
189 | /** |
||
190 | * @covers ::getAttribute |
||
191 | * @covers ::setAttribute |
||
192 | */ |
||
193 | public function testGetAndSetErrorMode() |
||
199 | |||
200 | /** |
||
201 | * @covers ::getAttribute |
||
202 | */ |
||
203 | public function testGetVersion() |
||
207 | |||
208 | /** |
||
209 | * @covers ::getAttribute |
||
210 | */ |
||
211 | public function testGetDriverName() |
||
215 | |||
216 | public function testGetStatementClass() |
||
220 | |||
221 | /** |
||
222 | * @covers ::getAttribute |
||
223 | */ |
||
224 | public function testPersistent() |
||
228 | |||
229 | /** |
||
230 | * @covers ::getAttribute |
||
231 | */ |
||
232 | public function testPreFetch() |
||
236 | |||
237 | /** |
||
238 | * @covers ::getAttribute |
||
239 | */ |
||
240 | public function testAutoCommit() |
||
244 | |||
245 | /** |
||
246 | * @covers ::getAttribute |
||
247 | * @covers ::setAttribute |
||
248 | */ |
||
249 | public function testGetAndSetTimeout() |
||
264 | |||
265 | /** |
||
266 | * @covers ::quote |
||
267 | */ |
||
268 | public function testQuote() |
||
276 | |||
277 | /** |
||
278 | * @return array |
||
279 | */ |
||
280 | public function quoteExceptionProvider() |
||
288 | |||
289 | /** |
||
290 | * @dataProvider quoteExceptionProvider |
||
291 | * @covers ::quote |
||
292 | * |
||
293 | * @param int $paramType |
||
294 | * @param string $message |
||
295 | */ |
||
296 | public function testQuoteWithExpectedException($paramType, $exception, $message) |
||
301 | |||
302 | /** |
||
303 | * @covers ::prepare |
||
304 | */ |
||
305 | public function testPrepareReturnsAPDOStatement() |
||
310 | |||
311 | /** |
||
312 | * @covers ::getAvailableDrivers |
||
313 | */ |
||
314 | public function testAvailableDriversContainsCrate() |
||
318 | |||
319 | /** |
||
320 | * @covers ::beginTransaction |
||
321 | */ |
||
322 | public function testBeginTransactionThrowsUnsupportedException() |
||
326 | |||
327 | /** |
||
328 | * @covers ::commit |
||
329 | */ |
||
330 | public function testCommitThrowsUnsupportedException() |
||
334 | |||
335 | /** |
||
336 | * @covers ::rollback |
||
337 | */ |
||
338 | public function testRollbackThrowsUnsupportedException() |
||
343 | |||
344 | /** |
||
345 | * @covers ::inTransaction |
||
346 | */ |
||
347 | public function testInTransactionThrowsUnsupportedException() |
||
351 | |||
352 | /** |
||
353 | * @covers ::lastInsertId |
||
354 | */ |
||
355 | public function testLastInsertIdThrowsUnsupportedException() |
||
360 | } |
||
361 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: