function BlockContentUpdateTest::testConvertBlockContentTypeRevisionFlagToBoolean

Same name in other branches
  1. 10 core/modules/block_content/tests/src/Functional/Update/BlockContentUpdateTest.php \Drupal\Tests\block_content\Functional\Update\BlockContentUpdateTest::testConvertBlockContentTypeRevisionFlagToBoolean()

Tests converting block types' `revision` flag to boolean.

File

core/modules/block_content/tests/src/Functional/Update/BlockContentUpdateTest.php, line 31

Class

BlockContentUpdateTest
Tests update functions for the Block Content module.

Namespace

Drupal\Tests\block_content\Functional\Update

Code

public function testConvertBlockContentTypeRevisionFlagToBoolean() : void {
    $no_new_revisions = BlockContentType::create([
        'id' => 'no_new_revisions',
        'label' => 'Does not create new revisions',
        'revision' => 0,
    ]);
    $no_new_revisions->trustData()
        ->save();
    $new_revisions = BlockContentType::create([
        'id' => 'new_revisions',
        'label' => 'Creates new revisions',
        'revision' => 1,
    ]);
    $new_revisions->trustData()
        ->save();
    // Ensure that an integer was stored, so we can be sure that the update
    // path converts it to a boolean.
    $this->assertSame(0, $no_new_revisions->get('revision'));
    $this->assertSame(1, $new_revisions->get('revision'));
    $this->runUpdates();
    $this->assertFalse(BlockContentType::load('no_new_revisions')->get('revision'));
    $this->assertTrue(BlockContentType::load('new_revisions')->get('revision'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.