function BlockContentRevisionsTest::setUp

Same name in other branches
  1. 8.9.x core/modules/block_content/tests/src/Functional/BlockContentRevisionsTest.php \Drupal\Tests\block_content\Functional\BlockContentRevisionsTest::setUp()
  2. 10 core/modules/block_content/tests/src/Kernel/BlockContentRevisionsTest.php \Drupal\Tests\block_content\Kernel\BlockContentRevisionsTest::setUp()
  3. 10 core/modules/block_content/tests/src/Functional/BlockContentRevisionsTest.php \Drupal\Tests\block_content\Functional\BlockContentRevisionsTest::setUp()
  4. 11.x core/modules/block_content/tests/src/Kernel/BlockContentRevisionsTest.php \Drupal\Tests\block_content\Kernel\BlockContentRevisionsTest::setUp()
  5. 11.x core/modules/block_content/tests/src/Functional/BlockContentRevisionsTest.php \Drupal\Tests\block_content\Functional\BlockContentRevisionsTest::setUp()

Sets the test up.

Overrides BlockContentTestBase::setUp

File

core/modules/block_content/tests/src/Functional/BlockContentRevisionsTest.php, line 36

Class

BlockContentRevisionsTest
Create a block with revisions.

Namespace

Drupal\Tests\block_content\Functional

Code

protected function setUp() : void {
    parent::setUp();
    // Create initial block.
    $block = $this->createBlockContent('initial');
    $blocks = [];
    $logs = [];
    // Get original block.
    $blocks[] = $block->getRevisionId();
    $logs[] = '';
    // Create three revisions.
    $revision_count = 3;
    for ($i = 0; $i < $revision_count; $i++) {
        $block->setNewRevision(TRUE);
        $block->setRevisionLogMessage($this->randomMachineName(32));
        $block->setRevisionUser($this->adminUser);
        $block->setRevisionCreationTime(REQUEST_TIME);
        $logs[] = $block->getRevisionLogMessage();
        $block->save();
        $blocks[] = $block->getRevisionId();
    }
    $this->blocks = $blocks;
    $this->revisionLogs = $logs;
}

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