-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'hotfix/44' into develop
Forward port #44
- Loading branch information
Showing
18 changed files
with
315 additions
and
86 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
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
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
79 changes: 79 additions & 0 deletions
79
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,79 @@ | ||
<?php | ||
|
||
/** | ||
* @see https://github.com/laminas/laminas-db for the canonical source repository | ||
* @copyright https://github.com/laminas/laminas-db/blob/master/COPYRIGHT.md | ||
* @license https://github.com/laminas/laminas-db/blob/master/LICENSE.md New BSD License | ||
*/ | ||
|
||
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(); | ||
} |
Oops, something went wrong.