-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapter test (both driver and platform used)
- Loading branch information
Showing
9 changed files
with
176 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
test/integration/Adapter/Driver/Pdo/AbstractAdapterTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace LaminasIntegrationTest\Db\Adapter\Driver\Pdo; | ||
|
||
use Laminas\Db\Adapter\Adapter; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @property Adapter $adapter | ||
*/ | ||
abstract class AbstractAdapterTest extends TestCase | ||
{ | ||
const DB_SERVER_PORT = null; | ||
|
||
/** | ||
* @covers \Laminas\Db\Adapter\Adapter::__construct() | ||
*/ | ||
public function testConnection() | ||
{ | ||
$this->assertInstanceOf(Adapter::class, $this->adapter); | ||
} | ||
|
||
public function testDriverDisconnectAfterQuoteWithPlatform() | ||
{ | ||
$isTcpConnection = $this->isTcpConnection(); | ||
|
||
$this->adapter->getDriver()->getConnection()->connect(); | ||
|
||
self::assertTrue($this->adapter->getDriver()->getConnection()->isConnected()); | ||
if ($isTcpConnection) { | ||
self::assertTrue($this->isConnectedTcp()); | ||
} | ||
|
||
$this->adapter->getDriver()->getConnection()->disconnect(); | ||
|
||
self::assertFalse($this->adapter->getDriver()->getConnection()->isConnected()); | ||
if ($isTcpConnection) { | ||
self::assertFalse($this->isConnectedTcp()); | ||
} | ||
|
||
$this->adapter->getDriver()->getConnection()->connect(); | ||
|
||
self::assertTrue($this->adapter->getDriver()->getConnection()->isConnected()); | ||
if ($isTcpConnection) { | ||
self::assertTrue($this->isConnectedTcp()); | ||
} | ||
|
||
$this->adapter->getPlatform()->quoteValue('test'); | ||
|
||
$this->adapter->getDriver()->getConnection()->disconnect(); | ||
|
||
self::assertFalse($this->adapter->getDriver()->getConnection()->isConnected()); | ||
if ($isTcpConnection) { | ||
self::assertFalse($this->isConnectedTcp()); | ||
} | ||
} | ||
|
||
protected function isConnectedTcp() | ||
{ | ||
$mypid = getmypid(); | ||
$dbPort = static::DB_SERVER_PORT; | ||
$lsof = shell_exec("lsof -i -P -n | grep $dbPort | grep $mypid"); | ||
return $lsof !== null; | ||
} | ||
|
||
protected function isTcpConnection() | ||
{ | ||
return $this->getHostname() !== 'localhost'; | ||
} | ||
|
||
abstract protected function getHostname(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
test/integration/Adapter/Driver/Pdo/Postgresql/AdapterTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace LaminasIntegrationTest\Db\Adapter\Driver\Pdo\Postgresql; | ||
|
||
use LaminasIntegrationTest\Db\Adapter\Driver\Pdo\AbstractAdapterTest; | ||
use PHPUnit\DbUnit\TestCaseTrait; | ||
|
||
class AdapterTest extends AbstractAdapterTest | ||
{ | ||
use AdapterTrait; | ||
|
||
const DB_SERVER_PORT = 5432; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters