-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #2983452 by ridhimaabrol24, Kwadz, cburschka, jungle, somersoft…
…, julienjoye, dhirendra.mishra, beram, daffie, alexpott: Improve support for SQLite in memory database
- Loading branch information
Showing
2 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/Drupal/Tests/Core/Database/Driver/sqlite/ConnectionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Drupal\Tests\Core\Database\Driver\sqlite; | ||
|
||
use Drupal\Core\Database\Driver\sqlite\Connection; | ||
use Drupal\Tests\Core\Database\Stub\StubPDO; | ||
use Drupal\Tests\UnitTestCase; | ||
|
||
/** | ||
* @coversDefaultClass \Drupal\Core\Database\Driver\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) { | ||
$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 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:'], | ||
]; | ||
} | ||
|
||
} |