public function RevisionUserTest::testRevisionUser in Drupal 9
Same name in this branch
- 9 core/modules/media/tests/src/Kernel/Views/RevisionUserTest.php \Drupal\Tests\media\Kernel\Views\RevisionUserTest::testRevisionUser()
- 9 core/modules/block_content/tests/src/Kernel/Views/RevisionUserTest.php \Drupal\Tests\block_content\Kernel\Views\RevisionUserTest::testRevisionUser()
Same name and namespace in other branches
- 10 core/modules/block_content/tests/src/Kernel/Views/RevisionUserTest.php \Drupal\Tests\block_content\Kernel\Views\RevisionUserTest::testRevisionUser()
Tests the block_content_revision_user relationship.
File
- core/
modules/ block_content/ tests/ src/ Kernel/ Views/ RevisionUserTest.php, line 69
Class
- RevisionUserTest
- Tests the block_content_revision_user field.
Namespace
Drupal\Tests\block_content\Kernel\ViewsCode
public function testRevisionUser() {
$primary_author = $this
->createUser();
$secondary_author = $this
->createUser();
$block_content_type = BlockContentType::create([
'id' => 'basic',
'label' => 'basic block',
]);
$block_content_type
->save();
$block_content = BlockContent::create([
'info' => 'Test block content',
'type' => 'basic',
]);
$block_content
->setRevisionUserId($primary_author
->id());
$block_content
->save();
$view = Views::getView('test_block_content_revision_user');
$this
->executeView($view);
$this
->assertIdenticalResultset($view, [
[
'id' => 1,
'revision_id' => 1,
'revision_user' => $primary_author
->id(),
],
], static::$columnMap);
// Test results shows the revision author.
$block_content
->setRevisionUser($secondary_author);
$block_content
->setNewRevision();
$block_content
->save();
$view = Views::getView('test_block_content_revision_user');
$this
->executeView($view);
$this
->assertIdenticalResultset($view, [
[
'id' => 1,
'revision_id' => 2,
'revision_user' => $secondary_author
->id(),
],
], static::$columnMap);
// Build a larger dataset to allow filtering.
$block_content2_title = $this
->randomString();
$block_content2 = BlockContent::create([
'info' => $block_content2_title,
'type' => 'basic',
]);
$block_content2
->save();
$block_content2
->setRevisionUser($primary_author);
$block_content2
->setNewRevision();
$block_content2
->save();
$view = Views::getView('test_block_content_revision_user');
$this
->executeView($view);
$this
->assertIdenticalResultset($view, [
[
'id' => 1,
'revision_id' => 2,
'revision_user' => $secondary_author
->id(),
],
[
'id' => 2,
'revision_id' => 4,
'revision_user' => $primary_author
->id(),
],
], static::$columnMap);
// Test filter by revision_author.
$view = Views::getView('test_block_content_revision_user');
$view
->initHandlers();
$view->filter['revision_user']->value = [
$secondary_author
->id(),
];
$this
->executeView($view);
$this
->assertIdenticalResultset($view, [
[
'id' => 1,
'revision_id' => 2,
'revision_user' => $secondary_author
->id(),
],
], static::$columnMap);
}