@trigger_error('db_query_temporary() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Instead, get a database connection injected into your service from the container and call queryTemporary() on it. For example, $injected_database->queryTemporary($query, $args, $options). See https://www.drupal.org/node/2993033',E_USER_DEPRECATED);
$this->assertEqual($this->countTableRows('test'),$data->row_count,'The temporary table contains the correct amount of rows.');
$this->assertFalse(Database::getConnection()->schema()->tableExists($data->table_name),'The temporary table is, indeed, temporary.');
$this->assertFalse($connection->schema()->tableExists($data->table_name),'The temporary table is, indeed, temporary.');
}
else{
$this->fail('The creation of the temporary table failed.');
}
// Now try to run two db_query_temporary() in the same request.
$table_name_test=db_query_temporary('SELECT name FROM {test}',[]);
$table_name_task=db_query_temporary('SELECT pid FROM {test_task}',[]);
$table_name_test=$connection->queryTemporary('SELECT name FROM {test}',[]);
$table_name_task=$connection->queryTemporary('SELECT pid FROM {test_task}',[]);
$this->assertEqual($this->countTableRows($table_name_test),$this->countTableRows('test'),'A temporary table was created successfully in this request.');
$this->assertEqual($this->countTableRows($table_name_task),$this->countTableRows('test_task'),'A second temporary table was created successfully in this request.');
...
...
@@ -50,7 +51,7 @@ public function testTemporaryQuery() {
$this->assertEqual($this->countTableRows($table_name_test),$this->countTableRows('test'),'Leading white space and comments do not interfere with temporary table creation.');
* Tests deprecation of the db_query_temporary() function.
*
* @expectedDeprecation db_query_temporary() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Instead, get a database connection injected into your service from the container and call queryTemporary() on it. For example, $injected_database->queryTemporary($query, $args, $options). See https://www.drupal.org/node/2993033