|
@@ 476-508 (lines=33) @@
|
| 473 |
|
); |
| 474 |
|
} |
| 475 |
|
|
| 476 |
|
public function testFetchAssoc() |
| 477 |
|
{ |
| 478 |
|
$statement = 'SELECT * FROM foo WHERE bar = ?'; |
| 479 |
|
$params = array(666); |
| 480 |
|
$types = array(\PDO::PARAM_INT); |
| 481 |
|
$result = array(); |
| 482 |
|
|
| 483 |
|
$driverMock = $this->createMock('Doctrine\DBAL\Driver'); |
| 484 |
|
|
| 485 |
|
$driverMock->expects($this->any()) |
| 486 |
|
->method('connect') |
| 487 |
|
->will($this->returnValue(new DriverConnectionMock())); |
| 488 |
|
|
| 489 |
|
$driverStatementMock = $this->createMock('Doctrine\Tests\Mocks\DriverStatementMock'); |
| 490 |
|
|
| 491 |
|
$driverStatementMock->expects($this->once()) |
| 492 |
|
->method('fetch') |
| 493 |
|
->with(\PDO::FETCH_ASSOC) |
| 494 |
|
->will($this->returnValue($result)); |
| 495 |
|
|
| 496 |
|
/** @var \PHPUnit_Framework_MockObject_MockObject|\Doctrine\DBAL\Connection $conn */ |
| 497 |
|
$conn = $this->getMockBuilder('Doctrine\DBAL\Connection') |
| 498 |
|
->setMethods(array('executeQuery')) |
| 499 |
|
->setConstructorArgs(array(array('platform' => new Mocks\MockPlatform()), $driverMock)) |
| 500 |
|
->getMock(); |
| 501 |
|
|
| 502 |
|
$conn->expects($this->once()) |
| 503 |
|
->method('executeQuery') |
| 504 |
|
->with($statement, $params, $types) |
| 505 |
|
->will($this->returnValue($driverStatementMock)); |
| 506 |
|
|
| 507 |
|
$this->assertSame($result, $conn->fetchAssoc($statement, $params, $types)); |
| 508 |
|
} |
| 509 |
|
|
| 510 |
|
public function testFetchArray() |
| 511 |
|
{ |
|
@@ 510-542 (lines=33) @@
|
| 507 |
|
$this->assertSame($result, $conn->fetchAssoc($statement, $params, $types)); |
| 508 |
|
} |
| 509 |
|
|
| 510 |
|
public function testFetchArray() |
| 511 |
|
{ |
| 512 |
|
$statement = 'SELECT * FROM foo WHERE bar = ?'; |
| 513 |
|
$params = array(666); |
| 514 |
|
$types = array(\PDO::PARAM_INT); |
| 515 |
|
$result = array(); |
| 516 |
|
|
| 517 |
|
$driverMock = $this->createMock('Doctrine\DBAL\Driver'); |
| 518 |
|
|
| 519 |
|
$driverMock->expects($this->any()) |
| 520 |
|
->method('connect') |
| 521 |
|
->will($this->returnValue(new DriverConnectionMock())); |
| 522 |
|
|
| 523 |
|
$driverStatementMock = $this->createMock('Doctrine\Tests\Mocks\DriverStatementMock'); |
| 524 |
|
|
| 525 |
|
$driverStatementMock->expects($this->once()) |
| 526 |
|
->method('fetch') |
| 527 |
|
->with(\PDO::FETCH_NUM) |
| 528 |
|
->will($this->returnValue($result)); |
| 529 |
|
|
| 530 |
|
/** @var \PHPUnit_Framework_MockObject_MockObject|\Doctrine\DBAL\Connection $conn */ |
| 531 |
|
$conn = $this->getMockBuilder('Doctrine\DBAL\Connection') |
| 532 |
|
->setMethods(array('executeQuery')) |
| 533 |
|
->setConstructorArgs(array(array('platform' => new Mocks\MockPlatform()), $driverMock)) |
| 534 |
|
->getMock(); |
| 535 |
|
|
| 536 |
|
$conn->expects($this->once()) |
| 537 |
|
->method('executeQuery') |
| 538 |
|
->with($statement, $params, $types) |
| 539 |
|
->will($this->returnValue($driverStatementMock)); |
| 540 |
|
|
| 541 |
|
$this->assertSame($result, $conn->fetchArray($statement, $params, $types)); |
| 542 |
|
} |
| 543 |
|
|
| 544 |
|
public function testFetchColumn() |
| 545 |
|
{ |
|
@@ 602-633 (lines=32) @@
|
| 599 |
|
$this->assertNull($connection->getWrappedConnection()); |
| 600 |
|
} |
| 601 |
|
|
| 602 |
|
public function testFetchAll() |
| 603 |
|
{ |
| 604 |
|
$statement = 'SELECT * FROM foo WHERE bar = ?'; |
| 605 |
|
$params = array(666); |
| 606 |
|
$types = array(\PDO::PARAM_INT); |
| 607 |
|
$result = array(); |
| 608 |
|
|
| 609 |
|
$driverMock = $this->createMock('Doctrine\DBAL\Driver'); |
| 610 |
|
|
| 611 |
|
$driverMock->expects($this->any()) |
| 612 |
|
->method('connect') |
| 613 |
|
->will($this->returnValue(new DriverConnectionMock())); |
| 614 |
|
|
| 615 |
|
$driverStatementMock = $this->createMock('Doctrine\Tests\Mocks\DriverStatementMock'); |
| 616 |
|
|
| 617 |
|
$driverStatementMock->expects($this->once()) |
| 618 |
|
->method('fetchAll') |
| 619 |
|
->will($this->returnValue($result)); |
| 620 |
|
|
| 621 |
|
/** @var \PHPUnit_Framework_MockObject_MockObject|\Doctrine\DBAL\Connection $conn */ |
| 622 |
|
$conn = $this->getMockBuilder('Doctrine\DBAL\Connection') |
| 623 |
|
->setMethods(array('executeQuery')) |
| 624 |
|
->setConstructorArgs(array(array('platform' => new Mocks\MockPlatform()), $driverMock)) |
| 625 |
|
->getMock(); |
| 626 |
|
|
| 627 |
|
$conn->expects($this->once()) |
| 628 |
|
->method('executeQuery') |
| 629 |
|
->with($statement, $params, $types) |
| 630 |
|
->will($this->returnValue($driverStatementMock)); |
| 631 |
|
|
| 632 |
|
$this->assertSame($result, $conn->fetchAll($statement, $params, $types)); |
| 633 |
|
} |
| 634 |
|
|
| 635 |
|
public function testConnectionDoesNotMaintainTwoReferencesToExternalPDO() |
| 636 |
|
{ |