Skip to content

Commit 9519c3a

Browse files
committed
Adds missing integration test for new factories
updates baseline Signed-off-by: Joey Smith <[email protected]> Signed-off-by: Joey Smith <[email protected]>
1 parent ca8ad84 commit 9519c3a

File tree

7 files changed

+140
-20
lines changed

7 files changed

+140
-20
lines changed

psalm-baseline.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,11 @@
1212
<code><![CDATA[ResultSetInterface]]></code>
1313
</UnnecessaryVarAnnotation>
1414
</file>
15-
<file src="src/Container/DriverFeatureFactory.php">
16-
<UnusedClass>
17-
<code><![CDATA[DriverFeatureFactory]]></code>
18-
</UnusedClass>
19-
</file>
2015
<file src="src/Container/MysqliResultFactory.php">
2116
<UnusedParam>
2217
<code><![CDATA[$container]]></code>
2318
</UnusedParam>
2419
</file>
25-
<file src="src/Container/MysqliStatementFactory.php">
26-
<UndefinedVariable>
27-
<code><![CDATA[$bufferResults]]></code>
28-
</UndefinedVariable>
29-
</file>
3020
<file src="src/Container/PdoResultFactory.php">
3121
<UnusedParam>
3222
<code><![CDATA[$container]]></code>

src/Container/DriverFeatureFactory.php

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

src/Container/MysqliStatementFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __invoke(ContainerInterface $container): StatementInterface&Stat
2222
$options = $dbConfig['options'] ?? [];
2323

2424
/** @var bool $bufferResults */
25-
$bufferResults = $options['buffer_results'] ?? $bufferResults;
25+
$bufferResults = $options['buffer_results'] ?? false;
2626

2727
return new Statement(bufferResults: $bufferResults);
2828
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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\Mysql\Container\MysqliConnectionFactory;
9+
use Laminas\Db\Adapter\Mysql\Driver\Mysqli\Connection;
10+
use PHPUnit\Framework\Attributes;
11+
use PHPUnit\Framework\TestCase;
12+
13+
#[Attributes\CoversClass(MysqliConnectionFactory::class)]
14+
#[Attributes\CoversMethod(MysqliConnectionFactory::class, '__invoke')]
15+
#[Attributes\Group('container')]
16+
#[Attributes\Group('integration')]
17+
#[Attributes\Group('integration-mysqli')]
18+
final class MysqliConnectionFactoryTest extends TestCase
19+
{
20+
use TestAsset\SetupTrait;
21+
22+
public function testInvokeReturnsMysqliConnection(): void
23+
{
24+
$this->getAdapter([
25+
'db' => [
26+
'driver' => 'Mysqli',
27+
],
28+
]);
29+
30+
$factory = new MysqliConnectionFactory();
31+
$connection = $factory($this->container);
32+
33+
self::assertInstanceOf(ConnectionInterface::class, $connection);
34+
self::assertInstanceOf(Connection::class, $connection);
35+
}
36+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace LaminasIntegrationTest\Db\Adapter\Mysql\Container;
6+
7+
use Laminas\Db\Adapter\Driver\DriverInterface;
8+
use Laminas\Db\Adapter\Mysql\Container\MysqliDriverFactory;
9+
use Laminas\Db\Adapter\Mysql\Driver\Mysqli\Mysqli;
10+
use PHPUnit\Framework\Attributes;
11+
use PHPUnit\Framework\TestCase;
12+
13+
#[Attributes\CoversClass(MysqliDriverFactory::class)]
14+
#[Attributes\CoversMethod(MysqliDriverFactory::class, '__invoke')]
15+
#[Attributes\Group('container')]
16+
#[Attributes\Group('integration')]
17+
#[Attributes\Group('integration-mysqli')]
18+
final class MysqliDriverFactoryTest extends TestCase
19+
{
20+
use TestAsset\SetupTrait;
21+
22+
public function testFactoryReturnsMysqliDriver(): void
23+
{
24+
$this->getAdapter([
25+
'db' => [
26+
'driver' => 'Mysqli',
27+
],
28+
]);
29+
$factory = new MysqliDriverFactory();
30+
$driver = $factory($this->container);
31+
self::assertInstanceOf(DriverInterface::class, $driver);
32+
$this->assertInstanceOf(Mysqli::class, $driver);
33+
}
34+
}
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\ResultInterface;
8+
use Laminas\Db\Adapter\Mysql\Container\MysqliResultFactory;
9+
use Laminas\Db\Adapter\Mysql\Driver\Mysqli\Result;
10+
use PHPUnit\Framework\Attributes;
11+
use PHPUnit\Framework\TestCase;
12+
13+
#[Attributes\CoversClass(MysqliResultFactory::class)]
14+
#[Attributes\CoversMethod(MysqliResultFactory::class, '__invoke')]
15+
#[Attributes\Group('container')]
16+
#[Attributes\Group('integration')]
17+
#[Attributes\Group('integration-mysqli')]
18+
final class MysqliResultFactoryTest extends TestCase
19+
{
20+
use TestAsset\SetupTrait;
21+
22+
public function testInvokeReturnsMysqliResult(): void
23+
{
24+
$factory = new MysqliResultFactory();
25+
$result = $factory($this->container);
26+
27+
self::assertInstanceOf(ResultInterface::class, $result);
28+
self::assertInstanceOf(Result::class, $result);
29+
}
30+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace LaminasIntegrationTest\Db\Adapter\Mysql\Container;
6+
7+
use Laminas\Db\Adapter\Driver\StatementInterface;
8+
use Laminas\Db\Adapter\Mysql\Container\MysqliStatementFactory;
9+
use Laminas\Db\Adapter\Mysql\Driver\Mysqli\Statement;
10+
use PHPUnit\Framework\Attributes;
11+
use PHPUnit\Framework\TestCase;
12+
13+
#[Attributes\CoversClass(MysqliStatementFactory::class)]
14+
#[Attributes\CoversMethod(MysqliStatementFactory::class, '__invoke')]
15+
#[Attributes\Group('container')]
16+
#[Attributes\Group('integration')]
17+
#[Attributes\Group('integration-mysqli')]
18+
final class MysqliStatementFactoryTest extends TestCase
19+
{
20+
use TestAsset\SetupTrait;
21+
22+
public function testInvokeReturnsMysqliStatement(): void
23+
{
24+
$this->getAdapter([
25+
'db' => [
26+
'driver' => 'Mysqli',
27+
'options' => [
28+
'buffer_results' => false,
29+
],
30+
],
31+
]);
32+
33+
$factory = new MysqliStatementFactory();
34+
$statement = $factory($this->container);
35+
36+
self::assertInstanceOf(StatementInterface::class, $statement);
37+
self::assertInstanceOf(Statement::class, $statement);
38+
}
39+
}

0 commit comments

Comments
 (0)