FilterUidRevisionTest.php in Zircon Profile 8
File
core/modules/node/src/Tests/Views/FilterUidRevisionTest.php
View source
<?php
namespace Drupal\node\Tests\Views;
use Drupal\views\Views;
class FilterUidRevisionTest extends NodeTestBase {
public static $testViews = array(
'test_filter_node_uid_revision',
);
public function testFilter() {
$author = $this
->drupalCreateUser();
$no_author = $this
->drupalCreateUser();
$expected_result = array();
$node = $this
->drupalCreateNode(array(
'uid' => $author
->id(),
));
$expected_result[] = array(
'nid' => $node
->id(),
);
$node = $this
->drupalCreateNode(array(
'revision_uid' => $no_author
->id(),
));
$expected_result[] = array(
'nid' => $node
->id(),
);
$revision = clone $node;
$revision
->set('vid', NULL);
$revision
->set('revision_uid', $author
->id());
$revision
->save();
$this
->drupalCreateNode(array(
'uid' => $no_author
->id(),
));
$view = Views::getView('test_filter_node_uid_revision');
$view
->initHandlers();
$view->filter['uid_revision']->value = array(
$author
->id(),
);
$this
->executeView($view);
$this
->assertIdenticalResultset($view, $expected_result, array(
'nid' => 'nid',
), 'Make sure that the view only returns nodes which match either the node or the revision author.');
}
}