Unverified Commit 383f701f authored by alexpott's avatar alexpott

Issue #2853118 by voleger, Jo Fitzgerald, Pavan B S, yogeshmpawar, hgunicamp,...

Issue #2853118 by voleger, Jo Fitzgerald, Pavan B S, yogeshmpawar, hgunicamp, pk188, andypost, jeetendrakumar, longwave, gaurav.kapoor, RenatoG, daffie, mondrake, dhruveshdtripathi, catch, alexpott, xjm: Replace all calls to db_insert, which is deprecated
parent 0a1be73a
......@@ -157,6 +157,7 @@ function db_query_temporary($query, array $args = [], array $options = []) {
* @see \Drupal\Core\Database\Connection::defaultOptions()
*/
function db_insert($table, array $options = []) {
@trigger_error('db_insert() 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 insert() on it. For example, $injected_database->insert($table, $options); See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
if (empty($options['target']) || $options['target'] == 'replica') {
$options['target'] = 'default';
}
......
......@@ -1081,7 +1081,7 @@ function hook_ENTITY_TYPE_presave(Drupal\Core\Entity\EntityInterface $entity) {
*/
function hook_entity_insert(Drupal\Core\Entity\EntityInterface $entity) {
// Insert the new entity into a fictional table of all entities.
db_insert('example_entity')
\Drupal::database()->insert('example_entity')
->fields([
'type' => $entity->getEntityTypeId(),
'id' => $entity->id(),
......@@ -1105,7 +1105,7 @@ function hook_entity_insert(Drupal\Core\Entity\EntityInterface $entity) {
*/
function hook_ENTITY_TYPE_insert(Drupal\Core\Entity\EntityInterface $entity) {
// Insert the new entity into a fictional table of this type of entity.
db_insert('example_entity')
\Drupal::database()->insert('example_entity')
->fields([
'id' => $entity->id(),
'created' => REQUEST_TIME,
......
......@@ -17,7 +17,7 @@
->execute();
// Add a custom contact category.
db_insert('contact')->fields([
$connection->insert('contact')->fields([
'category',
'recipients',
'reply',
......
......@@ -22,7 +22,8 @@ class UsageTest extends FileManagedUnitTestBase {
*/
public function testGetUsage() {
$file = $this->createFile();
db_insert('file_usage')
$connection = Database::getConnection();
$connection->insert('file_usage')
->fields([
'fid' => $file->id(),
'module' => 'testing',
......@@ -31,7 +32,7 @@ public function testGetUsage() {
'count' => 1,
])
->execute();
db_insert('file_usage')
$connection->insert('file_usage')
->fields([
'fid' => $file->id(),
'module' => 'testing',
......@@ -105,7 +106,8 @@ public function doTestRemoveUsage() {
$file = $this->createFile();
$file->setPermanent();
$file_usage = $this->container->get('file.usage');
db_insert('file_usage')
$connection = Database::getConnection();
$connection->insert('file_usage')
->fields([
'fid' => $file->id(),
'module' => 'testing',
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\history\Kernel\Views;
use Drupal\Core\Database\Database;
use Drupal\node\Entity\Node;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\user\Entity\User;
......@@ -67,14 +68,15 @@ public function testHandlers() {
$account->save();
\Drupal::currentUser()->setAccount($account);
db_insert('history')
$connection = Database::getConnection();
$connection->insert('history')
->fields([
'uid' => $account->id(),
'nid' => $nodes[0]->id(),
'timestamp' => REQUEST_TIME - 100,
])->execute();
db_insert('history')
$connection->insert('history')
->fields([
'uid' => $account->id(),
'nid' => $nodes[1]->id(),
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\locale\Functional;
use Drupal\Core\Database\Database;
use Drupal\Core\StreamWrapper\PublicStream;
use Drupal\file\Entity\File;
use Drupal\Tests\BrowserTestBase;
......@@ -278,9 +279,10 @@ protected function setCurrentTranslations() {
'filename' => 'custom_module_one.de.po',
'version' => '',
];
$connection = Database::getConnection();
foreach ($data as $file) {
$file = array_merge($default, $file);
db_insert('locale_file')->fields($file)->execute();
$connection->insert('locale_file')->fields($file)->execute();
}
}
......
......@@ -51,7 +51,7 @@
* 'grant_update' => 0,
* 'grant_delete' => 0,
* );
* db_insert('node_access')->fields($record)->execute();
* \Drupal::database()->insert('node_access')->fields($record)->execute();
* @endcode
* And then in its hook_node_grants() implementation, it would need to return:
* @code
......
......@@ -134,7 +134,7 @@ function node_install() {
}
// Populate the node access table.
db_insert('node_access')
Database::getConnection()->insert('node_access')
->fields([
'nid' => 0,
'gid' => 0,
......
......@@ -2,6 +2,8 @@
namespace Drupal\Tests\node\Functional;
use Drupal\Core\Database\Database;
/**
* Tests the node access grants cache context service.
*
......@@ -92,7 +94,7 @@ public function testCacheContext() {
'grant_update' => 0,
'grant_delete' => 0,
];
db_insert('node_access')->fields($record)->execute();
Database::getConnection()->insert('node_access')->fields($record)->execute();
// Put user accessUser (uid 0) in the realm.
\Drupal::state()->set('node_access_test.no_access_uid', 0);
......
......@@ -2,6 +2,8 @@
namespace Drupal\Tests\node\Functional;
use Drupal\Core\Database\Database;
/**
* Tests that node access queries are properly altered by the node module.
*
......@@ -151,7 +153,8 @@ public function testNodeQueryAlterOverride() {
'grant_update' => 0,
'grant_delete' => 0,
];
db_insert('node_access')->fields($record)->execute();
$connection = Database::getConnection();
$connection->insert('node_access')->fields($record)->execute();
// Test that the noAccessUser still doesn't have the 'view'
// privilege after adding the node_access record.
......
......@@ -20,7 +20,7 @@
* @see \Drupal\Core\Path\AliasStorageInterface::save()
*/
function hook_path_insert($path) {
db_insert('mytable')
\Drupal::database()->insert('mytable')
->fields([
'alias' => $path['alias'],
'pid' => $path['pid'],
......
......@@ -540,7 +540,7 @@ function search_index($type, $sid, $langcode, $text) {
$connection = \Drupal::database();
// Insert cleaned up data into dataset
db_insert('search_dataset')
$connection->insert('search_dataset')
->fields([
'sid' => $sid,
'langcode' => $langcode,
......
......@@ -4,6 +4,7 @@
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Core\Database\Database;
use Drupal\Core\Url;
use Drupal\filter\Entity\FilterFormat;
use Drupal\search\Entity\SearchPage;
......@@ -104,7 +105,7 @@ public function testRankings() {
// to the Statistics module. So instead go ahead and manually update the
// counter for this node.
$nid = $nodes['views'][1]->id();
db_insert('node_counter')
Database::getConnection()->insert('node_counter')
->fields(['totalcount' => 5, 'daycount' => 5, 'timestamp' => REQUEST_TIME, 'nid' => $nid])
->execute();
......
......@@ -138,7 +138,7 @@ function simpletest_run_tests($test_list) {
unset($test_list['phpunit']);
}
$test_id = db_insert('simpletest_test_id')
$test_id = \Drupal::database()->insert('simpletest_test_id')
->useDefaults(['test_id'])
->execute();
......
......@@ -5,6 +5,8 @@
* Install, update and uninstall functions for the module_test module.
*/
use Drupal\Core\Database\Database;
/**
* Implements hook_schema().
*/
......@@ -29,7 +31,7 @@ function module_test_schema() {
*/
function module_test_install() {
$schema = drupal_get_module_schema('module_test', 'module_test');
db_insert('module_test')
Database::getConnection()->insert('module_test')
->fields([
'data' => $schema['fields']['data']['type'],
])
......
......@@ -70,7 +70,7 @@ function tracker_cron() {
->execute();
// Insert the node-level data.
db_insert('tracker_node')
$connection->insert('tracker_node')
->fields([
'nid' => $nid,
'published' => (int) $node->isPublished(),
......@@ -79,7 +79,7 @@ function tracker_cron() {
->execute();
// Insert the user-level data for the node's author.
db_insert('tracker_user')
$connection->insert('tracker_user')
->fields([
'nid' => $nid,
'published' => (int) $node->isPublished(),
......@@ -102,7 +102,7 @@ function tracker_cron() {
->groupBy('uid')
->execute();
if ($result) {
$query = db_insert('tracker_user');
$query = $connection->insert('tracker_user');
foreach ($result as $row) {
$query->fields([
'uid' => $row['uid'],
......
......@@ -155,7 +155,7 @@ function hook_user_login($account) {
* The user object on which the operation was just performed.
*/
function hook_user_logout($account) {
db_insert('logouts')
\Drupal::database()->insert('logouts')
->fields([
'uid' => $account->id(),
'time' => time(),
......
......@@ -2,6 +2,7 @@
namespace Drupal\views\Tests;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\simpletest\KernelTestBase;
......@@ -71,7 +72,7 @@ protected function setUpFixtures() {
// Load the test dataset.
$data_set = $this->dataSet();
$query = db_insert('views_test_data')
$query = Database::getConnection()->insert('views_test_data')
->fields(array_keys($data_set[0]));
foreach ($data_set as $record) {
$query->values($record);
......
......@@ -4,6 +4,7 @@
@trigger_error('\Drupal\views\Tests\ViewTestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\views\Functional\ViewTestBase', E_USER_DEPRECATED);
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\simpletest\WebTestBase;
use Drupal\views\ViewExecutable;
......@@ -57,7 +58,7 @@ protected function enableViewsTestModule() {
// Load the test dataset.
$data_set = $this->dataSet();
$query = db_insert('views_test_data')
$query = Database::getConnection()->insert('views_test_data')
->fields(array_keys($data_set[0]));
foreach ($data_set as $record) {
$query->values($record);
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\views\Functional\Plugin;
use Drupal\Core\Database\Database;
use Drupal\dynamic_page_cache\EventSubscriber\DynamicPageCacheSubscriber;
use Drupal\Tests\views\Functional\ViewTestBase;
use Drupal\views\Entity\View;
......@@ -115,7 +116,7 @@ public function testNumericFieldVisible() {
// Adds a new datapoint in the views_test_data table to have a person with
// an age of zero.
$data_set = $this->dataSet();
$query = db_insert('views_test_data')
$query = Database::getConnection()->insert('views_test_data')
->fields(array_keys($data_set[0]));
$query->values([
'name' => 'James McCartney',
......
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\views\Functional;
use Behat\Mink\Exception\ElementNotFoundException;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\Tests\BrowserTestBase;
use Drupal\views\Tests\ViewResultAssertionTrait;
......@@ -55,7 +56,7 @@ protected function enableViewsTestModule() {
// Load the test dataset.
$data_set = $this->dataSet();
$query = db_insert('views_test_data')
$query = Database::getConnection()->insert('views_test_data')
->fields(array_keys($data_set[0]));
foreach ($data_set as $record) {
$query->values($record);
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\views\Kernel\Plugin;
use Drupal\Core\Database\Database;
use Drupal\Core\Render\RenderContext;
use Drupal\node\Entity\Node;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
......@@ -88,7 +89,7 @@ public function testTimeResultCaching() {
'age' => 29,
'job' => 'Banjo',
];
db_insert('views_test_data')->fields($record)->execute();
Database::getConnection()->insert('views_test_data')->fields($record)->execute();
// The result should be the same as before, because of the caching. (Note
// that views_test_data records don't have associated cache tags, and hence
......@@ -242,7 +243,7 @@ public function testNoneResultCaching() {
'age' => 29,
'job' => 'Banjo',
];
db_insert('views_test_data')->fields($record)->execute();
Database::getConnection()->insert('views_test_data')->fields($record)->execute();
// The Result changes, because the view is not cached.
$view = Views::getView('test_cache');
......
......@@ -31,7 +31,7 @@ protected function read($name) {
}
protected function insert($name, $data) {
db_insert('config')->fields(['name' => $name, 'data' => $data])->execute();
Database::getConnection()->insert('config')->fields(['name' => $name, 'data' => $data])->execute();
}
protected function update($name, $data) {
......
......@@ -76,7 +76,7 @@ public function testConcatWsFields() {
* Tests escaping of LIKE wildcards.
*/
public function testLikeEscape() {
db_insert('test')
$this->connection->insert('test')
->fields([
'name' => 'Ring_',
])
......@@ -102,7 +102,7 @@ public function testLikeEscape() {
* Tests a LIKE query containing a backslash.
*/
public function testLikeBackslash() {
db_insert('test')
$this->connection->insert('test')
->fields(['name'])
->values([
'name' => 'abcde\f',
......
......@@ -15,7 +15,7 @@ class CaseSensitivityTest extends DatabaseTestBase {
public function testCaseSensitiveInsert() {
$num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
db_insert('test')
$this->connection->insert('test')
->fields([
// A record already exists with name 'John'.
'name' => 'john',
......
......@@ -4,6 +4,7 @@
use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Database\Query\Delete;
use Drupal\Core\Database\Query\Insert;
use Drupal\Core\Database\Query\Merge;
use Drupal\Core\Database\Query\Truncate;
use Drupal\Core\Database\Query\Update;
......@@ -455,4 +456,13 @@ public function testDbAddIndex() {
$this->assertNull(db_add_index('test', 'test', ['age'], $table_specification));
}
/**
* Tests the db_insert() function.
*
* @expectedDeprecation db_insert() 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 insert() on it. For example, $injected_database->insert($table, $options); See https://www.drupal.org/node/2993033
*/
public function testDbInsert() {
$this->assertInstanceOf(Insert::class, db_insert('test'));
}
}
......@@ -15,7 +15,7 @@ class InsertDefaultsTest extends DatabaseTestBase {
* Tests that we can run a query that uses default values for everything.
*/
public function testDefaultInsert() {
$query = db_insert('test')->useDefaults(['job']);
$query = $this->connection->insert('test')->useDefaults(['job']);
$id = $query->execute();
$schema = drupal_get_module_schema('database_test', 'test');
......@@ -31,7 +31,7 @@ public function testDefaultEmptyInsert() {
$num_records_before = (int) db_query('SELECT COUNT(*) FROM {test}')->fetchField();
try {
db_insert('test')->execute();
$this->connection->insert('test')->execute();
// This is only executed if no exception has been thrown.
$this->fail('Expected exception NoFieldsException has not been thrown.');
}
......@@ -47,7 +47,7 @@ public function testDefaultEmptyInsert() {
* Tests that we can insert fields with values and defaults in the same query.
*/
public function testDefaultInsertWithFields() {
$query = db_insert('test')
$query = $this->connection->insert('test')
->fields(['name' => 'Bob'])
->useDefaults(['job']);
$id = $query->execute();
......
......@@ -15,7 +15,7 @@ class InsertLobTest extends DatabaseTestBase {
public function testInsertOneBlob() {
$data = "This is\000a test.";
$this->assertTrue(strlen($data) === 15, 'Test data contains a NULL.');
$id = db_insert('test_one_blob')
$id = $this->connection->insert('test_one_blob')
->fields(['blob1' => $data])
->execute();
$r = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', [':id' => $id])->fetchAssoc();
......@@ -26,7 +26,7 @@ public function testInsertOneBlob() {
* Tests that we can insert multiple blob fields in the same query.
*/
public function testInsertMultipleBlob() {
$id = db_insert('test_two_blobs')
$id = $this->connection->insert('test_two_blobs')
->fields([
'blob1' => 'This is',
'blob2' => 'a test',
......
......@@ -15,7 +15,7 @@ class InsertTest extends DatabaseTestBase {
public function testSimpleInsert() {
$num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
$query = db_insert('test');
$query = $this->connection->insert('test');
$query->fields([
'name' => 'Yoko',
'age' => '29',
......@@ -37,7 +37,7 @@ public function testSimpleInsert() {
public function testMultiInsert() {
$num_records_before = (int) db_query('SELECT COUNT(*) FROM {test}')->fetchField();
$query = db_insert('test');
$query = $this->connection->insert('test');
$query->fields([
'name' => 'Larry',
'age' => '30',
......@@ -76,7 +76,7 @@ public function testMultiInsert() {
public function testRepeatedInsert() {
$num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField();
$query = db_insert('test');
$query = $this->connection->insert('test');
$query->fields([
'name' => 'Larry',
......@@ -119,7 +119,7 @@ public function testRepeatedInsert() {
public function testInsertFieldOnlyDefinition() {
// This is useful for importers, when we want to create a query and define
// its fields once, then loop over a multi-insert execution.
db_insert('test')
$this->connection->insert('test')
->fields(['name', 'age'])
->values(['Larry', '30'])
->values(['Curly', '31'])
......@@ -137,7 +137,7 @@ public function testInsertFieldOnlyDefinition() {
* Tests that inserts return the proper auto-increment ID.
*/
public function testInsertLastInsertID() {
$id = db_insert('test')
$id = $this->connection->insert('test')
->fields([
'name' => 'Larry',
'age' => '30',
......@@ -165,7 +165,7 @@ public function testInsertSelectFields() {
// SELECT tp.age AS age, tp.name AS name, tp.job AS job
// FROM test_people tp
// WHERE tp.name = 'Meredith'
db_insert('test')
$this->connection->insert('test')
->from($query)
->execute();
......@@ -186,7 +186,7 @@ public function testInsertSelectAll() {
// SELECT *
// FROM test_people tp
// WHERE tp.name = 'Meredith'
db_insert('test_people_copy')
$this->connection->insert('test_people_copy')
->from($query)
->execute();
......
......@@ -18,7 +18,7 @@ class InvalidDataTest extends DatabaseTestBase {
public function testInsertDuplicateData() {
// Try to insert multiple records where at least one has bad data.
try {
db_insert('test')
$this->connection->insert('test')
->fields(['name', 'age', 'job'])
->values([
'name' => 'Elvis',
......@@ -75,7 +75,7 @@ public function testInsertDuplicateDataFromSelect() {
// Insert multiple records in 'test_people' where one has bad data
// (duplicate key). A 'Meredith' record has already been inserted
// in ::setUp.
db_insert('test_people')
$this->connection->insert('test_people')
->fields(['name', 'age', 'job'])
->values([
'name' => 'Elvis',
......@@ -109,7 +109,7 @@ public function testInsertDuplicateDataFromSelect() {
->orderBy('name');
// Try inserting from the subselect.
db_insert('test')
$this->connection->insert('test')
->from($query)
->execute();
......
......@@ -100,7 +100,7 @@ public function testConditionOperatorArgumentsSQLInjection() {
// Attempt SQLi via union query with no unsafe characters.
$this->enableModules(['user']);
$this->installEntitySchema('user');
db_insert('test')
$this->connection->insert('test')
->fields(['name' => '123456'])
->execute();
$injection = "= 1 UNION ALL SELECT password FROM user WHERE uid =";
......@@ -117,7 +117,7 @@ public function testConditionOperatorArgumentsSQLInjection() {
}
// Attempt SQLi via union query - uppercase tablename.
db_insert('TEST_UPPERCASE')
$this->connection->insert('TEST_UPPERCASE')
->fields(['name' => 'secrets'])
->execute();
$injection = "IS NOT NULL) UNION ALL SELECT name FROM {TEST_UPPERCASE} -- ";
......
......@@ -22,7 +22,8 @@ class RegressionTest extends DatabaseTestBase {
public function testRegression_310447() {
// That's a 255 character UTF-8 string.
$job = str_repeat("é", 255);
db_insert('test')
$this->connection
->insert('test')
->fields([
'name' => $this->randomMachineName(),
'age' => 20,
......
......@@ -209,7 +209,7 @@ public function testJoinSubquerySelect() {
*/
public function testExistsSubquerySelect() {
// Put George into {test_people}.
db_insert('test_people')
$this->connection->insert('test_people')
->fields([
'name' => 'George',
'age' => 27,
......@@ -239,7 +239,7 @@ public function testExistsSubquerySelect() {
*/
public function testNotExistsSubquerySelect() {
// Put George into {test_people}.
db_insert('test_people')
$this->connection->insert('test_people')
->fields([
'name' => 'George',
'age' => 27,
......
......@@ -402,7 +402,7 @@ public function testRandomOrder() {
// after shuffling it (in other words, nearly impossible).
$number_of_items = 52;
while (db_query("SELECT MAX(id) FROM {test}")->fetchField() < $number_of_items) {
db_insert('test')->fields(['name' => $this->randomMachineName()])->execute();
$this->connection->insert('test')->fields(['name' => $this->randomMachineName()])->execute();
}
// First select the items in order and make sure we get an ordered list.
......
......@@ -55,7 +55,7 @@ protected function transactionOuterLayer($suffix, $rollback = FALSE, $ddl_statem
$txn = $this->connection->startTransaction();
// Insert a single row into the testing table.
db_insert('test')
$this->connection->insert('test')
->fields([
'name' => 'David' . $suffix,
'age' => '24',
......@@ -103,7 +103,7 @@ protected function transactionInnerLayer($suffix, $rollback = FALSE, $ddl_statem
$this->assertTrue($depth < $depth2, 'Transaction depth is has increased with new transaction.');
// Insert a single row into the testing table.
db_insert('test')
$this->connection->insert('test')
->fields([
'name' => 'Daniel' . $suffix,
'age' => '19',
......@@ -308,7 +308,7 @@ public function testTransactionWithDdlStatement() {
* Inserts a single row into the testing table.
*/
protected function insertRow($name) {
db_insert('test')
$this->connection->insert('test')
->fields([
'name' => $name,
])
......
......@@ -15,7 +15,7 @@ class UpdateLobTest extends DatabaseTestBase {
public function testUpdateOneBlob() {
$data = "This is\000a test.";
$this->assertTrue(strlen($data) === 15, 'Test data contains a NULL.');
$id = db_insert('test_one_blob')
$id = $this->connection->insert('test_one_blob')
->fields(['blob1' => $data])
->execute();
......@@ -33,7 +33,7 @@ public function testUpdateOneBlob() {
* Confirms that we can update two blob columns in the same table.
*/
public function testUpdateMultipleBlob() {
$id = db_insert('test_two_blobs')
$id = $this->connection->insert('test_two_blobs')
->fields([
'blob1' => 'This is',
'blob2' => 'a test',
......
......@@ -123,7 +123,8 @@ public function testFieldLoad() {
// Generate values and insert them directly in the storage tables.
$values = [];
$query = db_insert($this->revisionTable)->fields($columns);
$connection = Database::getConnection();
$query = $connection->insert($this->revisionTable)->fields($columns);
foreach ($revision_ids as $revision_id) {
// Put one value too many.
for ($delta = 0; $delta <= $this->fieldCardinality; $delta++) {
......@@ -133,7 +134,7 @@ public function testFieldLoad() {
}
$query->execute();
}
$query = db_insert($this->table)->fields($columns);
$query = $connection->insert($this->table)->fields($columns);
foreach ($values[$revision_id] as $delta => $value) {
$query->values([$bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value]);
}
......@@ -167,8 +168,8 @@ public function testFieldLoad() {
// loaded.
$unavailable_langcode = 'xx';
$values = [$bundle, 0, $entity->id(), $entity->getRevisionId(), 0, $unavailable_langcode, mt_rand(1, 127)];
db_insert($this->table)->fields($columns)->values($values)->execute();
db_insert($this->revisionTable)->fields($columns)->values($values)->execute();
$connection->insert($this->table)->fields($columns)->values($values)->execute();
$connection->insert($this->revisionTable)->fields($columns)->values($values)->execute();
$entity = $storage->load($entity->id());
$this->assertFalse(array_key_exists($unavailable_langcode, $entity->{$this->fieldName}));
}
......