diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 6a39fe2..cd4fe80 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -21,9 +21,7 @@
connectionParameters]]>
-
- resource->getAttribute(\PDO::ATTR_DRIVER_NAME)]]>
-
+
@@ -80,9 +78,6 @@
-
-
-
@@ -364,17 +359,9 @@
- getMockBuilder(Driver::class)
- ->setConstructorArgs([
- $this->mockConnection,
- $this->mockStatement,
- ])
- ->getMock()]]>
getMockBuilder(Statement::class)->getMock()]]>
-
-
@@ -432,8 +419,6 @@
-
-
@@ -441,47 +426,6 @@
-
-
- [
- PlatformInterface::class => Platform\Sqlite::class,
- ProfilerInterface::class => Profiler::class,
- ],
- 'factories' => [
- AdapterInterface::class => AdapterServiceFactory::class,
- DriverInterface::class => Driver\Pdo\DriverFactory::class,
- Platform\Sqlite::class => InvokableFactory::class,
- Profiler::class => InvokableFactory::class,
- ],
- ]]]>
-
-
-
-
-
-
-
-
-
- pdo]]>
-
-
-
-
-
- pdo]]>
- pdo]]>
- pdo]]>
- pdo]]>
- pdo]]>
- pdo]]>
-
-
-
-
-
-
@@ -490,17 +434,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -509,47 +442,8 @@
-
-
- [
- PlatformInterface::class => Platform\Sqlite::class,
- ProfilerInterface::class => Profiler::class,
- ],
- 'factories' => [
- AdapterInterface::class => AdapterServiceFactory::class,
- DriverInterface::class => Driver\Pdo\DriverFactory::class,
- Platform\Sqlite::class => InvokableFactory::class,
- Profiler::class => InvokableFactory::class,
- ],
- ]]]>
-
-
-
-
-
-
-
- assertEquals(E_USER_NOTICE, $errno);
- $this->assertEquals(
- $errstr,
- 'Attempting to quote a value in PhpDb\Adapter\Sqlite\Platform\Sqlite without extension/driver support can '
- . 'introduce security vulnerabilities in a production environment'
- );
- $raisedNotice = true;
- }]]>
- assertEquals(E_USER_NOTICE, $errno);
- $this->assertEquals(
- $errstr,
- 'Attempting to quote a value in PhpDb\Adapter\Sqlite\Platform\Sqlite without extension/driver support can '
- . 'introduce security vulnerabilities in a production environment'
- );
- $raisedNotice = true;
- }]]>
-
+
diff --git a/src/ConfigProvider.php b/src/ConfigProvider.php
index ce40636..5a093e0 100644
--- a/src/ConfigProvider.php
+++ b/src/ConfigProvider.php
@@ -7,13 +7,13 @@
use Laminas\ServiceManager\Factory\InvokableFactory;
use PhpDb\Adapter\AdapterInterface;
use PhpDb\Adapter\Driver\ConnectionInterface;
-use PhpDb\Adapter\Driver\PdoConnectionInterface;
use PhpDb\Adapter\Driver\DriverInterface;
+use PhpDb\Adapter\Driver\Pdo\Result;
+use PhpDb\Adapter\Driver\Pdo\Statement;
+use PhpDb\Adapter\Driver\PdoConnectionInterface;
use PhpDb\Adapter\Driver\PdoDriverInterface;
use PhpDb\Adapter\Driver\ResultInterface;
use PhpDb\Adapter\Driver\StatementInterface;
-use PhpDb\Adapter\Driver\Pdo\Result;
-use PhpDb\Adapter\Driver\Pdo\Statement;
use PhpDb\Adapter\Platform\PlatformInterface;
use PhpDb\Adapter\Profiler\Profiler;
use PhpDb\Adapter\Profiler\ProfilerInterface;
@@ -34,10 +34,10 @@ public function __invoke(): array
public function getDependencies(): array
{
return [
- 'aliases' => [
+ 'aliases' => [
MetadataInterface::class => Metadata\Source\SqliteMetadata::class,
],
- 'factories' => [
+ 'factories' => [
Metadata\Source\SqliteMetadata::class => Container\MetadataInterfaceFactory::class,
],
'delegators' => [
diff --git a/src/Container/AdapterFactory.php b/src/Container/AdapterFactory.php
index e593fff..b396be9 100644
--- a/src/Container/AdapterFactory.php
+++ b/src/Container/AdapterFactory.php
@@ -81,4 +81,3 @@ public function __invoke(ContainerInterface $container): AdapterInterface
);
}
}
-
diff --git a/src/Container/MetadataInterfaceFactory.php b/src/Container/MetadataInterfaceFactory.php
index 4d7194c..65bcef8 100644
--- a/src/Container/MetadataInterfaceFactory.php
+++ b/src/Container/MetadataInterfaceFactory.php
@@ -5,8 +5,8 @@
namespace PhpDb\Adapter\Sqlite\Container;
use PhpDb\Adapter\AdapterInterface;
-use PhpDb\Adapter\Sqlite\Metadata\Source\SqliteMetadata;
use PhpDb\Adapter\SchemaAwareInterface;
+use PhpDb\Adapter\Sqlite\Metadata\Source\SqliteMetadata;
use PhpDb\Metadata\MetadataInterface;
use Psr\Container\ContainerInterface;
diff --git a/src/Container/PdoDriverFactory.php b/src/Container/PdoDriverFactory.php
index 9e06103..33cd20b 100644
--- a/src/Container/PdoDriverFactory.php
+++ b/src/Container/PdoDriverFactory.php
@@ -10,8 +10,8 @@
use PhpDb\Adapter\Driver\PdoDriverInterface;
use PhpDb\Adapter\Driver\ResultInterface;
use PhpDb\Adapter\Driver\StatementInterface;
-use PhpDb\Adapter\Sqlite\Driver\Pdo\Feature\SqliteRowCounter;
use PhpDb\Adapter\Sqlite\Driver\Pdo\Connection;
+use PhpDb\Adapter\Sqlite\Driver\Pdo\Feature\SqliteRowCounter;
use PhpDb\Adapter\Sqlite\Driver\Pdo\Pdo as PdoDriver;
use PhpDb\Container\AdapterManager;
use Psr\Container\ContainerInterface;
diff --git a/src/Container/PdoStatementFactory.php b/src/Container/PdoStatementFactory.php
index 7b8c343..1b33117 100644
--- a/src/Container/PdoStatementFactory.php
+++ b/src/Container/PdoStatementFactory.php
@@ -6,7 +6,6 @@
use PhpDb\Adapter\Driver\Pdo\Statement;
use PhpDb\Adapter\Driver\StatementInterface;
-use PhpDb\Adapter\ParameterContainer;
use Psr\Container\ContainerInterface;
final class PdoStatementFactory
diff --git a/src/Container/PlatformInterfaceFactory.php b/src/Container/PlatformInterfaceFactory.php
index ba09cc5..32b8ebf 100644
--- a/src/Container/PlatformInterfaceFactory.php
+++ b/src/Container/PlatformInterfaceFactory.php
@@ -6,8 +6,8 @@
use PDO;
use PhpDb\Adapter\Driver\PdoDriverInterface;
-use PhpDb\Adapter\Sqlite\Platform\Sqlite;
use PhpDb\Adapter\Platform\PlatformInterface;
+use PhpDb\Adapter\Sqlite\Platform\Sqlite;
use PhpDb\Container\AdapterManager;
use Psr\Container\ContainerInterface;
diff --git a/src/Driver/Pdo/Connection.php b/src/Driver/Pdo/Connection.php
index d221b39..2c3fafd 100644
--- a/src/Driver/Pdo/Connection.php
+++ b/src/Driver/Pdo/Connection.php
@@ -5,6 +5,7 @@
namespace PhpDb\Adapter\Sqlite\Driver\Pdo;
use Override;
+use PDO;
use PDOException;
use PhpDb\Adapter\Driver\ConnectionInterface;
use PhpDb\Adapter\Driver\Pdo\AbstractPdoConnection;
@@ -12,6 +13,7 @@
use Webmozart\Assert\Assert;
use function array_diff_key;
+use function assert;
use function is_int;
use function is_string;
use function str_starts_with;
@@ -94,9 +96,11 @@ public function connect(): ConnectionInterface
$this->dsn = $dsn;
try {
- $this->resource = new \PDO(dsn: $dsn, options: $options);
- $this->resource->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
- $this->driverName = strtolower($this->resource->getAttribute(\PDO::ATTR_DRIVER_NAME));
+ $this->resource = new PDO(dsn: $dsn, options: $options);
+ $this->resource->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ $driverName = $this->resource->getAttribute(PDO::ATTR_DRIVER_NAME);
+ assert(is_string($driverName));
+ $this->driverName = strtolower($driverName);
} catch (PDOException $e) {
$code = $e->getCode();
if (! is_int($code)) {
diff --git a/src/Driver/Pdo/Pdo.php b/src/Driver/Pdo/Pdo.php
index ac7d1d1..e449816 100644
--- a/src/Driver/Pdo/Pdo.php
+++ b/src/Driver/Pdo/Pdo.php
@@ -13,7 +13,7 @@
use PhpDb\Adapter\Driver\ResultInterface;
use PhpDb\Adapter\Sqlite\Driver\DatabasePlatformNameTrait;
-final class Pdo extends AbstractPdo implements DriverFeatureProviderInterface
+class Pdo extends AbstractPdo implements DriverFeatureProviderInterface
{
use DatabasePlatformNameTrait;
use DriverFeatureProviderTrait;
diff --git a/src/Metadata/Source/SqliteMetadata.php b/src/Metadata/Source/SqliteMetadata.php
index 0d09a4e..3ff9f60 100644
--- a/src/Metadata/Source/SqliteMetadata.php
+++ b/src/Metadata/Source/SqliteMetadata.php
@@ -171,7 +171,7 @@ protected function loadConstraintData(string $table, string $schema): void
$id = $name = null;
foreach ($foreignKeys as $fk) {
if ($id !== $fk['id']) {
- $id = $fk['id'];
+ $id = $fk['id'];
// todo: decide on whether to continue to use _laminas_
$name = '_laminas_' . $table . '_FOREIGN_KEY_' . ($id + 1);
$constraints[$name] = [
diff --git a/src/Module.php b/src/Module.php
index e304815..8aed970 100644
--- a/src/Module.php
+++ b/src/Module.php
@@ -4,6 +4,9 @@
namespace PhpDb\Adapter\Sqlite;
+/**
+ * @psalm-api
+ */
final class Module
{
public function getConfig(): array
diff --git a/src/Platform/Sqlite.php b/src/Platform/Sqlite.php
index 0071fb1..f1afa4d 100644
--- a/src/Platform/Sqlite.php
+++ b/src/Platform/Sqlite.php
@@ -5,12 +5,11 @@
namespace PhpDb\Adapter\Sqlite\Platform;
use Override;
+use PDO;
use PhpDb\Adapter\Driver\PdoDriverInterface;
-use PhpDb\Adapter\Exception;
use PhpDb\Adapter\Platform\AbstractPlatform;
-use PhpDb\Sql\Platform\PlatformDecoratorInterface;
-use PhpDb\Adapter\Sqlite\Driver\Pdo;
use PhpDb\Adapter\Sqlite\Sql\Platform\Sqlite as SqlPlatformDecorator;
+use PhpDb\Sql\Platform\PlatformDecoratorInterface;
class Sqlite extends AbstractPlatform
{
@@ -18,7 +17,7 @@ class Sqlite extends AbstractPlatform
/** @var string[] */
protected $quoteIdentifier = ['"', '"'];
- /** @var \PDO */
+ /** @var PDO */
protected $resource;
/**
@@ -27,7 +26,7 @@ class Sqlite extends AbstractPlatform
protected $quoteIdentifierTo = '\'';
public function __construct(
- protected readonly PdoDriverInterface|\PDO $driver
+ protected readonly PdoDriverInterface|PDO $driver
) {
}
diff --git a/src/Sql/Platform/Ddl/AlterTableDecorator.php b/src/Sql/Platform/Ddl/AlterTableDecorator.php
index 1013bdd..568efea 100644
--- a/src/Sql/Platform/Ddl/AlterTableDecorator.php
+++ b/src/Sql/Platform/Ddl/AlterTableDecorator.php
@@ -4,6 +4,7 @@
use PhpDb\Adapter\Platform\PlatformInterface;
use PhpDb\Sql\Ddl\AlterTable;
+use PhpDb\Sql\Ddl\Column\ColumnInterface;
use PhpDb\Sql\Platform\PlatformDecoratorInterface;
use function count;
@@ -147,7 +148,7 @@ protected function processChangeColumns(?PlatformInterface $adapterPlatform = nu
{
$sqls = [];
- /** @var \PhpDb\Sql\Ddl\Column\ColumnInterface $column */
+ /** @var ColumnInterface $column */
foreach ($this->changeColumns as $name => $column) {
$sql = $this->processExpression($column, $adapterPlatform);
$insertStart = $this->getSqlInsertOffsets($sql);
@@ -217,6 +218,7 @@ private function normalizeColumnOption(string $name): string
/**
* phpcs:ignore SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedMethod
+ *
* @psalm-suppress UnusedReturnValue
*/
private function compareColumnOptions(string $columnA, string $columnB): int
diff --git a/src/Sql/Platform/Ddl/CreateTableDecorator.php b/src/Sql/Platform/Ddl/CreateTableDecorator.php
index ad1756f..8549803 100644
--- a/src/Sql/Platform/Ddl/CreateTableDecorator.php
+++ b/src/Sql/Platform/Ddl/CreateTableDecorator.php
@@ -18,9 +18,7 @@
final class CreateTableDecorator extends CreateTable implements PlatformDecoratorInterface
{
- /**
- * @psalm-suppress PossiblyUnusedProperty
- */
+ /** @psalm-suppress PossiblyUnusedProperty */
protected CreateTable $subject;
/** @var int[] */
@@ -158,6 +156,7 @@ private function normalizeColumnOption(string $name): string
/**
* phpcs:ignore SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedMethod
+ *
* @psalm-suppress UnusedReturnValue
*/
private function compareColumnOptions(string $columnA, string $columnB): int
diff --git a/test/integration/Container/TestAsset/SetupTrait.php b/test/integration/Container/TestAsset/SetupTrait.php
index 1acd229..7c02a3b 100644
--- a/test/integration/Container/TestAsset/SetupTrait.php
+++ b/test/integration/Container/TestAsset/SetupTrait.php
@@ -4,17 +4,17 @@
namespace PhpDbIntegrationTest\Adapter\Sqlite\Container\TestAsset;
-use Override;
use Laminas\ServiceManager\ServiceManager;
use Laminas\Stdlib\ArrayUtils;
+use Override;
use PhpDb\Adapter\AdapterInterface;
use PhpDb\Adapter\Driver\DriverInterface;
use PhpDb\Adapter\Sqlite\ConfigProvider;
use PhpDb\Adapter\Sqlite\Driver\Pdo\Pdo;
use PhpDb\Container\AdapterManager;
use PhpDb\Container\ConfigProvider as LaminasDbConfigProvider;
-use Psr\Container\ContainerInterface;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
+use Psr\Container\ContainerInterface;
/**
* This trait provides a setup method for integration tests that require
diff --git a/test/integration/Driver/Pdo/ConnectionIntegrationTest.php b/test/integration/Driver/Pdo/ConnectionIntegrationTest.php
index 7acc4c3..088a668 100644
--- a/test/integration/Driver/Pdo/ConnectionIntegrationTest.php
+++ b/test/integration/Driver/Pdo/ConnectionIntegrationTest.php
@@ -36,17 +36,6 @@ public function testGetCurrentSchema(): void
self::assertIsString($connection->getCurrentSchema());
}
- // public function testSetResource(): void
- // {
- // $resource = $this->getAdapter()->getDriver()->getConnection()->getResource();
- // $connection = new Connection([]);
- // self::assertSame($connection, $connection->setResource($resource));
-
- // $connection->disconnect();
- // unset($connection);
- // unset($resource);
- // }
-
public function testGetResource(): void
{
$connection = $this->getAdapter()->getDriver()->getConnection();
@@ -129,7 +118,7 @@ public function testGetLastGeneratedValue(): never
public function testConnectReturnsConnectionWhenResourceSet(): void
{
/** @var PDO $resource */
- $resource = $this->getAdapter()->getDriver()->getConnection()->getResource();
+ $resource = $this->getAdapter()->getDriver()->getConnection()->getResource();
/** @var PdoConnectionInterface&Connection $connection */
$connection = $this->getAdapter()->getDriver()->getConnection();
self::assertInstanceOf(PdoConnectionInterface::class, $connection);
diff --git a/test/integration/Driver/Pdo/StatementTest.php b/test/integration/Driver/Pdo/StatementTest.php
index ab73c02..5290b41 100644
--- a/test/integration/Driver/Pdo/StatementTest.php
+++ b/test/integration/Driver/Pdo/StatementTest.php
@@ -6,9 +6,9 @@
use PDO;
use PDOStatement;
-use PhpDb\Adapter\Driver\StatementInterface;
-use PhpDb\Adapter\Driver\Pdo\Statement;
use PhpDb\Adapter\Driver\Pdo\Result;
+use PhpDb\Adapter\Driver\Pdo\Statement;
+use PhpDb\Adapter\Driver\StatementInterface;
use PhpDbIntegrationTest\Adapter\Sqlite\Container\TestAsset\SetupTrait;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\TestCase;
@@ -29,7 +29,7 @@ final class StatementTest extends TestCase
public function testGetResource(): void
{
/** @var PDO $pdo */
- $pdo = $this->getAdapter()->getDriver()->getConnection()->getResource();
+ $pdo = $this->getAdapter()->getDriver()->getConnection()->getResource();
/** @var StatementInterface&Statement $statement */
$statement = $this->getAdapter()->getDriver()->createStatement();
/** @var PDOStatement $stmt */
diff --git a/test/unit/AdapterServiceFactoryTest.php b/test/unit/AdapterServiceFactoryTest.php
index 9b3e63f..4447585 100644
--- a/test/unit/AdapterServiceFactoryTest.php
+++ b/test/unit/AdapterServiceFactoryTest.php
@@ -2,20 +2,22 @@
namespace PhpDbTest\Adapter\Sqlite;
-use PhpDb\Adapter\Profiler\Profiler;
-use PhpDb\Adapter\Profiler\ProfilerInterface;
-use PhpDb\Adapter\Sqlite\Adapter;
-use PhpDb\Adapter\Sqlite\AdapterServiceFactory;
-use PhpDb\Adapter\Sqlite\ConfigProvider;
use Laminas\ServiceManager\ServiceLocatorInterface;
use Laminas\ServiceManager\ServiceManager;
use Override;
+use PhpDb\Adapter\Profiler\Profiler;
+use PhpDb\Adapter\Profiler\ProfilerInterface;
+use PhpDb\Adapter\Adapter;
+use PhpDb\Adapter\AdapterServiceFactory;
+use PhpDb\Adapter\Sqlite\ConfigProvider;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
+use function array_key_exists;
use function extension_loaded;
+use function is_array;
#[CoversMethod(AdapterServiceFactory::class, '__invoke')]
final class AdapterServiceFactoryTest extends TestCase
@@ -24,7 +26,7 @@ final class AdapterServiceFactoryTest extends TestCase
protected function createServiceManager(array $dbConfig): ServiceLocatorInterface
{
- $config = (new ConfigProvider())->getDependencies();
+ $config = (new ConfigProvider())->getDependencies();
if (array_key_exists('services', $config) && is_array($config['services'])) {
$config['services']['config'] = $dbConfig;
}
@@ -35,10 +37,6 @@ protected function createServiceManager(array $dbConfig): ServiceLocatorInterfac
#[Override]
protected function setUp(): void
{
- if (! extension_loaded('pdo_sqlite')) {
- $this->markTestSkipped('Adapter factory tests require pdo_sqlite');
- }
-
$this->factory = new AdapterServiceFactory();
}
diff --git a/test/unit/AdapterTest.php b/test/unit/AdapterTest.php
index 077b82c..749fef1 100644
--- a/test/unit/AdapterTest.php
+++ b/test/unit/AdapterTest.php
@@ -3,21 +3,22 @@
namespace PhpDbTest\Adapter\Sqlite;
use InvalidArgumentException;
+use Override;
use PhpDb\Adapter\AdapterInterface;
use PhpDb\Adapter\Driver\ConnectionInterface;
use PhpDb\Adapter\Driver\DriverInterface;
+use PhpDb\Adapter\Driver\PdoDriverInterface;
use PhpDb\Adapter\Driver\ResultInterface;
use PhpDb\Adapter\Driver\StatementInterface;
use PhpDb\Adapter\ParameterContainer;
use PhpDb\Adapter\Profiler;
-use PhpDb\ResultSet\ResultSet;
-use PhpDb\ResultSet\ResultSetInterface;
use PhpDb\Adapter\Sqlite\Adapter;
use PhpDb\Adapter\Sqlite\Driver\Pdo\Pdo;
use PhpDb\Adapter\Sqlite\Driver\Pdo\Statement;
use PhpDb\Adapter\Sqlite\Platform\Sqlite as SqlitePlatform;
+use PhpDb\ResultSet\ResultSet;
+use PhpDb\ResultSet\ResultSetInterface;
use PhpDbTest\Adapter\Sqlite\TestAsset\TemporaryResultSet;
-use Override;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\TestDox;
@@ -244,7 +245,7 @@ public function testMagicGet(): void
protected function setUp(): void
{
$this->mockConnection = $this->createMock(ConnectionInterface::class);
- $this->mockPlatform = new SqlitePlatform();
+ $this->mockPlatform = new SqlitePlatform($this->createMock(PdoDriverInterface::class));
$this->mockStatement = $this->getMockBuilder(Statement::class)->getMock();
$this->mockDriver = $this->getMockBuilder(Pdo::class)
->setConstructorArgs([
diff --git a/test/unit/ConfigProviderTest.php b/test/unit/ConfigProviderTest.php
index a73109f..9f1fffa 100644
--- a/test/unit/ConfigProviderTest.php
+++ b/test/unit/ConfigProviderTest.php
@@ -4,15 +4,16 @@
namespace PhpDbTest\Adapter\Sqlite;
+use Laminas\ServiceManager\Factory\InvokableFactory;
use PhpDb\Adapter\AdapterInterface;
-use PhpDb\Adapter\Driver\DriverInterface;
use PhpDb\Adapter\Driver\ConnectionInterface;
+use PhpDb\Adapter\Driver\DriverInterface;
+use PhpDb\Adapter\Driver\Pdo\Result;
+use PhpDb\Adapter\Driver\Pdo\Statement;
use PhpDb\Adapter\Driver\PdoConnectionInterface;
use PhpDb\Adapter\Driver\PdoDriverInterface;
use PhpDb\Adapter\Driver\ResultInterface;
use PhpDb\Adapter\Driver\StatementInterface;
-use PhpDb\Adapter\Driver\Pdo\Result;
-use PhpDb\Adapter\Driver\Pdo\Statement;
use PhpDb\Adapter\Platform\PlatformInterface;
use PhpDb\Adapter\Profiler\Profiler;
use PhpDb\Adapter\Profiler\ProfilerInterface;
@@ -24,7 +25,6 @@
use PhpDb\Container\AdapterManager;
use PhpDb\Metadata\MetadataInterface;
use PhpDb\ResultSet;
-use Laminas\ServiceManager\Factory\InvokableFactory;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;
@@ -34,12 +34,12 @@
#[CoversMethod(ConfigProvider::class, 'getAdapterManagerConfig')]
final class ConfigProviderTest extends TestCase
{
- /** @var array> */
+ /** @var array>> */
private array $config = [
- 'aliases' => [
+ 'aliases' => [
MetadataInterface::class => Metadata\Source\SqliteMetadata::class,
],
- 'factories' => [
+ 'factories' => [
Metadata\Source\SqliteMetadata::class => Container\MetadataInterfaceFactory::class,
],
'delegators' => [
@@ -76,7 +76,7 @@ final class ConfigProviderTest extends TestCase
Statement::class => Container\PdoStatementFactory::class,
Platform\Sqlite::class => Container\PlatformInterfaceFactory::class,
//Profiler::class => InvokableFactory::class,
- ResultSet\ResultSet::class => InvokableFactory::class,
+ ResultSet\ResultSet::class => InvokableFactory::class,
],
];
@@ -91,7 +91,10 @@ public function testProvidesExpectedDependencies(): ConfigProvider
public function testProvidesExpectedAdapterManagerConfiguration(): void
{
$provider = new ConfigProvider();
- self::assertEquals($this->adapterManagerConfig, $provider->getAdapterManagerConfig());
+ self::assertEquals(
+ $this->adapterManagerConfig,
+ $provider->getAdapterManagerConfig()
+ );
}
#[Depends('testProvidesExpectedDependencies')]
diff --git a/test/unit/Driver/Pdo/ConnectionTest.php b/test/unit/Driver/Pdo/ConnectionTest.php
index 4e135f5..3fd2866 100644
--- a/test/unit/Driver/Pdo/ConnectionTest.php
+++ b/test/unit/Driver/Pdo/ConnectionTest.php
@@ -5,9 +5,9 @@
namespace PhpDbTest\Adapter\Sqlite\Sqlite\Driver\Pdo;
use Exception;
+use Override;
use PhpDb\Adapter\Exception\InvalidConnectionParametersException;
use PhpDb\Adapter\Sqlite\Driver\Pdo\Connection;
-use Override;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
diff --git a/test/unit/Driver/Pdo/ConnectionTransactionsTest.php b/test/unit/Driver/Pdo/ConnectionTransactionsTest.php
index 4c7ca1f..9980060 100644
--- a/test/unit/Driver/Pdo/ConnectionTransactionsTest.php
+++ b/test/unit/Driver/Pdo/ConnectionTransactionsTest.php
@@ -4,11 +4,11 @@
namespace PhpDbTest\Adapter\Sqlite\Driver\Pdo;
+use Override;
use PhpDb\Adapter\Driver\AbstractConnection;
use PhpDb\Adapter\Exception\RuntimeException;
use PhpDb\Adapter\Sqlite\Driver\Pdo\Connection;
use PhpDbTest\Adapter\Sqlite\TestAsset\ConnectionWrapper;
-use Override;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\TestCase;
diff --git a/test/unit/Driver/Pdo/PdoTest.php b/test/unit/Driver/Pdo/PdoTest.php
index 7fabbb4..97f7259 100644
--- a/test/unit/Driver/Pdo/PdoTest.php
+++ b/test/unit/Driver/Pdo/PdoTest.php
@@ -5,11 +5,14 @@
namespace PhpDbTest\Adapter\Sqlite\Sqlite\Driver\Pdo;
use Override;
-use PhpDb\Adapter\Driver\PdoDriverInterface;
use PhpDb\Adapter\Driver\Pdo\Result;
-use PhpDb\Exception\RuntimeException;
+use PhpDb\Adapter\Driver\PdoDriverAwareInterface;
+use PhpDb\Adapter\Driver\PdoDriverInterface;
+use PhpDb\Adapter\Driver\ResultInterface;
+use PhpDb\Adapter\Driver\StatementInterface;
use PhpDb\Adapter\Sqlite\Driver\Pdo\Connection;
use PhpDb\Adapter\Sqlite\Driver\Pdo\Pdo;
+use PhpDb\Exception\RuntimeException;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
@@ -29,7 +32,17 @@ protected function setUp(): void
{
$connection = new Connection();
- $this->pdo = new Pdo($connection);
+ /** @var StatementInterface&PdoDriverAwareInterface $statementPrototype */
+ $statementPrototype = $this->createMockForIntersectionOfInterfaces([
+ StatementInterface::class,
+ PdoDriverAwareInterface::class,
+ ]);
+
+ $this->pdo = new Pdo(
+ $connection,
+ $statementPrototype,
+ $this->createMock(ResultInterface::class),
+ );
}
public function testGetDatabasePlatformName(): void
diff --git a/test/unit/Driver/Pdo/ResultTest.php b/test/unit/Driver/Pdo/ResultTest.php
index 263d3fb..bc0d1e6 100644
--- a/test/unit/Driver/Pdo/ResultTest.php
+++ b/test/unit/Driver/Pdo/ResultTest.php
@@ -4,16 +4,15 @@
namespace PhpDbTest\Adapter\Sqlite\Sqlite\Driver\Pdo;
-use PhpDb\Adapter\Driver\Pdo\Result;
-use PhpDb\Adapter\Exception\InvalidArgumentException;
use PDO;
use PDOStatement;
+use PhpDb\Adapter\Driver\Pdo\Result;
+use PhpDb\Adapter\Exception\InvalidArgumentException;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use stdClass;
-use function assert;
use function uniqid;
#[CoversMethod(Result::class, 'current')]
diff --git a/test/unit/Driver/Pdo/StatementTest.php b/test/unit/Driver/Pdo/StatementTest.php
index ccf0951..51efe0d 100644
--- a/test/unit/Driver/Pdo/StatementTest.php
+++ b/test/unit/Driver/Pdo/StatementTest.php
@@ -4,13 +4,14 @@
namespace PhpDbTest\Adapter\Sqlite\Sqlite\Driver\Pdo;
+use Override;
use PhpDb\Adapter\Driver\Pdo\Statement;
use PhpDb\Adapter\ParameterContainer;
+use PhpDb\Adapter\Sqlite\Container\PdoDriverFactory;
use PhpDb\Adapter\Sqlite\Driver\Pdo\Connection;
-use PhpDb\Adapter\Sqlite\Driver\Pdo\Pdo;
-use Override;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\TestCase;
+use Psr\Container\ContainerInterface;
#[CoversMethod(Statement::class, 'setDriver')]
#[CoversMethod(Statement::class, 'setParameterContainer')]
@@ -27,7 +28,14 @@ final class StatementTest extends TestCase
public function testSetDriver(): void
{
- self::assertEquals($this->statement, $this->statement->setDriver(new Driver(new Connection())));
+ self::assertEquals(
+ $this->statement,
+ $this->statement->setDriver(
+ (new PdoDriverFactory())->__invoke(
+ $this->createMock(ContainerInterface::class)
+ )
+ )
+ );
}
public function testSetParameterContainer(): void
diff --git a/test/unit/Platform/SqliteTest.php b/test/unit/Platform/SqliteTest.php
index 8053a11..e8da3a0 100644
--- a/test/unit/Platform/SqliteTest.php
+++ b/test/unit/Platform/SqliteTest.php
@@ -2,15 +2,16 @@
namespace PhpDbTest\Adapter\Sqlite\Sqlite\Platform;
+use Override;
+use PDO;
+use PhpDb\Adapter\Sqlite\Container\PdoDriverFactory;
use PhpDb\Adapter\Sqlite\Driver\Pdo\Connection;
-use PhpDb\Adapter\Sqlite\Driver\Pdo\Pdo;
use PhpDb\Adapter\Sqlite\Platform\Sqlite;
-use Override;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\TestCase;
+use Psr\Container\ContainerInterface;
use function file_exists;
-use function realpath;
use function restore_error_handler;
use function set_error_handler;
use function touch;
@@ -39,7 +40,9 @@ final class SqliteTest extends TestCase
#[Override]
protected function setUp(): void
{
- $this->platform = new Sqlite();
+ $this->platform = new Sqlite(new PDO(
+ dsn: "sqlite::memory:mydb.sqlite",
+ ));
}
public function testGetName(): void
@@ -72,10 +75,15 @@ public function testGetQuoteValueSymbol(): void
public function testQuoteValueRaisesNoticeWithoutPlatformSupport(): void
{
$raisedNotice = false;
- set_error_handler(function ($errno, $errstr) use (&$raisedNotice) {
+
+ /**
+ * @psalm-suppress InvalidArgument
+ */
+ set_error_handler(function (int $errno, string $errstr) use (&$raisedNotice) {
$this->assertEquals(E_USER_NOTICE, $errno);
$this->assertEquals(
$errstr,
+ // phpcs:ignore Generic.Files.LineLength
'Attempting to quote a value in PhpDb\Adapter\Sqlite\Platform\Sqlite without extension/driver support can '
. 'introduce security vulnerabilities in a production environment'
);
@@ -121,10 +129,15 @@ public function testQuoteTrustedValue(): void
public function testQuoteValueList(): void
{
$raisedNotice = false;
+
+ /**
+ * @psalm-suppress InvalidArgument
+ */
set_error_handler(function ($errno, $errstr) use (&$raisedNotice) {
$this->assertEquals(E_USER_NOTICE, $errno);
$this->assertEquals(
$errstr,
+ // phpcs:ignore Generic.Files.LineLength
'Attempting to quote a value in PhpDb\Adapter\Sqlite\Platform\Sqlite without extension/driver support can '
. 'introduce security vulnerabilities in a production environment'
);
@@ -180,10 +193,9 @@ public function testCanCloseConnectionAfterQuoteValue(): void
touch($filePath);
}
- $driver = new Driver(new Connection([
- 'driver' => 'Pdo_Sqlite',
- 'database' => ':memory',
- ]));
+ $driver = (new PdoDriverFactory())->__invoke(
+ $this->createMock(ContainerInterface::class)
+ );
$this->platform->setDriver($driver);
$this->platform->quoteValue("some; random]/ value");
diff --git a/test/unit/Sql/Platform/SelectDecoratorTest.php b/test/unit/Sql/Platform/SelectDecoratorTest.php
index b93cf03..a0fd91b 100644
--- a/test/unit/Sql/Platform/SelectDecoratorTest.php
+++ b/test/unit/Sql/Platform/SelectDecoratorTest.php
@@ -27,7 +27,6 @@ final class SelectDecoratorTest extends TestCase
protected function setUp(): void
{
-
$this->driver = $this->getMockBuilder(PdoDriverInterface::class)
->getMock();
diff --git a/test/unit/Sql/Platform/SqliteTest.php b/test/unit/Sql/Platform/SqliteTest.php
index e51828f..61feae8 100644
--- a/test/unit/Sql/Platform/SqliteTest.php
+++ b/test/unit/Sql/Platform/SqliteTest.php
@@ -2,9 +2,9 @@
namespace PhpDbTest\Adapter\Sqlite\Sql\Platform;
-use PhpDb\Sql\Select;
use PhpDb\Adapter\Sqlite\Sql\Platform\SelectDecorator;
use PhpDb\Adapter\Sqlite\Sql\Platform\Sqlite;
+use PhpDb\Sql\Select;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;