public function SelectExtenderTest::testExtend in Drupal 9
Same name and namespace in other branches
- 10 core/tests/Drupal/KernelTests/Core/Database/SelectExtenderTest.php \Drupal\KernelTests\Core\Database\SelectExtenderTest::testExtend()
@covers ::extend @covers \Drupal\Core\Database\Query\SelectExtender::extend @dataProvider providerExtend
File
- core/
tests/ Drupal/ KernelTests/ Core/ Database/ SelectExtenderTest.php, line 118
Class
- SelectExtenderTest
- Tests the Select query extender classes.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testExtend(string $expected, string $namespace, string $extend) : void {
$additional_class_loader = new ClassLoader();
$additional_class_loader
->addPsr4("Drupal\\corefake\\Driver\\Database\\corefake\\", __DIR__ . "/../../../../../tests/fixtures/database_drivers/module/corefake/src/Driver/Database/corefake");
$additional_class_loader
->addPsr4("Drupal\\corefake\\Driver\\Database\\corefakeWithAllCustomClasses\\", __DIR__ . "/../../../../../tests/fixtures/database_drivers/module/corefake/src/Driver/Database/corefakeWithAllCustomClasses");
$additional_class_loader
->register(TRUE);
$mock_pdo = $this
->createMock(StubPDO::class);
$connection = new StubConnection($mock_pdo, [
'namespace' => $namespace,
]);
// Tests the method \Drupal\Core\Database\Query\Select::extend().
$select = $connection
->select('test')
->extend($extend);
$this
->assertEquals($expected, get_class($select));
// Get an instance of the class \Drupal\Core\Database\Query\SelectExtender.
$select_extender = $connection
->select('test')
->extend(SelectExtender::class);
$this
->assertEquals(SelectExtender::class, get_class($select_extender));
// Tests the method \Drupal\Core\Database\Query\SelectExtender::extend().
$select_extender_extended = $select_extender
->extend($extend);
$this
->assertEquals($expected, get_class($select_extender_extended));
}