diff --git a/composer.lock b/composer.lock index bef44a6..dd6fdc6 100644 --- a/composer.lock +++ b/composer.lock @@ -57,16 +57,16 @@ }, { "name": "laminas/laminas-servicemanager", - "version": "4.5.0", + "version": "4.5.1", "source": { "type": "git", "url": "https://github.com/laminas/laminas-servicemanager.git", - "reference": "a6996829c8ce55025cca1b57b1e8a8b165e3926c" + "reference": "11192d588876ad04ba2988984c77b4ecb5c771c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/a6996829c8ce55025cca1b57b1e8a8b165e3926c", - "reference": "a6996829c8ce55025cca1b57b1e8a8b165e3926c", + "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/11192d588876ad04ba2988984c77b4ecb5c771c2", + "reference": "11192d588876ad04ba2988984c77b4ecb5c771c2", "shasum": "" }, "require": { @@ -130,7 +130,7 @@ "chat": "https://laminas.dev/chat", "forum": "https://discourse.laminas.dev", "issues": "https://github.com/laminas/laminas-servicemanager/issues", - "source": "https://github.com/laminas/laminas-servicemanager/tree/4.5.0" + "source": "https://github.com/laminas/laminas-servicemanager/tree/4.5.1" }, "funding": [ { @@ -138,7 +138,7 @@ "type": "community_bridge" } ], - "time": "2025-10-14T09:41:04+00:00" + "time": "2026-05-12T09:53:32+00:00" }, { "name": "laminas/laminas-stdlib", @@ -263,12 +263,12 @@ "source": { "type": "git", "url": "https://github.com/php-db/phpdb.git", - "reference": "003ff3440af8d2b51c6f190f1d256f5185b84819" + "reference": "81844a5699bf397bf044bbe36ea90be361b4a021" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-db/phpdb/zipball/003ff3440af8d2b51c6f190f1d256f5185b84819", - "reference": "003ff3440af8d2b51c6f190f1d256f5185b84819", + "url": "https://api.github.com/repos/php-db/phpdb/zipball/81844a5699bf397bf044bbe36ea90be361b4a021", + "reference": "81844a5699bf397bf044bbe36ea90be361b4a021", "shasum": "" }, "require": { @@ -324,7 +324,7 @@ "issues": "https://github.com/php-db/phpdb/issues", "source": "https://github.com/php-db/phpdb" }, - "time": "2026-01-25T20:41:58+00:00" + "time": "2026-04-13T01:24:01+00:00" }, { "name": "psr/container", @@ -381,16 +381,16 @@ }, { "name": "webmozart/assert", - "version": "2.1.2", + "version": "2.3.0", "source": { "type": "git", "url": "https://github.com/webmozarts/assert.git", - "reference": "ce6a2f100c404b2d32a1dd1270f9b59ad4f57649" + "reference": "eb0d790f735ba6cff25c683a85a1da0eadeff9e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/ce6a2f100c404b2d32a1dd1270f9b59ad4f57649", - "reference": "ce6a2f100c404b2d32a1dd1270f9b59ad4f57649", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/eb0d790f735ba6cff25c683a85a1da0eadeff9e4", + "reference": "eb0d790f735ba6cff25c683a85a1da0eadeff9e4", "shasum": "" }, "require": { @@ -437,24 +437,24 @@ ], "support": { "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/2.1.2" + "source": "https://github.com/webmozarts/assert/tree/2.3.0" }, - "time": "2026-01-13T14:02:24+00:00" + "time": "2026-04-11T10:33:05+00:00" } ], "packages-dev": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v1.2.0", + "version": "v1.2.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/composer-installer.git", - "reference": "845eb62303d2ca9b289ef216356568ccc075ffd1" + "reference": "963f0c67bffde0eac41b56be71ac0e8ba132f0bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/845eb62303d2ca9b289ef216356568ccc075ffd1", - "reference": "845eb62303d2ca9b289ef216356568ccc075ffd1", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/963f0c67bffde0eac41b56be71ac0e8ba132f0bd", + "reference": "963f0c67bffde0eac41b56be71ac0e8ba132f0bd", "shasum": "" }, "require": { @@ -537,7 +537,7 @@ "type": "thanks_dev" } ], - "time": "2025-11-11T04:32:07+00:00" + "time": "2026-05-06T08:26:05+00:00" }, { "name": "laminas/laminas-coding-standard", @@ -819,11 +819,11 @@ }, { "name": "phpstan/phpstan", - "version": "2.1.38", + "version": "2.1.55", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dfaf1f530e1663aa167bc3e52197adb221582629", - "reference": "dfaf1f530e1663aa167bc3e52197adb221582629", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/9eaac3826ed5e9b8427350a43cac825eeca3f566", + "reference": "9eaac3826ed5e9b8427350a43cac825eeca3f566", "shasum": "" }, "require": { @@ -868,20 +868,20 @@ "type": "github" } ], - "time": "2026-01-30T17:12:46+00:00" + "time": "2026-05-18T11:57:34+00:00" }, { "name": "phpstan/phpstan-phpunit", - "version": "2.0.12", + "version": "2.0.16", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan-phpunit.git", - "reference": "e4c5a22bf43d3d2bd5a780ad261a622ff62c49a4" + "reference": "6ab598e1bc106e6827fd346ae4a12b4a5d634c32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/e4c5a22bf43d3d2bd5a780ad261a622ff62c49a4", - "reference": "e4c5a22bf43d3d2bd5a780ad261a622ff62c49a4", + "url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/6ab598e1bc106e6827fd346ae4a12b4a5d634c32", + "reference": "6ab598e1bc106e6827fd346ae4a12b4a5d634c32", "shasum": "" }, "require": { @@ -917,11 +917,14 @@ "MIT" ], "description": "PHPUnit extensions and rules for PHPStan", + "keywords": [ + "static analysis" + ], "support": { "issues": "https://github.com/phpstan/phpstan-phpunit/issues", - "source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.12" + "source": "https://github.com/phpstan/phpstan-phpunit/tree/2.0.16" }, - "time": "2026-01-22T13:40:00+00:00" + "time": "2026-02-14T09:05:21+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1015,28 +1018,28 @@ }, { "name": "phpunit/php-file-iterator", - "version": "5.1.0", + "version": "5.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "118cfaaa8bc5aef3287bf315b6060b1174754af6" + "reference": "2f3a64888c814fc235386b7387dd5b5ed92ad903" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/118cfaaa8bc5aef3287bf315b6060b1174754af6", - "reference": "118cfaaa8bc5aef3287bf315b6060b1174754af6", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/2f3a64888c814fc235386b7387dd5b5ed92ad903", + "reference": "2f3a64888c814fc235386b7387dd5b5ed92ad903", "shasum": "" }, "require": { "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^11.0" + "phpunit/phpunit": "^11.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -1064,15 +1067,27 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/5.1.0" + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/5.1.1" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/php-file-iterator", + "type": "tidelift" } ], - "time": "2024-08-27T05:02:59+00:00" + "time": "2026-02-02T13:52:54+00:00" }, { "name": "phpunit/php-invoker", @@ -1260,16 +1275,16 @@ }, { "name": "phpunit/phpunit", - "version": "11.5.50", + "version": "11.5.55", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "fdfc727f0fcacfeb8fcb30c7e5da173125b58be3" + "reference": "adc7262fccc12de2b30f12a8aa0b33775d814f00" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fdfc727f0fcacfeb8fcb30c7e5da173125b58be3", - "reference": "fdfc727f0fcacfeb8fcb30c7e5da173125b58be3", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/adc7262fccc12de2b30f12a8aa0b33775d814f00", + "reference": "adc7262fccc12de2b30f12a8aa0b33775d814f00", "shasum": "" }, "require": { @@ -1284,7 +1299,7 @@ "phar-io/version": "^3.2.1", "php": ">=8.2", "phpunit/php-code-coverage": "^11.0.12", - "phpunit/php-file-iterator": "^5.1.0", + "phpunit/php-file-iterator": "^5.1.1", "phpunit/php-invoker": "^5.0.1", "phpunit/php-text-template": "^4.0.1", "phpunit/php-timer": "^7.0.1", @@ -1296,6 +1311,7 @@ "sebastian/exporter": "^6.3.2", "sebastian/global-state": "^7.0.2", "sebastian/object-enumerator": "^6.0.1", + "sebastian/recursion-context": "^6.0.3", "sebastian/type": "^5.1.3", "sebastian/version": "^5.0.2", "staabm/side-effects-detector": "^1.0.5" @@ -1341,7 +1357,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.50" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.55" }, "funding": [ { @@ -1365,7 +1381,7 @@ "type": "tidelift" } ], - "time": "2026-01-27T05:59:18+00:00" + "time": "2026-02-18T12:37:06+00:00" }, { "name": "sebastian/cli-parser", diff --git a/src/Container/MetadataInterfaceFactory.php b/src/Container/MetadataInterfaceFactory.php index 0a832ef..bd4f615 100644 --- a/src/Container/MetadataInterfaceFactory.php +++ b/src/Container/MetadataInterfaceFactory.php @@ -5,20 +5,20 @@ namespace PhpDb\Sqlite\Container; use PhpDb\Adapter\AdapterInterface; -use PhpDb\Adapter\SchemaAwareInterface; use PhpDb\Metadata\MetadataInterface; use PhpDb\Sqlite\Metadata; use Psr\Container\ContainerInterface; final class MetadataInterfaceFactory { - public function __invoke(ContainerInterface $container): MetadataInterface&Metadata\Source - { - /** @var AdapterInterface&SchemaAwareInterface $adapter */ - $adapter = $container->get(AdapterInterface::class); + public const ADAPTER_SERVICE_NAME = 'adapter_service_name'; + public function __invoke( + ContainerInterface $container, + string $requestedName, + ?array $options = null + ): MetadataInterface&Metadata\Source { + $adapterServiceName = $options[self::ADAPTER_SERVICE_NAME] ?? AdapterInterface::class; - return new Metadata\Source( - $adapter - ); + return new Metadata\Source($container->get($adapterServiceName)); } } diff --git a/src/Container/PdoConnectionFactory.php b/src/Container/PdoConnectionFactory.php index 696d7b6..7957e26 100644 --- a/src/Container/PdoConnectionFactory.php +++ b/src/Container/PdoConnectionFactory.php @@ -4,24 +4,28 @@ namespace PhpDb\Sqlite\Container; -use PhpDb\Adapter\AdapterInterface; -use PhpDb\Adapter\Driver\ConnectionInterface; +use PhpDb\Adapter\Driver\PdoConnectionInterface; +use PhpDb\Adapter\Exception\InvalidConnectionParametersException; use PhpDb\Sqlite\Pdo\Connection; use Psr\Container\ContainerInterface; +use function is_array; + final class PdoConnectionFactory { - public function __invoke(ContainerInterface $container): ConnectionInterface&Connection - { - /** @var array $config */ - $config = $container->get('config'); - - /** @var array $dbConfig */ - $dbConfig = $config[AdapterInterface::class] ?? []; - - /** @var array $connectionConfig */ - $connectionConfig = $dbConfig['connection'] ?? []; + public function __invoke( + ContainerInterface $container, + string $requestedName, + ?array $options = null + ): PdoConnectionInterface&Connection { + $conn = $options['connection'] ?? []; + if (! is_array($conn) || $conn === []) { + throw new InvalidConnectionParametersException( + 'Connection configuration must be an array of parameters passed via $options["connection"]', + $conn + ); + } - return new Connection($connectionConfig); + return new Connection($conn); } } diff --git a/src/Container/PdoDriverInterfaceFactory.php b/src/Container/PdoDriverInterfaceFactory.php index 824b5a2..f32715b 100644 --- a/src/Container/PdoDriverInterfaceFactory.php +++ b/src/Container/PdoDriverInterfaceFactory.php @@ -19,18 +19,10 @@ public function __invoke( string $requestedName, ?array $options = null ): PdoDriverInterface&Pdo\Driver { - // if (! $container->has('config')) { - // throw ContainerException::forService( - // Pdo\Driver::class, - // self::class, - // 'Container is missing config service' - // ); - // } - /** @var Pdo\Connection $connectionInstance */ $connectionInstance = $container->build( Pdo\Connection::class, - ['connection' => $options['connection'] ?? []] + $options ); /** @var ResultInterface&Result $resultInstance */ diff --git a/src/Container/PdoStatementFactory.php b/src/Container/PdoStatementFactory.php index 1f7f7ee..270fea3 100644 --- a/src/Container/PdoStatementFactory.php +++ b/src/Container/PdoStatementFactory.php @@ -10,17 +10,11 @@ final class PdoStatementFactory { - public function __invoke(ContainerInterface $container): StatementInterface&Statement - { - /** @var array $config */ - $config = $container->get('config'); - - /** @var array $dbConfig */ - $dbConfig = $config['db'] ?? []; - - /** @var array $options */ - $options = $dbConfig['options'] ?? []; - + public function __invoke( + ContainerInterface $container, + string $requestedName, + ?array $options = null + ): StatementInterface&Statement { return new Statement(options: $options); } } diff --git a/src/DatabasePlatformNameTrait.php b/src/DatabasePlatformNameTrait.php deleted file mode 100644 index 8c650e4..0000000 --- a/src/DatabasePlatformNameTrait.php +++ /dev/null @@ -1,33 +0,0 @@ -setConnectionParameters($connectionParameters); + } elseif ($connectionParameters instanceof PDO) { + $this->setResource($connectionParameters); + } + } + /** * {@inheritDoc} */ diff --git a/src/Pdo/Driver.php b/src/Pdo/Driver.php index 45dd5a0..793dfd6 100644 --- a/src/Pdo/Driver.php +++ b/src/Pdo/Driver.php @@ -5,20 +5,44 @@ namespace PhpDb\Sqlite\Pdo; use Override; +use PDO; use PDOStatement; use PhpDb\Adapter\Driver\Feature\DriverFeatureProviderInterface; use PhpDb\Adapter\Driver\Feature\DriverFeatureProviderTrait; use PhpDb\Adapter\Driver\Pdo\AbstractPdo; use PhpDb\Adapter\Driver\Pdo\Result; use PhpDb\Adapter\Driver\Pdo\Statement; +use PhpDb\Adapter\Driver\PdoConnectionInterface; +use PhpDb\Adapter\Driver\PdoDriverAwareInterface; use PhpDb\Adapter\Driver\ResultInterface; -use PhpDb\Sqlite\DatabasePlatformNameTrait; +use PhpDb\Adapter\Driver\StatementInterface; class Driver extends AbstractPdo implements DriverFeatureProviderInterface { - use DatabasePlatformNameTrait; use DriverFeatureProviderTrait; + public function __construct( + (PdoConnectionInterface&PdoDriverAwareInterface)|PDO $connection, + (StatementInterface&PdoDriverAwareInterface)|Statement $statementPrototype = new Statement(), + ResultInterface $resultPrototype = new Result(), + array $features = [], + ) { + $this->connection = $connection; + $this->statementPrototype = $statementPrototype; + $this->resultPrototype = $resultPrototype; + + if (! $this->connection instanceof PDO) { + $this->connection->setDriver($this); + } + + $this->statementPrototype->setDriver($this); + + // $features is not constructor promoted because $this->features is defined in the trait + if ($features !== []) { + $this->addFeatures($features); + } + } + /** * @param PDOStatement|resource $resource */ diff --git a/test/integration/Container/PdoConnectionFactoryTest.php b/test/integration/Container/PdoConnectionFactoryTest.php index 40bbfd4..55232ed 100644 --- a/test/integration/Container/PdoConnectionFactoryTest.php +++ b/test/integration/Container/PdoConnectionFactoryTest.php @@ -24,7 +24,7 @@ final class PdoConnectionFactoryTest extends TestCase public function testInvokeReturnsPdoConnection(): void { $factory = new PdoConnectionFactory(); - $instance = $factory($this->container); + $instance = $factory($this->container, Connection::class, ['connection' => ['dsn' => 'sqlite::memory:']]); self::assertInstanceOf(ConnectionInterface::class, $instance); self::assertInstanceOf(PdoConnectionInterface::class, $instance); self::assertInstanceOf(Connection::class, $instance); diff --git a/test/integration/Container/PdoStatementFactoryTest.php b/test/integration/Container/PdoStatementFactoryTest.php index d0734da..2cfa0c0 100644 --- a/test/integration/Container/PdoStatementFactoryTest.php +++ b/test/integration/Container/PdoStatementFactoryTest.php @@ -23,7 +23,7 @@ final class PdoStatementFactoryTest extends TestCase public function testInvokeReturnsPdoStatement(): void { $factory = new PdoStatementFactory(); - $statement = $factory($this->container); + $statement = $factory($this->container, Statement::class, []); self::assertInstanceOf(StatementInterface::class, $statement); self::assertInstanceOf(Statement::class, $statement); } diff --git a/test/integration/Container/SqliteMetadataFactoryTest.php b/test/integration/Container/SqliteMetadataFactoryTest.php index 97364c1..eee3d69 100644 --- a/test/integration/Container/SqliteMetadataFactoryTest.php +++ b/test/integration/Container/SqliteMetadataFactoryTest.php @@ -20,7 +20,7 @@ final class SqliteMetadataFactoryTest extends TestCase public function testFactoryReturnsMysqlMetadata(): void { $factory = new MetadataInterfaceFactory(); - $metadata = $factory($this->container); + $metadata = $factory($this->container, Metadata\Source::class); self::assertInstanceOf(MetadataInterface::class, $metadata); self::assertInstanceOf(Metadata\Source::class, $metadata); } diff --git a/test/unit/Container/MetadataInterfaceFactoryTest.php b/test/unit/Container/MetadataInterfaceFactoryTest.php index 44cd42c..a29f3a1 100644 --- a/test/unit/Container/MetadataInterfaceFactoryTest.php +++ b/test/unit/Container/MetadataInterfaceFactoryTest.php @@ -33,7 +33,7 @@ public function testInvokeReturnsMetadata(): void ->willReturn($adapterMock); $factory = new MetadataInterfaceFactory(); - $metadata = $factory($containerMock); + $metadata = $factory($containerMock, Metadata\Source::class); self::assertInstanceOf(Metadata\Source::class, $metadata); } diff --git a/test/unit/Container/PdoConnectionFactoryTest.php b/test/unit/Container/PdoConnectionFactoryTest.php index cff7b5d..7da08cb 100644 --- a/test/unit/Container/PdoConnectionFactoryTest.php +++ b/test/unit/Container/PdoConnectionFactoryTest.php @@ -4,6 +4,7 @@ namespace PhpDbTest\Sqlite\Container; +use PhpDb\Adapter\Exception\InvalidConnectionParametersException; use PhpDb\Sqlite\Container\PdoConnectionFactory; use PhpDb\Sqlite\Pdo\Connection; use PHPUnit\Framework\Attributes\CoversClass; @@ -16,47 +17,30 @@ final class PdoConnectionFactoryTest extends TestCase public function testInvokeReturnsConnection(): void { $containerMock = $this->createMock(ContainerInterface::class); - $containerMock->method('get') - ->with('config') - ->willReturn([ - 'db' => [ - 'connection' => [ - 'dsn' => 'sqlite::memory:', - ], - ], - ]); $factory = new PdoConnectionFactory(); - $connection = $factory($containerMock); + $connection = $factory($containerMock, Connection::class, ['connection' => ['dsn' => 'sqlite::memory:']]); self::assertInstanceOf(Connection::class, $connection); } - public function testInvokeWithoutConnectionConfig(): void + public function testInvokeWithoutConnectionConfigThrows(): void { $containerMock = $this->createMock(ContainerInterface::class); - $containerMock->method('get') - ->with('config') - ->willReturn([ - 'db' => [], - ]); - $factory = new PdoConnectionFactory(); - $connection = $factory($containerMock); + $this->expectException(InvalidConnectionParametersException::class); - self::assertInstanceOf(Connection::class, $connection); + $factory = new PdoConnectionFactory(); + $factory($containerMock, Connection::class, []); } - public function testInvokeWithoutDbConfig(): void + public function testInvokeWithNullOptionsThrows(): void { $containerMock = $this->createMock(ContainerInterface::class); - $containerMock->method('get') - ->with('config') - ->willReturn([]); - $factory = new PdoConnectionFactory(); - $connection = $factory($containerMock); + $this->expectException(InvalidConnectionParametersException::class); - self::assertInstanceOf(Connection::class, $connection); + $factory = new PdoConnectionFactory(); + $factory($containerMock, Connection::class, null); } } diff --git a/test/unit/Container/PdoStatementFactoryTest.php b/test/unit/Container/PdoStatementFactoryTest.php index e8460d1..4c11e5e 100644 --- a/test/unit/Container/PdoStatementFactoryTest.php +++ b/test/unit/Container/PdoStatementFactoryTest.php @@ -13,47 +13,22 @@ #[CoversClass(PdoStatementFactory::class)] final class PdoStatementFactoryTest extends TestCase { - public function testInvokeReturnsStatement(): void + public function testInvokeReturnsStatementWithOptions(): void { $containerMock = $this->createMock(ContainerInterface::class); - $containerMock->method('get') - ->with('config') - ->willReturn([ - 'db' => [ - 'options' => [], - ], - ]); $factory = new PdoStatementFactory(); - $statement = $factory($containerMock); + $statement = $factory($containerMock, Statement::class, ['key' => 'value']); self::assertInstanceOf(Statement::class, $statement); } - public function testInvokeWithoutOptionsConfig(): void + public function testInvokeReturnsStatementWithEmptyOptions(): void { $containerMock = $this->createMock(ContainerInterface::class); - $containerMock->method('get') - ->with('config') - ->willReturn([ - 'db' => [], - ]); $factory = new PdoStatementFactory(); - $statement = $factory($containerMock); - - self::assertInstanceOf(Statement::class, $statement); - } - - public function testInvokeWithoutDbConfig(): void - { - $containerMock = $this->createMock(ContainerInterface::class); - $containerMock->method('get') - ->with('config') - ->willReturn([]); - - $factory = new PdoStatementFactory(); - $statement = $factory($containerMock); + $statement = $factory($containerMock, Statement::class, []); self::assertInstanceOf(Statement::class, $statement); } diff --git a/test/unit/DatabasePlatformNameTraitTest.php b/test/unit/DatabasePlatformNameTraitTest.php deleted file mode 100644 index d632e54..0000000 --- a/test/unit/DatabasePlatformNameTraitTest.php +++ /dev/null @@ -1,53 +0,0 @@ -traitObject = new class { - use DatabasePlatformNameTrait; - }; - } - - public function testGetDatabasePlatformNameWithCamelCaseFormat(): void - { - $result = $this->traitObject->getDatabasePlatformName(DriverInterface::NAME_FORMAT_CAMELCASE); - - self::assertSame('Sqlite', $result); - } - - public function testGetDatabasePlatformNameWithNaturalFormat(): void - { - $result = $this->traitObject->getDatabasePlatformName(DriverInterface::NAME_FORMAT_NATURAL); - - self::assertSame('SQLite', $result); - } - - public function testGetDatabasePlatformNameWithInvalidFormatThrowsException(): void - { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid name format provided'); - - $this->traitObject->getDatabasePlatformName('INVALID_FORMAT'); - } - - public function testGetDatabasePlatformNameDefaultsToCamelCase(): void - { - $result = $this->traitObject->getDatabasePlatformName(); - - self::assertSame('Sqlite', $result); - } -} diff --git a/test/unit/Pdo/DriverTest.php b/test/unit/Pdo/DriverTest.php index 36d9311..fb0fcc9 100644 --- a/test/unit/Pdo/DriverTest.php +++ b/test/unit/Pdo/DriverTest.php @@ -44,13 +44,6 @@ protected function setUp(): void ); } - public function testGetDatabasePlatformName(): void - { - $this->pdo->getConnection()->setConnectionParameters(['pdodriver' => 'pdo_sqlite']); - self::assertEquals('Sqlite', $this->pdo->getDatabasePlatformName()); - self::assertEquals('SQLite', $this->pdo->getDatabasePlatformName(PdoDriverInterface::NAME_FORMAT_NATURAL)); - } - /** @psalm-return array */ public static function getParamsAndType(): array {