Skip to content

Commit ca5fe95

Browse files
committed
Add integration test factory test for all Pdo related components
Signed-off-by: Joey Smith <jsmith@webinertia.net> Signed-off-by: Joey Smith <jsmith@webinertia.net>
1 parent 352e9fe commit ca5fe95

File tree

5 files changed

+154
-0
lines changed

5 files changed

+154
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace LaminasIntegrationTest\Db\Adapter\Mysql\Container;
6+
7+
use Laminas\Db\Adapter\Driver\ConnectionInterface;
8+
use Laminas\Db\Adapter\Driver\PdoConnectionInterface;
9+
use Laminas\Db\Adapter\Mysql\Container\PdoConnectionFactory;
10+
use Laminas\Db\Adapter\Mysql\Driver\Pdo\Connection;
11+
use PHPUnit\Framework\Attributes\CoversClass;
12+
use PHPUnit\Framework\Attributes\CoversMethod;
13+
use PHPUnit\Framework\Attributes\Group;
14+
use PHPUnit\Framework\TestCase;
15+
16+
#[Group('container')]
17+
#[Group('integration')]
18+
#[CoversClass(PdoConnectionFactory::class)]
19+
#[CoversMethod(PdoConnectionFactory::class, '__invoke')]
20+
final class PdoConnectionFactoryTest extends TestCase
21+
{
22+
use TestAsset\SetupTrait;
23+
24+
public function testInvokeReturnsPdoConnection(): void
25+
{
26+
$factory = new PdoConnectionFactory();
27+
$instance = $factory($this->container);
28+
self::assertInstanceOf(ConnectionInterface::class, $instance);
29+
self::assertInstanceOf(PdoConnectionInterface::class, $instance);
30+
self::assertInstanceOf(Connection::class, $instance);
31+
}
32+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace LaminasIntegrationTest\Db\Adapter\Mysql\Container;
6+
7+
use Laminas\Db\Adapter\Driver\PdoDriverInterface;
8+
use Laminas\Db\Adapter\Mysql\Container\PdoDriverFactory;
9+
use Laminas\Db\Adapter\Mysql\Driver\Pdo\Pdo;
10+
use PHPUnit\Framework\Attributes\CoversClass;
11+
use PHPUnit\Framework\Attributes\CoversMethod;
12+
use PHPUnit\Framework\Attributes\Group;
13+
use PHPUnit\Framework\TestCase;
14+
15+
#[Group('container')]
16+
#[Group('integration')]
17+
#[CoversClass(PdoDriverFactory::class)]
18+
#[CoversMethod(PdoDriverFactory::class, '__invoke')]
19+
final class PdoDriverFactoryTest extends TestCase
20+
{
21+
use TestAsset\SetupTrait;
22+
23+
public function testInvokeReturnsPdoDriver(): void
24+
{
25+
$factory = new PdoDriverFactory();
26+
$instance = $factory($this->container);
27+
28+
self::assertInstanceOf(PdoDriverInterface::class, $instance);
29+
self::assertInstanceOf(Pdo::class, $instance);
30+
}
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace LaminasIntegrationTest\Db\Adapter\Mysql\Container;
6+
7+
use Laminas\Db\Adapter\Driver\Pdo\Result;
8+
use Laminas\Db\Adapter\Driver\ResultInterface;
9+
use Laminas\Db\Adapter\Mysql\Container\PdoResultFactory;
10+
use PHPUnit\Framework\Attributes\CoversClass;
11+
use PHPUnit\Framework\Attributes\CoversMethod;
12+
use PHPUnit\Framework\Attributes\Group;
13+
use PHPUnit\Framework\TestCase;
14+
15+
#[Group('container')]
16+
#[Group('integration')]
17+
#[CoversClass(PdoResultFactory::class)]
18+
#[CoversMethod(PdoResultFactory::class, '__invoke')]
19+
final class PdoResultFactoryTest extends TestCase
20+
{
21+
use TestAsset\SetupTrait;
22+
23+
public function testInvokeReturnsPdoResult(): void
24+
{
25+
$factory = new PdoResultFactory();
26+
$result = $factory($this->container);
27+
28+
self::assertInstanceOf(ResultInterface::class, $result);
29+
self::assertInstanceOf(Result::class, $result);
30+
}
31+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace LaminasIntegrationTest\Db\Adapter\Mysql\Container;
6+
7+
use Laminas\Db\Adapter\Driver\Pdo\Statement;
8+
use Laminas\Db\Adapter\Driver\StatementInterface;
9+
use Laminas\Db\Adapter\Mysql\Container\PdoStatementFactory;
10+
use PHPUnit\Framework\Attributes\CoversClass;
11+
use PHPUnit\Framework\Attributes\CoversMethod;
12+
use PHPUnit\Framework\Attributes\Group;
13+
use PHPUnit\Framework\TestCase;
14+
15+
#[Group('container')]
16+
#[Group('integration')]
17+
#[CoversClass(PdoStatementFactory::class)]
18+
#[CoversMethod(PdoStatementFactory::class, '__invoke')]
19+
final class PdoStatementFactoryTest extends TestCase
20+
{
21+
use TestAsset\SetupTrait;
22+
23+
public function testInvokeReturnsPdoStatement(): void
24+
{
25+
$factory = new PdoStatementFactory();
26+
$statement = $factory($this->container);
27+
self::assertInstanceOf(StatementInterface::class, $statement);
28+
self::assertInstanceOf(Statement::class, $statement);
29+
}
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace LaminasIntegrationTest\Db\Adapter\Mysql\Container;
6+
7+
use Laminas\Db\Adapter\Mysql\Container\PlatformInterfaceFactory;
8+
use Laminas\Db\Adapter\Mysql\Platform\Mysql;
9+
use Laminas\Db\Adapter\Platform\PlatformInterface;
10+
use PHPUnit\Framework\Attributes\CoversClass;
11+
use PHPUnit\Framework\Attributes\CoversMethod;
12+
use PHPUnit\Framework\Attributes\Group;
13+
use PHPUnit\Framework\TestCase;
14+
15+
#[Group('integration')]
16+
#[Group('container')]
17+
#[CoversClass(PlatformInterfaceFactory::class)]
18+
#[CoversMethod(PlatformInterfaceFactory::class, '__invoke')]
19+
final class PlatformInterfaceFactoryTest extends TestCase
20+
{
21+
use TestAsset\SetupTrait;
22+
23+
public function testInvokeReturnsPlatformInterfaceWhenDbDriverIsPdo(): void
24+
{
25+
$factory = new PlatformInterfaceFactory();
26+
$instance = $factory($this->container);
27+
self::assertInstanceOf(PlatformInterface::class, $instance);
28+
self::assertInstanceOf(Mysql::class, $instance);
29+
}
30+
}

0 commit comments

Comments
 (0)