function TemporaryQueryTest::testTemporaryQuery
Same name in this branch
- 11.x core/modules/sqlite/tests/src/Kernel/sqlite/TemporaryQueryTest.php \Drupal\Tests\sqlite\Kernel\sqlite\TemporaryQueryTest::testTemporaryQuery()
- 11.x core/modules/pgsql/tests/src/Kernel/pgsql/TemporaryQueryTest.php \Drupal\Tests\pgsql\Kernel\pgsql\TemporaryQueryTest::testTemporaryQuery()
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Database/TemporaryQueryTest.php \Drupal\Tests\system\Functional\Database\TemporaryQueryTest::testTemporaryQuery()
- 8.9.x core/modules/system/tests/src/Functional/Database/TemporaryQueryTest.php \Drupal\Tests\system\Functional\Database\TemporaryQueryTest::testTemporaryQuery()
- 10 core/modules/sqlite/tests/src/Kernel/sqlite/TemporaryQueryTest.php \Drupal\Tests\sqlite\Kernel\sqlite\TemporaryQueryTest::testTemporaryQuery()
- 10 core/modules/mysql/tests/src/Kernel/mysql/TemporaryQueryTest.php \Drupal\Tests\mysql\Kernel\mysql\TemporaryQueryTest::testTemporaryQuery()
- 10 core/modules/pgsql/tests/src/Kernel/pgsql/TemporaryQueryTest.php \Drupal\Tests\pgsql\Kernel\pgsql\TemporaryQueryTest::testTemporaryQuery()
Confirms that temporary tables work.
Overrides TemporaryQueryTestBase::testTemporaryQuery
File
-
core/
modules/ mysql/ tests/ src/ Kernel/ mysql/ TemporaryQueryTest.php, line 19
Class
- TemporaryQueryTest
- Tests the temporary query functionality.
Namespace
Drupal\Tests\mysql\Kernel\mysqlCode
public function testTemporaryQuery() : void {
parent::testTemporaryQuery();
$connection = $this->getConnection();
$table_name_test = $connection->queryTemporary('SELECT [name] FROM {test}', []);
// Assert that the table is indeed a temporary one.
$temporary_table_info = $connection->query("SHOW CREATE TABLE {" . $table_name_test . "}")
->fetchAssoc();
$this->assertStringContainsString('CREATE TEMPORARY TABLE', $temporary_table_info['Create Table']);
// Assert that both have the same field names.
$normal_table_fields = $connection->query("SELECT * FROM {test}")
->fetch();
$temp_table_name = $connection->queryTemporary('SELECT * FROM {test}');
$temp_table_fields = $connection->query("SELECT * FROM {" . $temp_table_name . "}")
->fetch();
$normal_table_fields = array_keys(get_object_vars($normal_table_fields));
$temp_table_fields = array_keys(get_object_vars($temp_table_fields));
$this->assertEmpty(array_diff($normal_table_fields, $temp_table_fields));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.