function BlockWeightUpdateTest::testRunUpdates
Tests update path for blocks' `weight` property.
File
-
core/
modules/ block/ tests/ src/ Functional/ BlockWeightUpdateTest.php, line 28
Class
- BlockWeightUpdateTest
- @covers block_post_update_make_weight_integer @group block
Namespace
Drupal\Tests\block\FunctionalCode
public function testRunUpdates() {
// Find a block and change it to have a null weight.
/** @var \Drupal\Core\Database\Connection $database */
$database = $this->container
->get('database');
$block = $database->select('config', 'c')
->fields('c', [
'data',
])
->condition('name', 'block.block.claro_content')
->execute()
->fetchField();
$block = unserialize($block);
$block['weight'] = NULL;
$database->update('config')
->fields([
'data' => serialize($block),
])
->condition('name', 'block.block.claro_content')
->execute();
$this->assertNull(Block::load('claro_content')->get('weight'));
$this->runUpdates();
$this->assertSame(0, Block::load('claro_content')->get('weight'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.