| Total Complexity | 45 |
| Total Lines | 869 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like ConnectionTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ConnectionTest, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 34 | class ConnectionTest extends TestCase |
||
| 35 | { |
||
| 36 | /** @var Connection */ |
||
| 37 | private $connection; |
||
| 38 | |||
| 39 | /** @var string[] */ |
||
| 40 | protected $params = [ |
||
| 41 | 'driver' => 'pdo_mysql', |
||
| 42 | 'host' => 'localhost', |
||
| 43 | 'user' => 'root', |
||
| 44 | 'password' => 'password', |
||
| 45 | 'port' => '1234', |
||
| 46 | ]; |
||
| 47 | |||
| 48 | protected function setUp() : void |
||
| 49 | { |
||
| 50 | $this->connection = DriverManager::getConnection($this->params); |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @return Connection|MockObject |
||
| 55 | */ |
||
| 56 | private function getExecuteUpdateMockConnection() |
||
| 57 | { |
||
| 58 | $driverMock = $this->createMock(Driver::class); |
||
| 59 | |||
| 60 | $driverMock->expects($this->any()) |
||
| 61 | ->method('connect') |
||
| 62 | ->will($this->returnValue( |
||
| 63 | $this->createMock(DriverConnection::class) |
||
| 64 | )); |
||
| 65 | |||
| 66 | $platform = $this->getMockForAbstractClass(AbstractPlatform::class); |
||
| 67 | |||
| 68 | return $this->getMockBuilder(Connection::class) |
||
| 69 | ->onlyMethods(['executeUpdate']) |
||
| 70 | ->setConstructorArgs([['platform' => $platform], $driverMock]) |
||
| 71 | ->getMock(); |
||
| 72 | } |
||
| 73 | |||
| 74 | public function testIsConnected() : void |
||
| 75 | { |
||
| 76 | self::assertFalse($this->connection->isConnected()); |
||
| 77 | } |
||
| 78 | |||
| 79 | public function testNoTransactionActiveByDefault() : void |
||
| 80 | { |
||
| 81 | self::assertFalse($this->connection->isTransactionActive()); |
||
| 82 | } |
||
| 83 | |||
| 84 | public function testCommitWithNoActiveTransactionThrowsException() : void |
||
| 85 | { |
||
| 86 | $this->expectException(ConnectionException::class); |
||
| 87 | $this->connection->commit(); |
||
| 88 | } |
||
| 89 | |||
| 90 | public function testRollbackWithNoActiveTransactionThrowsException() : void |
||
| 91 | { |
||
| 92 | $this->expectException(ConnectionException::class); |
||
| 93 | $this->connection->rollBack(); |
||
| 94 | } |
||
| 95 | |||
| 96 | public function testSetRollbackOnlyNoActiveTransactionThrowsException() : void |
||
| 97 | { |
||
| 98 | $this->expectException(ConnectionException::class); |
||
| 99 | $this->connection->setRollbackOnly(); |
||
| 100 | } |
||
| 101 | |||
| 102 | public function testIsRollbackOnlyNoActiveTransactionThrowsException() : void |
||
| 103 | { |
||
| 104 | $this->expectException(ConnectionException::class); |
||
| 105 | $this->connection->isRollbackOnly(); |
||
| 106 | } |
||
| 107 | |||
| 108 | public function testGetConfiguration() : void |
||
| 109 | { |
||
| 110 | $config = $this->connection->getConfiguration(); |
||
| 111 | |||
| 112 | self::assertInstanceOf(Configuration::class, $config); |
||
| 113 | } |
||
| 114 | |||
| 115 | public function testGetHost() : void |
||
| 116 | { |
||
| 117 | self::assertEquals('localhost', $this->connection->getHost()); |
||
| 118 | } |
||
| 119 | |||
| 120 | public function testGetPort() : void |
||
| 123 | } |
||
| 124 | |||
| 125 | public function testGetUsername() : void |
||
| 128 | } |
||
| 129 | |||
| 130 | public function testGetPassword() : void |
||
| 131 | { |
||
| 132 | self::assertEquals('password', $this->connection->getPassword()); |
||
| 133 | } |
||
| 134 | |||
| 135 | public function testGetDriver() : void |
||
| 136 | { |
||
| 137 | self::assertInstanceOf(\Doctrine\DBAL\Driver\PDOMySql\Driver::class, $this->connection->getDriver()); |
||
| 138 | } |
||
| 139 | |||
| 140 | public function testGetEventManager() : void |
||
| 141 | { |
||
| 142 | self::assertInstanceOf(EventManager::class, $this->connection->getEventManager()); |
||
| 143 | } |
||
| 144 | |||
| 145 | public function testConnectDispatchEvent() : void |
||
| 146 | { |
||
| 147 | $listenerMock = $this->getMockBuilder($this->getMockClass('ConnectDispatchEventListener')) |
||
| 148 | ->addMethods(['postConnect']) |
||
| 149 | ->getMock(); |
||
| 150 | $listenerMock->expects($this->once())->method('postConnect'); |
||
| 151 | |||
| 152 | $eventManager = new EventManager(); |
||
| 153 | $eventManager->addEventListener([Events::postConnect], $listenerMock); |
||
| 154 | |||
| 155 | $driverMock = $this->createMock(Driver::class); |
||
| 156 | $driverMock->expects($this->at(0)) |
||
| 157 | ->method('connect'); |
||
| 158 | |||
| 159 | $conn = new Connection([], $driverMock, new Configuration(), $eventManager); |
||
| 160 | $conn->connect(); |
||
| 161 | } |
||
| 162 | |||
| 163 | public function testEventManagerPassedToPlatform() : void |
||
| 181 | } |
||
| 182 | |||
| 183 | /** |
||
| 184 | * @requires extension pdo_sqlite |
||
| 185 | * @dataProvider getQueryMethods |
||
| 186 | */ |
||
| 187 | public function testDriverExceptionIsWrapped(string $method) : void |
||
| 188 | { |
||
| 189 | $this->expectException(DBALException::class); |
||
| 190 | $this->expectExceptionMessage("An exception occurred while executing 'MUUHAAAAHAAAA':\n\nSQLSTATE[HY000]: General error: 1 near \"MUUHAAAAHAAAA\""); |
||
| 191 | |||
| 192 | $connection = DriverManager::getConnection([ |
||
| 193 | 'driver' => 'pdo_sqlite', |
||
| 194 | 'memory' => true, |
||
| 195 | ]); |
||
| 196 | |||
| 197 | $connection->$method('MUUHAAAAHAAAA'); |
||
| 198 | } |
||
| 199 | |||
| 200 | /** |
||
| 201 | * @return array<int, array<int, mixed>> |
||
| 202 | */ |
||
| 203 | public static function getQueryMethods() : iterable |
||
| 211 | ]; |
||
| 212 | } |
||
| 213 | |||
| 214 | /** |
||
| 215 | * Pretty dumb test, however we want to check that the DebugStack correctly implements the interface. |
||
| 216 | * |
||
| 217 | * @group DBAL-11 |
||
| 218 | */ |
||
| 219 | public function testDebugSQLStack() : void |
||
| 220 | { |
||
| 221 | $logger = new DebugStack(); |
||
| 222 | $this->connection->getConfiguration()->setSQLLogger($logger); |
||
| 223 | self::assertSame($logger, $this->connection->getConfiguration()->getSQLLogger()); |
||
| 224 | } |
||
| 225 | |||
| 226 | /** |
||
| 227 | * @group DBAL-81 |
||
| 228 | */ |
||
| 229 | public function testIsAutoCommit() : void |
||
| 230 | { |
||
| 231 | self::assertTrue($this->connection->isAutoCommit()); |
||
| 232 | } |
||
| 233 | |||
| 234 | /** |
||
| 235 | * @group DBAL-81 |
||
| 236 | */ |
||
| 237 | public function testSetAutoCommit() : void |
||
| 238 | { |
||
| 239 | $this->connection->setAutoCommit(false); |
||
| 240 | self::assertFalse($this->connection->isAutoCommit()); |
||
| 241 | $this->connection->setAutoCommit(0); |
||
| 242 | self::assertFalse($this->connection->isAutoCommit()); |
||
| 243 | } |
||
| 244 | |||
| 245 | /** |
||
| 246 | * @group DBAL-81 |
||
| 247 | */ |
||
| 248 | public function testConnectStartsTransactionInNoAutoCommitMode() : void |
||
| 249 | { |
||
| 250 | $driverMock = $this->createMock(Driver::class); |
||
| 251 | $driverMock->expects($this->any()) |
||
| 252 | ->method('connect') |
||
| 253 | ->will($this->returnValue( |
||
| 254 | $this->createMock(DriverConnection::class) |
||
| 255 | )); |
||
| 256 | $conn = new Connection([], $driverMock); |
||
| 257 | |||
| 258 | $conn->setAutoCommit(false); |
||
| 259 | |||
| 260 | self::assertFalse($conn->isTransactionActive()); |
||
| 261 | |||
| 262 | $conn->connect(); |
||
| 263 | |||
| 264 | self::assertTrue($conn->isTransactionActive()); |
||
| 265 | } |
||
| 266 | |||
| 267 | /** |
||
| 268 | * @group DBAL-81 |
||
| 269 | */ |
||
| 270 | public function testCommitStartsTransactionInNoAutoCommitMode() : void |
||
| 271 | { |
||
| 272 | $driverMock = $this->createMock(Driver::class); |
||
| 273 | $driverMock->expects($this->any()) |
||
| 274 | ->method('connect') |
||
| 275 | ->will($this->returnValue( |
||
| 276 | $this->createMock(DriverConnection::class) |
||
| 277 | )); |
||
| 278 | $conn = new Connection([], $driverMock); |
||
| 279 | |||
| 280 | $conn->setAutoCommit(false); |
||
| 281 | $conn->connect(); |
||
| 282 | $conn->commit(); |
||
| 283 | |||
| 284 | self::assertTrue($conn->isTransactionActive()); |
||
| 285 | } |
||
| 286 | |||
| 287 | /** |
||
| 288 | * @dataProvider resultProvider |
||
| 289 | */ |
||
| 290 | public function testCommitReturn(bool $expectedResult) : void |
||
| 291 | { |
||
| 292 | $driverConnection = $this->createMock(DriverConnection::class); |
||
| 293 | $driverConnection->expects($this->once()) |
||
| 294 | ->method('commit')->willReturn($expectedResult); |
||
| 295 | |||
| 296 | $driverMock = $this->createMock(Driver::class); |
||
| 297 | $driverMock->expects($this->any()) |
||
| 298 | ->method('connect') |
||
| 299 | ->will($this->returnValue($driverConnection)); |
||
| 300 | |||
| 301 | $conn = new Connection([], $driverMock); |
||
| 302 | |||
| 303 | $conn->connect(); |
||
| 304 | $conn->beginTransaction(); |
||
| 305 | |||
| 306 | self::assertSame($expectedResult, $conn->commit()); |
||
| 307 | } |
||
| 308 | |||
| 309 | /** |
||
| 310 | * @return bool[][] |
||
| 311 | */ |
||
| 312 | public function resultProvider() : array |
||
| 313 | { |
||
| 314 | return [[true], [false]]; |
||
| 315 | } |
||
| 316 | |||
| 317 | /** |
||
| 318 | * @group DBAL-81 |
||
| 319 | */ |
||
| 320 | public function testRollBackStartsTransactionInNoAutoCommitMode() : void |
||
| 321 | { |
||
| 322 | $driverMock = $this->createMock(Driver::class); |
||
| 323 | $driverMock->expects($this->any()) |
||
| 324 | ->method('connect') |
||
| 325 | ->will($this->returnValue( |
||
| 326 | $this->createMock(DriverConnection::class) |
||
| 327 | )); |
||
| 328 | $conn = new Connection([], $driverMock); |
||
| 329 | |||
| 330 | $conn->setAutoCommit(false); |
||
| 331 | $conn->connect(); |
||
| 332 | $conn->rollBack(); |
||
| 333 | |||
| 334 | self::assertTrue($conn->isTransactionActive()); |
||
| 335 | } |
||
| 336 | |||
| 337 | /** |
||
| 338 | * @group DBAL-81 |
||
| 339 | */ |
||
| 340 | public function testSwitchingAutoCommitModeCommitsAllCurrentTransactions() : void |
||
| 341 | { |
||
| 342 | $driverMock = $this->createMock(Driver::class); |
||
| 343 | $driverMock->expects($this->any()) |
||
| 344 | ->method('connect') |
||
| 345 | ->will($this->returnValue( |
||
| 346 | $this->createMock(DriverConnection::class) |
||
| 347 | )); |
||
| 348 | $conn = new Connection([], $driverMock); |
||
| 349 | |||
| 350 | $conn->connect(); |
||
| 351 | $conn->beginTransaction(); |
||
| 352 | $conn->beginTransaction(); |
||
| 353 | $conn->setAutoCommit(false); |
||
| 354 | |||
| 355 | self::assertSame(1, $conn->getTransactionNestingLevel()); |
||
| 356 | |||
| 357 | $conn->beginTransaction(); |
||
| 358 | $conn->beginTransaction(); |
||
| 359 | $conn->setAutoCommit(true); |
||
| 360 | |||
| 361 | self::assertFalse($conn->isTransactionActive()); |
||
| 362 | } |
||
| 363 | |||
| 364 | public function testEmptyInsert() : void |
||
| 365 | { |
||
| 366 | $conn = $this->getExecuteUpdateMockConnection(); |
||
| 367 | |||
| 368 | $conn->expects($this->once()) |
||
| 369 | ->method('executeUpdate') |
||
| 370 | ->with('INSERT INTO footable () VALUES ()'); |
||
| 371 | |||
| 372 | $conn->insert('footable', []); |
||
| 373 | } |
||
| 374 | |||
| 375 | /** |
||
| 376 | * @group DBAL-2511 |
||
| 377 | */ |
||
| 378 | public function testUpdateWithDifferentColumnsInDataAndIdentifiers() : void |
||
| 415 | ] |
||
| 416 | ); |
||
| 417 | } |
||
| 418 | |||
| 419 | /** |
||
| 420 | * @group DBAL-2511 |
||
| 421 | */ |
||
| 422 | public function testUpdateWithSameColumnInDataAndIdentifiers() : void |
||
| 423 | { |
||
| 424 | $conn = $this->getExecuteUpdateMockConnection(); |
||
| 425 | |||
| 426 | $conn->expects($this->once()) |
||
| 427 | ->method('executeUpdate') |
||
| 428 | ->with( |
||
| 429 | 'UPDATE TestTable SET text = ?, is_edited = ? WHERE id = ? AND is_edited = ?', |
||
| 430 | [ |
||
| 431 | 'some text', |
||
| 432 | true, |
||
| 433 | 1, |
||
| 434 | false, |
||
| 435 | ], |
||
| 436 | [ |
||
| 437 | 'string', |
||
| 438 | 'boolean', |
||
| 439 | 'integer', |
||
| 440 | 'boolean', |
||
| 441 | ] |
||
| 442 | ); |
||
| 443 | |||
| 444 | $conn->update( |
||
| 445 | 'TestTable', |
||
| 446 | [ |
||
| 447 | 'text' => 'some text', |
||
| 448 | 'is_edited' => true, |
||
| 449 | ], |
||
| 450 | [ |
||
| 451 | 'id' => 1, |
||
| 452 | 'is_edited' => false, |
||
| 453 | ], |
||
| 454 | [ |
||
| 455 | 'text' => 'string', |
||
| 456 | 'is_edited' => 'boolean', |
||
| 457 | 'id' => 'integer', |
||
| 458 | ] |
||
| 459 | ); |
||
| 460 | } |
||
| 461 | |||
| 462 | /** |
||
| 463 | * @group DBAL-2688 |
||
| 464 | */ |
||
| 465 | public function testUpdateWithIsNull() : void |
||
| 466 | { |
||
| 467 | $conn = $this->getExecuteUpdateMockConnection(); |
||
| 468 | |||
| 469 | $conn->expects($this->once()) |
||
| 470 | ->method('executeUpdate') |
||
| 471 | ->with( |
||
| 472 | 'UPDATE TestTable SET text = ?, is_edited = ? WHERE id IS NULL AND name = ?', |
||
| 473 | [ |
||
| 474 | 'some text', |
||
| 475 | null, |
||
| 476 | 'foo', |
||
| 477 | ], |
||
| 478 | [ |
||
| 479 | 'string', |
||
| 480 | 'boolean', |
||
| 481 | 'string', |
||
| 482 | ] |
||
| 483 | ); |
||
| 484 | |||
| 485 | $conn->update( |
||
| 486 | 'TestTable', |
||
| 487 | [ |
||
| 488 | 'text' => 'some text', |
||
| 489 | 'is_edited' => null, |
||
| 490 | ], |
||
| 491 | [ |
||
| 492 | 'id' => null, |
||
| 493 | 'name' => 'foo', |
||
| 494 | ], |
||
| 495 | [ |
||
| 496 | 'text' => 'string', |
||
| 497 | 'is_edited' => 'boolean', |
||
| 498 | 'id' => 'integer', |
||
| 499 | 'name' => 'string', |
||
| 500 | ] |
||
| 501 | ); |
||
| 502 | } |
||
| 503 | |||
| 504 | /** |
||
| 505 | * @group DBAL-2688 |
||
| 506 | */ |
||
| 507 | public function testDeleteWithIsNull() : void |
||
| 508 | { |
||
| 509 | $conn = $this->getExecuteUpdateMockConnection(); |
||
| 510 | |||
| 511 | $conn->expects($this->once()) |
||
| 512 | ->method('executeUpdate') |
||
| 513 | ->with( |
||
| 514 | 'DELETE FROM TestTable WHERE id IS NULL AND name = ?', |
||
| 515 | ['foo'], |
||
| 516 | ['string'] |
||
| 517 | ); |
||
| 518 | |||
| 519 | $conn->delete( |
||
| 520 | 'TestTable', |
||
| 521 | [ |
||
| 522 | 'id' => null, |
||
| 523 | 'name' => 'foo', |
||
| 524 | ], |
||
| 525 | [ |
||
| 526 | 'id' => 'integer', |
||
| 527 | 'name' => 'string', |
||
| 528 | ] |
||
| 529 | ); |
||
| 530 | } |
||
| 531 | |||
| 532 | public function testFetchAssoc() : void |
||
| 566 | } |
||
| 567 | |||
| 568 | public function testFetchArray() : void |
||
| 602 | } |
||
| 603 | |||
| 604 | public function testFetchColumn() : void |
||
| 605 | { |
||
| 606 | $statement = 'SELECT * FROM foo WHERE bar = ?'; |
||
| 607 | $params = [666]; |
||
| 608 | $types = [ParameterType::INTEGER]; |
||
| 609 | $column = 0; |
||
| 610 | $result = []; |
||
| 611 | |||
| 612 | $driverMock = $this->createMock(Driver::class); |
||
| 613 | |||
| 614 | $driverMock->expects($this->any()) |
||
| 615 | ->method('connect') |
||
| 616 | ->will($this->returnValue( |
||
| 617 | $this->createMock(DriverConnection::class) |
||
| 618 | )); |
||
| 619 | |||
| 620 | $driverStatementMock = $this->createMock(Statement::class); |
||
| 621 | |||
| 622 | $driverStatementMock->expects($this->once()) |
||
| 623 | ->method('fetchColumn') |
||
| 624 | ->with($column) |
||
| 625 | ->will($this->returnValue($result)); |
||
| 626 | |||
| 627 | /** @var Connection|MockObject $conn */ |
||
| 628 | $conn = $this->getMockBuilder(Connection::class) |
||
| 629 | ->onlyMethods(['executeQuery']) |
||
| 630 | ->setConstructorArgs([[], $driverMock]) |
||
| 631 | ->getMock(); |
||
| 632 | |||
| 633 | $conn->expects($this->once()) |
||
| 634 | ->method('executeQuery') |
||
| 635 | ->with($statement, $params, $types) |
||
| 636 | ->will($this->returnValue($driverStatementMock)); |
||
| 637 | |||
| 638 | self::assertSame($result, $conn->fetchColumn($statement, $params, $column, $types)); |
||
| 639 | } |
||
| 640 | |||
| 641 | public function testFetchAll() : void |
||
| 642 | { |
||
| 643 | $statement = 'SELECT * FROM foo WHERE bar = ?'; |
||
| 644 | $params = [666]; |
||
| 645 | $types = [ParameterType::INTEGER]; |
||
| 646 | $result = []; |
||
| 647 | |||
| 648 | $driverMock = $this->createMock(Driver::class); |
||
| 649 | |||
| 650 | $driverMock->expects($this->any()) |
||
| 651 | ->method('connect') |
||
| 652 | ->will($this->returnValue( |
||
| 653 | $this->createMock(DriverConnection::class) |
||
| 654 | )); |
||
| 655 | |||
| 656 | $driverStatementMock = $this->createMock(Statement::class); |
||
| 657 | |||
| 658 | $driverStatementMock->expects($this->once()) |
||
| 659 | ->method('fetchAll') |
||
| 660 | ->will($this->returnValue($result)); |
||
| 661 | |||
| 662 | /** @var Connection|MockObject $conn */ |
||
| 663 | $conn = $this->getMockBuilder(Connection::class) |
||
| 664 | ->onlyMethods(['executeQuery']) |
||
| 665 | ->setConstructorArgs([[], $driverMock]) |
||
| 666 | ->getMock(); |
||
| 667 | |||
| 668 | $conn->expects($this->once()) |
||
| 669 | ->method('executeQuery') |
||
| 670 | ->with($statement, $params, $types) |
||
| 671 | ->will($this->returnValue($driverStatementMock)); |
||
| 672 | |||
| 673 | self::assertSame($result, $conn->fetchAll($statement, $params, $types)); |
||
| 674 | } |
||
| 675 | |||
| 676 | public function testCallingDeleteWithNoDeletionCriteriaResultsInInvalidArgumentException() : void |
||
| 677 | { |
||
| 678 | /** @var Driver $driver */ |
||
| 679 | $driver = $this->createMock(Driver::class); |
||
| 680 | $conn = new Connection([], $driver); |
||
| 681 | |||
| 682 | $this->expectException(InvalidArgumentException::class); |
||
| 683 | $conn->delete('kittens', []); |
||
| 684 | } |
||
| 685 | |||
| 686 | public function testCallConnectOnce() : void |
||
| 698 | } |
||
| 699 | |||
| 700 | /** |
||
| 701 | * @group DBAL-1127 |
||
| 702 | */ |
||
| 703 | public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform() : void |
||
| 704 | { |
||
| 705 | /** @var VersionAwarePlatformDriver|MockObject $driverMock */ |
||
| 706 | $driverMock = $this->createMock(VersionAwarePlatformDriver::class); |
||
| 707 | |||
| 708 | /** @var ServerInfoAwareConnection|MockObject $driverConnectionMock */ |
||
| 709 | $driverConnectionMock = $this->createMock(ServerInfoAwareConnection::class); |
||
| 710 | |||
| 711 | /** @var AbstractPlatform|MockObject $platformMock */ |
||
| 712 | $platformMock = $this->getMockForAbstractClass(AbstractPlatform::class); |
||
| 713 | |||
| 714 | $connection = new Connection([], $driverMock); |
||
| 715 | |||
| 716 | $driverMock->expects($this->once()) |
||
| 717 | ->method('connect') |
||
| 718 | ->will($this->returnValue($driverConnectionMock)); |
||
| 719 | |||
| 720 | $driverConnectionMock->expects($this->once()) |
||
| 721 | ->method('requiresQueryForServerVersion') |
||
| 722 | ->will($this->returnValue(false)); |
||
| 723 | |||
| 724 | $driverConnectionMock->expects($this->once()) |
||
| 725 | ->method('getServerVersion') |
||
| 726 | ->will($this->returnValue('6.6.6')); |
||
| 727 | |||
| 728 | $driverMock->expects($this->once()) |
||
| 729 | ->method('createDatabasePlatformForVersion') |
||
| 730 | ->with('6.6.6') |
||
| 731 | ->will($this->returnValue($platformMock)); |
||
| 732 | |||
| 733 | self::assertSame($platformMock, $connection->getDatabasePlatform()); |
||
| 734 | } |
||
| 735 | |||
| 736 | public function testConnectionParamsArePassedToTheQueryCacheProfileInExecuteCacheQuery() : void |
||
| 771 | ); |
||
| 772 | } |
||
| 773 | |||
| 774 | /** |
||
| 775 | * @group #2821 |
||
| 776 | */ |
||
| 777 | public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecuteCacheQuery() : void |
||
| 811 | } |
||
| 812 | |||
| 813 | /** |
||
| 814 | * @group #2821 |
||
| 815 | */ |
||
| 816 | public function testThrowsExceptionWhenInValidPlatformSpecified() : void |
||
| 817 | { |
||
| 818 | $connectionParams = $this->params; |
||
| 819 | $connectionParams['platform'] = new stdClass(); |
||
| 820 | |||
| 821 | /** @var Driver $driver */ |
||
| 822 | $driver = $this->createMock(Driver::class); |
||
| 823 | |||
| 824 | $this->expectException(DBALException::class); |
||
| 825 | |||
| 826 | new Connection($connectionParams, $driver); |
||
| 827 | } |
||
| 828 | |||
| 829 | /** |
||
| 830 | * @group DBAL-990 |
||
| 831 | */ |
||
| 832 | public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnectingToNonExistentDatabase() : void |
||
| 833 | { |
||
| 834 | /** @var VersionAwarePlatformDriver|MockObject $driverMock */ |
||
| 835 | $driverMock = $this->createMock(VersionAwarePlatformDriver::class); |
||
| 836 | |||
| 837 | $connection = new Connection(['dbname' => 'foo'], $driverMock); |
||
| 838 | $originalException = new Exception('Original exception'); |
||
| 839 | $fallbackException = new Exception('Fallback exception'); |
||
| 840 | |||
| 841 | $driverMock->expects($this->at(0)) |
||
| 842 | ->method('connect') |
||
| 843 | ->willThrowException($originalException); |
||
| 844 | |||
| 845 | $driverMock->expects($this->at(1)) |
||
| 846 | ->method('connect') |
||
| 847 | ->willThrowException($fallbackException); |
||
| 848 | |||
| 849 | $this->expectExceptionMessage($originalException->getMessage()); |
||
| 850 | |||
| 851 | $connection->getDatabasePlatform(); |
||
| 852 | } |
||
| 853 | |||
| 854 | /** |
||
| 855 | * @group #3194 |
||
| 856 | */ |
||
| 857 | public function testExecuteCacheQueryStripsPlatformFromConnectionParamsBeforeGeneratingCacheKeys() : void |
||
| 903 | } |
||
| 904 | } |
||
| 905 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths