NodeAccessTest.php in Diff 8
File
tests/src/Functional/NodeAccessTest.php
View source
<?php
namespace Drupal\Tests\diff\Functional;
use Drupal\Tests\BrowserTestBase;
class NodeAccessTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
protected static $modules = [
'diff',
'node',
'node_access_test',
];
protected function setUp() {
parent::setUp();
$this
->createContentType([
'type' => 'article',
]);
$this
->createUser();
node_access_rebuild();
}
public function testOverview() {
$node = $this
->createNode([
'type' => 'article',
'status' => FALSE,
]);
$node
->setTitle($this
->randomString());
$node
->setNewRevision();
$node
->save();
$node
->setTitle($this
->randomString());
$node
->setNewRevision();
$node
->save();
$user = $this
->createUser([
'access content',
'view all revisions',
]);
$this
->drupalLogin($user);
\Drupal::state()
->set('node_access_test.allow_uid', $user
->id());
$this
->drupalGet($node
->toUrl());
$this
->assertSession()
->statusCodeEquals(200);
$this
->drupalGet($node
->toUrl('version-history'));
$this
->assertSession()
->statusCodeEquals(200);
$rows = $this
->xpath('//tbody/tr');
$this
->assertCount(3, $rows, 'Did not find 3 diff rows.');
$this
->drupalGet('/node/' . $node
->id() . '/revisions');
$this
->drupalPostForm(NULL, NULL, t('Compare selected revisions'));
$this
->assertSession()
->statusCodeEquals(200);
}
}
Classes
Name |
Description |
NodeAccessTest |
Tests the diff overview form with modules implementing node access. |