Skip to content

Commit ca8ad84

Browse files
committed
Signed-off-by: Joey Smith <jsmith@webinertia.net>
1 parent ca5fe95 commit ca8ad84

File tree

2 files changed

+15
-45
lines changed

2 files changed

+15
-45
lines changed

psalm-baseline.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -634,16 +634,8 @@
634634
</MoreSpecificReturnType>
635635
</file>
636636
<file src="test/integration/Driver/Pdo/AbstractAdapterTestCase.php">
637-
<RedundantCondition>
638-
<code><![CDATA[(string) $connectionConfig['port']]]></code>
639-
</RedundantCondition>
640-
<TypeDoesNotContainNull>
641-
<code><![CDATA['3306']]></code>
642-
</TypeDoesNotContainNull>
643637
<UnnecessaryVarAnnotation>
644638
<code><![CDATA[ConnectionInterface]]></code>
645-
<code><![CDATA[array]]></code>
646-
<code><![CDATA[string]]></code>
647639
</UnnecessaryVarAnnotation>
648640
</file>
649641
<file src="test/integration/Driver/Pdo/AdapterTest.php">

test/integration/Driver/Pdo/AbstractAdapterTestCase.php

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
use PHPUnit\Framework\Attributes\CoversMethod;
1414
use PHPUnit\Framework\TestCase;
1515

16-
use function getmypid;
17-
use function shell_exec;
18-
1916
#[CoversMethod(Adapter::class, 'getCurrentSchema')]
2017
#[CoversMethod(AdapterInterface::class, '__construct')]
2118
#[CoversMethod(SchemaAwareInterface::class, 'getCurrentSchema')]
@@ -44,7 +41,7 @@ public function testGetCurrentSchema(): void
4441

4542
public function testDriverDisconnectAfterQuoteWithPlatform(): void
4643
{
47-
//$isTcpConnection = $this->isTcpConnection();
44+
$isTcpConnection = $this->isTcpConnection();
4845

4946
/** @var AdapterInterface $adapter */
5047
$adapter = $this->getAdapter([
@@ -53,55 +50,36 @@ public function testDriverDisconnectAfterQuoteWithPlatform(): void
5350
],
5451
]);
5552
$adapter->getDriver()->getConnection()->connect();
56-
5753
self::assertTrue($adapter->getDriver()->getConnection()->isConnected());
58-
// if ($isTcpConnection) {
59-
// self::assertTrue($this->isConnectedTcp());
60-
// }
54+
if ($isTcpConnection) {
55+
self::assertTrue($adapter->getDriver()->getConnection()->isConnected());
56+
}
6157

6258
$adapter->getDriver()->getConnection()->disconnect();
63-
6459
self::assertFalse($adapter->getDriver()->getConnection()->isConnected());
65-
// if ($isTcpConnection) {
66-
// self::assertFalse($this->isConnectedTcp());
67-
// }
60+
if ($isTcpConnection) {
61+
self::assertFalse($adapter->getDriver()->getConnection()->isConnected());
62+
}
6863

6964
$adapter->getDriver()->getConnection()->connect();
70-
7165
self::assertTrue($adapter->getDriver()->getConnection()->isConnected());
72-
// if ($isTcpConnection) {
73-
// self::assertTrue($this->isConnectedTcp());
74-
// }
66+
if ($isTcpConnection) {
67+
self::assertTrue($adapter->getDriver()->getConnection()->isConnected());
68+
}
7569

7670
$adapter->getPlatform()->quoteValue('test');
7771

7872
$adapter->getDriver()->getConnection()->disconnect();
7973

8074
self::assertFalse($adapter->getDriver()->getConnection()->isConnected());
81-
// if ($isTcpConnection) {
82-
// self::assertFalse($this->isConnectedTcp());
83-
// }
84-
}
85-
86-
protected function isConnectedTcp(): bool
87-
{
88-
$mypid = getmypid();
89-
/** @var array $config */
90-
$config = $this->getConfig();
91-
/** @var array $dbConfig */
92-
$dbConfig = $config['db'] ?? [];
93-
/** @var array $connectionConfig */
94-
$connectionConfig = $dbConfig['connection'] ?? [];
95-
/** @var string $dbPort */
96-
$dbPort = (string) $connectionConfig['port'] ?? '3306';
97-
/** @psalm-suppress ForbiddenCode - running lsof */
98-
$lsof = shell_exec("lsof -i -P -n | grep $dbPort | grep $mypid");
99-
100-
return $lsof !== null;
75+
if ($isTcpConnection) {
76+
self::assertFalse($adapter->getDriver()->getConnection()->isConnected());
77+
}
10178
}
10279

10380
protected function isTcpConnection(): bool
10481
{
105-
return $this->getHostname() !== 'localhost';
82+
$hostName = $this->getHostname();
83+
return $hostName !== 'localhost' && $hostName !== '127.0.0.1';
10684
}
10785
}

0 commit comments

Comments
 (0)