|
2 | 2 |
|
3 | 3 | namespace Test\Phinx\Db\Adapter;
|
4 | 4 |
|
| 5 | +use PDO; |
5 | 6 | use PDOException;
|
6 | 7 | use PHPUnit\Framework\TestCase;
|
7 | 8 | use RuntimeException;
|
8 |
| -use Test\Phinx\Db\Mock\PdoAdapterTestPDOMock; |
9 |
| -use Test\Phinx\Db\Mock\PdoAdapterTestPDOMockWithExecChecks; |
10 | 9 |
|
11 | 10 | class PdoAdapterTest extends TestCase
|
12 | 11 | {
|
@@ -34,7 +33,7 @@ public function testOptions()
|
34 | 33 |
|
35 | 34 | public function testOptionsSetConnection()
|
36 | 35 | {
|
37 |
| - $connection = new PdoAdapterTestPDOMock(); |
| 36 | + $connection = $this->getMockBuilder(PDO::class)->disableOriginalConstructor()->getMock(); |
38 | 37 | $this->adapter->setOptions(['connection' => $connection]);
|
39 | 38 |
|
40 | 39 | $this->assertSame($connection, $this->adapter->getConnection());
|
@@ -181,23 +180,21 @@ public function testGetVersionLongDryRun()
|
181 | 180 | */
|
182 | 181 | public function testExecuteCanBeCalled()
|
183 | 182 | {
|
184 |
| - $pdo = new PdoAdapterTestPDOMockWithExecChecks(); |
| 183 | + /** @var \PDO&\PHPUnit\Framework\MockObject\MockObject $pdo */ |
| 184 | + $pdo = $this->getMockBuilder(PDO::class)->disableOriginalConstructor()->onlyMethods(['exec'])->getMock(); |
| 185 | + $pdo->expects($this->once())->method('exec')->with('SELECT 1;')->will($this->returnValue(1)); |
185 | 186 |
|
186 | 187 | $this->adapter->setConnection($pdo);
|
187 |
| - |
188 | 188 | $this->adapter->execute('SELECT 1');
|
189 |
| - |
190 |
| - $this->assertSame('SELECT 1;', $pdo->getExecutedSqlForTest()); |
191 | 189 | }
|
192 | 190 |
|
193 | 191 | public function testExecuteRightTrimsSemiColons()
|
194 | 192 | {
|
195 |
| - $pdo = new PdoAdapterTestPDOMockWithExecChecks(); |
| 193 | + /** @var \PDO&\PHPUnit\Framework\MockObject\MockObject $pdo */ |
| 194 | + $pdo = $this->getMockBuilder(PDO::class)->disableOriginalConstructor()->onlyMethods(['exec'])->getMock(); |
| 195 | + $pdo->expects($this->once())->method('exec')->with('SELECT 1;')->will($this->returnValue(1)); |
196 | 196 |
|
197 | 197 | $this->adapter->setConnection($pdo);
|
198 |
| - |
199 | 198 | $this->adapter->execute('SELECT 1;;');
|
200 |
| - |
201 |
| - $this->assertSame('SELECT 1;', $pdo->getExecutedSqlForTest()); |
202 | 199 | }
|
203 | 200 | }
|
0 commit comments