Skip to content

Commit 3aca44f

Browse files
committed
Unit test are running. With following results:
Tests: 83, Assertions: 173, Notices: 1, Skipped: 4, Incomplete: 13, Risky: 4. Signed-off-by: Joey Smith <jsmith@webinertia.net> Signed-off-by: Joey Smith <jsmith@webinertia.net>
1 parent 4a9c4f5 commit 3aca44f

File tree

17 files changed

+112
-111
lines changed

17 files changed

+112
-111
lines changed

composer.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Driver/Mysqli/Mysqli.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Laminas\Db\Adapter\Driver\DriverInterface;
88
use Laminas\Db\Adapter\Exception;
99
use Laminas\Db\Adapter\Profiler;
10+
use Laminas\Db\Adapter\Mysql\DatabasePlatformNameTrait;
1011
use mysqli_stmt;
1112

1213
use function array_intersect_key;
@@ -16,6 +17,8 @@
1617

1718
class Mysqli implements DriverInterface, Profiler\ProfilerAwareInterface
1819
{
20+
use DatabasePlatformNameTrait;
21+
1922
/** @var Connection */
2023
protected $connection;
2124

@@ -125,21 +128,6 @@ public function getResultPrototype()
125128
return $this->resultPrototype;
126129
}
127130

128-
/**
129-
* Get database platform name
130-
*
131-
* @param string $nameFormat
132-
* @return string
133-
*/
134-
public function getDatabasePlatformName($nameFormat = self::NAME_FORMAT_CAMELCASE)
135-
{
136-
if ($nameFormat === self::NAME_FORMAT_CAMELCASE) {
137-
return 'Mysql';
138-
}
139-
140-
return 'MySQL';
141-
}
142-
143131
/**
144132
* Check environment
145133
*

src/Driver/Pdo/Connection.php

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -116,38 +116,23 @@ public function connect(): static
116116

117117
if (! isset($dsn) && isset($pdoDriver)) {
118118
$dsn = [];
119-
switch ($pdoDriver) {
120-
case 'sqlite':
121-
$dsn[] = $database;
122-
break;
123-
case 'sqlsrv':
124-
if (isset($database)) {
125-
$dsn[] = "database={$database}";
126-
}
127-
if (isset($hostname)) {
128-
$dsn[] = "server={$hostname}";
129-
}
130-
break;
131-
default:
132-
if (isset($database)) {
133-
$dsn[] = "dbname={$database}";
134-
}
135-
if (isset($hostname)) {
136-
$dsn[] = "host={$hostname}";
137-
}
138-
if (isset($port)) {
139-
$dsn[] = "port={$port}";
140-
}
141-
if (isset($charset) && $pdoDriver !== 'pgsql') {
142-
$dsn[] = "charset={$charset}";
143-
}
144-
if (isset($unixSocket)) {
145-
$dsn[] = "unix_socket={$unixSocket}";
146-
}
147-
if (isset($version)) {
148-
$dsn[] = "version={$version}";
149-
}
150-
break;
119+
if (isset($database)) {
120+
$dsn[] = "dbname={$database}";
121+
}
122+
if (isset($hostname)) {
123+
$dsn[] = "host={$hostname}";
124+
}
125+
if (isset($port)) {
126+
$dsn[] = "port={$port}";
127+
}
128+
if (isset($charset) && $pdoDriver !== 'pgsql') {
129+
$dsn[] = "charset={$charset}";
130+
}
131+
if (isset($unixSocket)) {
132+
$dsn[] = "unix_socket={$unixSocket}";
133+
}
134+
if (isset($version)) {
135+
$dsn[] = "version={$version}";
151136
}
152137
$dsn = $pdoDriver . ':' . implode(';', $dsn);
153138
} elseif (! isset($dsn)) {

test/unit/Adapter/Driver/Pdo/TestAsset/SqliteMemoryPdo.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

test/unit/Adapter/Driver/Mysqli/ConnectionTest.php renamed to test/unit/Driver/Mysqli/ConnectionTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function testGetConnectionParameters(): void
6464
public function testNonSecureConnection(): void
6565
{
6666
$mysqli = $this->createMockMysqli(0);
67+
/** @var Connection */
6768
$connection = $this->createMockConnection(
6869
$mysqli,
6970
[
@@ -81,6 +82,7 @@ public function testNonSecureConnection(): void
8182
public function testSslConnection(): void
8283
{
8384
$mysqli = $this->createMockMysqli(MYSQLI_CLIENT_SSL);
85+
/** @var Connection */
8486
$connection = $this->createMockConnection(
8587
$mysqli,
8688
[
@@ -99,6 +101,7 @@ public function testSslConnection(): void
99101
public function testSslConnectionNoVerify(): void
100102
{
101103
$mysqli = $this->createMockMysqli(MYSQLI_CLIENT_SSL | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT);
104+
/** @var Connection */
102105
$connection = $this->createMockConnection(
103106
$mysqli,
104107
[

test/unit/Adapter/Driver/Pdo/ConnectionIntegrationTest.php renamed to test/unit/Driver/Pdo/ConnectionIntegrationTest.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,22 @@
2929
final class ConnectionIntegrationTest extends TestCase
3030
{
3131
/** @var array<string, string> */
32-
protected array $variables = ['pdodriver' => 'sqlite', 'database' => ':memory:'];
32+
protected array $variables = ['driver' => 'pdo_mysql', 'database' => 'laminas_test'];
3333

3434
public function testGetCurrentSchema(): void
3535
{
36+
$this->markTestIncomplete(
37+
'Already covered by integration group'
38+
);
3639
$connection = new Connection($this->variables);
3740
self::assertIsString($connection->getCurrentSchema());
3841
}
3942

4043
public function testSetResource(): void
4144
{
45+
$this->markTestIncomplete(
46+
'Needs refactored since no Sqlite testing should occur here'
47+
);
4248
$resource = new TestAsset\SqliteMemoryPdo();
4349
$connection = new Connection([]);
4450
self::assertSame($connection, $connection->setResource($resource));
@@ -50,6 +56,9 @@ public function testSetResource(): void
5056

5157
public function testGetResource(): void
5258
{
59+
$this->markTestIncomplete(
60+
'Possibly covered by integration group'
61+
);
5362
$connection = new Connection($this->variables);
5463
$connection->connect();
5564
self::assertInstanceOf('PDO', $connection->getResource());
@@ -60,6 +69,9 @@ public function testGetResource(): void
6069

6170
public function testConnect(): void
6271
{
72+
$this->markTestIncomplete(
73+
'Already covered by integration group'
74+
);
6375
$connection = new Connection($this->variables);
6476
self::assertSame($connection, $connection->connect());
6577
self::assertTrue($connection->isConnected());
@@ -70,6 +82,9 @@ public function testConnect(): void
7082

7183
public function testIsConnected(): void
7284
{
85+
$this->markTestIncomplete(
86+
'Already covered by integration group'
87+
);
7388
$connection = new Connection($this->variables);
7489
self::assertFalse($connection->isConnected());
7590
self::assertSame($connection, $connection->connect());
@@ -81,6 +96,9 @@ public function testIsConnected(): void
8196

8297
public function testDisconnect(): void
8398
{
99+
$this->markTestIncomplete(
100+
'Already covered by integration group'
101+
);
84102
$connection = new Connection($this->variables);
85103
$connection->connect();
86104
self::assertTrue($connection->isConnected());
@@ -123,6 +141,9 @@ public function testRollback(): never
123141

124142
public function testExecute(): void
125143
{
144+
$this->markTestIncomplete(
145+
'Needs refactored or removed since sqlsrv testing should not occur here'
146+
);
126147
$sqlsrv = new Pdo($this->variables);
127148
$connection = $sqlsrv->getConnection();
128149

@@ -132,6 +153,9 @@ public function testExecute(): void
132153

133154
public function testPrepare(): void
134155
{
156+
$this->markTestIncomplete(
157+
'Needs refactored or removed since we do not have a valid connection in Unit test'
158+
);
135159
$sqlsrv = new Pdo($this->variables);
136160
$connection = $sqlsrv->getConnection();
137161

@@ -149,6 +173,9 @@ public function testGetLastGeneratedValue(): never
149173
#[Group('laminas3469')]
150174
public function testConnectReturnsConnectionWhenResourceSet(): void
151175
{
176+
$this->markTestIncomplete(
177+
'Needs refactored or removed since we do not have a valid connection in Unit test'
178+
);
152179
$resource = new TestAsset\SqliteMemoryPdo();
153180
$connection = new Connection([]);
154181
$connection->setResource($resource);
File renamed without changes.

test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php renamed to test/unit/Driver/Pdo/ConnectionTransactionsTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Laminas\Db\Adapter\Driver\AbstractConnection;
88
use Laminas\Db\Adapter\Exception\RuntimeException;
99
use Laminas\Db\Adapter\Mysql\Driver\Pdo\Connection;
10-
use LaminasTest\Db\TestAsset\ConnectionWrapper;
10+
use LaminasTest\Db\Adapter\Mysql\TestAsset\ConnectionWrapper;
1111
use Override;
1212
use PHPUnit\Framework\Attributes\CoversClass;
1313
use PHPUnit\Framework\Attributes\CoversMethod;
@@ -24,8 +24,7 @@
2424
#[CoversMethod(Connection::class, 'rollback()')]
2525
final class ConnectionTransactionsTest extends TestCase
2626
{
27-
/** @var Wrapper */
28-
protected Wrapper|ConnectionWrapper $wrapper;
27+
protected ConnectionWrapper $wrapper;
2928

3029
/**
3130
* {@inheritDoc}
File renamed without changes.

0 commit comments

Comments
 (0)