class ArgumentUidRevisionTest
Same name and namespace in other branches
- 11.x core/modules/node/tests/src/Kernel/Views/ArgumentUidRevisionTest.php \Drupal\Tests\node\Kernel\Views\ArgumentUidRevisionTest
Tests the argument_node_uid_revision handler.
@group node
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\node\Kernel\Views\ArgumentUidRevisionTest uses \Drupal\Tests\user\Traits\UserCreationTrait implements \Drupal\Tests\views\Kernel\ViewsKernelTestBase
- class \Drupal\Tests\views\Kernel\ViewsKernelTestBase uses \Drupal\views\Tests\ViewResultAssertionTrait implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of ArgumentUidRevisionTest
File
-
core/
modules/ node/ tests/ src/ Kernel/ Views/ ArgumentUidRevisionTest.php, line 16
Namespace
Drupal\Tests\node\Kernel\ViewsView source
class ArgumentUidRevisionTest extends ViewsKernelTestBase {
use UserCreationTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'node',
'field',
'text',
'user',
'node_test_views',
];
/**
* {@inheritdoc}
*/
public static $testViews = [
'test_argument_node_uid_revision',
];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) : void {
parent::setUp($import_test_views);
$this->installEntitySchema('node');
$this->installSchema('node', [
'node_access',
]);
$this->installEntitySchema('user');
$this->installConfig([
'node',
'field',
]);
ViewTestData::createTestViews(static::class, [
'node_test_views',
]);
}
/**
* Tests the node_uid_revision argument.
*/
public function testArgument() {
$expected_result = [];
$author = $this->createUser();
$no_author = $this->createUser();
// Create one node, with the author as the node author.
$node1 = Node::create([
'type' => 'default',
'title' => $this->randomMachineName(),
]);
$node1->setOwner($author);
$node1->save();
$expected_result[] = [
'nid' => $node1->id(),
];
// Create one node of which an additional revision author will be the
// author.
$node2 = Node::create([
'type' => 'default',
'title' => $this->randomMachineName(),
]);
$node2->setRevisionUserId($no_author->id());
$node2->save();
$expected_result[] = [
'nid' => $node2->id(),
];
// Force to add a new revision.
$node2->setNewRevision(TRUE);
$node2->setRevisionUserId($author->id());
$node2->save();
// Create one node on which the author has neither authorship of revisions
// or the main node.
$node3 = Node::create([
'type' => 'default',
'title' => $this->randomMachineName(),
]);
$node3->setOwner($no_author);
$node3->save();
$view = Views::getView('test_argument_node_uid_revision');
$view->initHandlers();
$view->setArguments([
'uid_revision' => $author->id(),
]);
$this->executeView($view);
$this->assertIdenticalResultset($view, $expected_result, [
'nid' => 'nid',
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.