
| Current Path : /var/www/html/rocksensor2/web/core/modules/sqlite/tests/src/Unit/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/rocksensor2/web/core/modules/sqlite/tests/src/Unit/ConnectionTest.php |
<?php
declare(strict_types=1);
namespace Drupal\Tests\sqlite\Unit;
use Drupal\sqlite\Driver\Database\sqlite\Connection;
use Drupal\Tests\Core\Database\Stub\StubPDO;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\sqlite\Driver\Database\sqlite\Connection
* @group Database
*/
class ConnectionTest extends UnitTestCase {
/**
* @covers ::createConnectionOptionsFromUrl
* @dataProvider providerCreateConnectionOptionsFromUrl
*
* @param string $url
* SQLite URL.
* @param string $expected
* Expected connection option.
*/
public function testCreateConnectionOptionsFromUrl(string $url, string $expected): void {
$root = dirname(__DIR__, 8);
$sqlite_connection = new Connection($this->createMock(StubPDO::class), []);
$database = $sqlite_connection->createConnectionOptionsFromUrl($url, $root);
$this->assertEquals('sqlite', $database['driver']);
$this->assertEquals($expected, $database['database']);
}
/**
* Data provider for testCreateConnectionOptionsFromUrl.
*
* @return string[][]
* Associative array of arrays with the following elements:
* - SQLite database URL
* - Expected database connection option
*/
public static function providerCreateConnectionOptionsFromUrl(): array {
$root = dirname(__DIR__, 8);
return [
'sqlite relative path' => ['sqlite://localhost/tmp/test', $root . '/tmp/test'],
'sqlite absolute path' => ['sqlite://localhost//tmp/test', '/tmp/test'],
'in memory sqlite path' => ['sqlite://localhost/:memory:', ':memory:'],
];
}
}