function BlockContentRevisionsTest::setUp
Same name in other branches
- 9 core/modules/block_content/tests/src/Functional/BlockContentRevisionsTest.php \Drupal\Tests\block_content\Functional\BlockContentRevisionsTest::setUp()
- 10 core/modules/block_content/tests/src/Kernel/BlockContentRevisionsTest.php \Drupal\Tests\block_content\Kernel\BlockContentRevisionsTest::setUp()
- 10 core/modules/block_content/tests/src/Functional/BlockContentRevisionsTest.php \Drupal\Tests\block_content\Functional\BlockContentRevisionsTest::setUp()
- 11.x core/modules/block_content/tests/src/Kernel/BlockContentRevisionsTest.php \Drupal\Tests\block_content\Kernel\BlockContentRevisionsTest::setUp()
- 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 37
Class
- BlockContentRevisionsTest
- Create a block with revisions.
Namespace
Drupal\Tests\block_content\FunctionalCode
protected function setUp() {
parent::setUp();
/** @var \Drupal\user\Entity\UserInterface $user */
$user = User::load(1);
// 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.