Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions tests/Phinx/Db/Adapter/PdoAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

namespace Test\Phinx\Db\Adapter;

use PDO;
use PDOException;
use PHPUnit\Framework\TestCase;
use RuntimeException;
use Test\Phinx\Db\Mock\PdoAdapterTestPDOMock;
use Test\Phinx\Db\Mock\PdoAdapterTestPDOMockWithExecChecks;

class PdoAdapterTest extends TestCase
{
Expand Down Expand Up @@ -34,7 +33,7 @@ public function testOptions()

public function testOptionsSetConnection()
{
$connection = new PdoAdapterTestPDOMock();
$connection = $this->getMockBuilder(PDO::class)->disableOriginalConstructor()->getMock();
$this->adapter->setOptions(['connection' => $connection]);

$this->assertSame($connection, $this->adapter->getConnection());
Expand Down Expand Up @@ -181,23 +180,21 @@ public function testGetVersionLongDryRun()
*/
public function testExecuteCanBeCalled()
{
$pdo = new PdoAdapterTestPDOMockWithExecChecks();
/** @var \PDO&\PHPUnit\Framework\MockObject\MockObject $pdo */
$pdo = $this->getMockBuilder(PDO::class)->disableOriginalConstructor()->onlyMethods(['exec'])->getMock();
$pdo->expects($this->once())->method('exec')->with('SELECT 1;')->will($this->returnValue(1));

$this->adapter->setConnection($pdo);

$this->adapter->execute('SELECT 1');

$this->assertSame('SELECT 1;', $pdo->getExecutedSqlForTest());
}

public function testExecuteRightTrimsSemiColons()
{
$pdo = new PdoAdapterTestPDOMockWithExecChecks();
/** @var \PDO&\PHPUnit\Framework\MockObject\MockObject $pdo */
$pdo = $this->getMockBuilder(PDO::class)->disableOriginalConstructor()->onlyMethods(['exec'])->getMock();
$pdo->expects($this->once())->method('exec')->with('SELECT 1;')->will($this->returnValue(1));

$this->adapter->setConnection($pdo);

$this->adapter->execute('SELECT 1;;');

$this->assertSame('SELECT 1;', $pdo->getExecutedSqlForTest());
}
}
10 changes: 0 additions & 10 deletions tests/Phinx/Db/Mock/PdoAdapterTestPDOMock.php

This file was deleted.

33 changes: 0 additions & 33 deletions tests/Phinx/Db/Mock/PdoAdapterTestPDOMockWithExecChecks.php

This file was deleted.

16 changes: 0 additions & 16 deletions tests/Phinx/Db/Mock/PdoStatementMock.php

This file was deleted.