ConnectionTest.php

Same filename in this branch
  1. main core/modules/mysql/tests/src/Unit/ConnectionTest.php
  2. main core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php
  3. main core/modules/mysqli/tests/src/Kernel/mysqli/ConnectionTest.php
  4. main core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
  5. main core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
Same filename and directory in other branches
  1. 10 core/modules/sqlite/tests/src/Kernel/sqlite/ConnectionTest.php
  2. 8.9.x core/tests/Drupal/Tests/Core/Database/Driver/sqlite/ConnectionTest.php
  3. 11.x core/modules/sqlite/tests/src/Unit/ConnectionTest.php
  4. 11.x core/modules/mysql/tests/src/Unit/ConnectionTest.php
  5. 11.x core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php
  6. 11.x core/modules/mysqli/tests/src/Kernel/mysqli/ConnectionTest.php
  7. 11.x core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
  8. 11.x core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
  9. 10 core/modules/sqlite/tests/src/Unit/ConnectionTest.php
  10. 10 core/modules/mysql/tests/src/Unit/ConnectionTest.php
  11. 10 core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php
  12. 10 core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
  13. 10 core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
  14. 9 core/modules/sqlite/tests/src/Unit/ConnectionTest.php
  15. 9 core/modules/mysql/tests/src/Unit/ConnectionTest.php
  16. 9 core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php
  17. 9 core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
  18. 9 core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
  19. 8.9.x core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
  20. 8.9.x core/tests/Drupal/Tests/Core/Database/ConnectionTest.php

Namespace

Drupal\Tests\sqlite\Unit

File

core/modules/sqlite/tests/src/Unit/ConnectionTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\sqlite\Unit;

use Drupal\sqlite\Driver\Database\sqlite\Connection;
use Drupal\sqlite\Driver\Database\sqlite\SqliteConnection;
use Drupal\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;

/**
 * Tests Drupal\sqlite\Driver\Database\sqlite\Connection.
 */
class ConnectionTest extends UnitTestCase {
  
  /**
   * Tests create connection options from url.
   *
   * @param string $url
   *   SQLite URL.
   * @param string $expected
   *   Expected connection option.
   */
  public function testCreateConnectionOptionsFromUrl(string $url, string $expected) : void {
    $sqlite_connection = new Connection($this->createMock(SqliteConnection::class), []);
    $database = $sqlite_connection->createConnectionOptionsFromUrl($url, NULL);
    $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 {
    return [
      'sqlite relative path' => [
        'sqlite://localhost/tmp/test',
        'tmp/test',
      ],
      'sqlite absolute path' => [
        'sqlite://localhost//tmp/test',
        '/tmp/test',
      ],
      'in memory sqlite path' => [
        'sqlite://localhost/:memory:',
        ':memory:',
      ],
    ];
  }

}

Classes

Title Deprecated Summary
ConnectionTest Tests Drupal\sqlite\Driver\Database\sqlite\Connection.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.