You are here

public function ContentLockTimeoutTest::setUp in Content locking (anti-concurrent editing) 8.2

Same name and namespace in other branches
  1. 8 modules/content_lock_timeout/tests/src/Functional/ContentLockTimeoutTest.php \Drupal\Tests\content_lock_timeout\Functional\ContentLockTimeoutTest::setUp()

Setup and Rebuild node access.

Overrides BrowserTestBase::setUp

File

modules/content_lock_timeout/tests/src/Functional/ContentLockTimeoutTest.php, line 120

Class

ContentLockTimeoutTest
Test content_lock_timeout sub module.

Namespace

Drupal\Tests\content_lock_timeout\Functional

Code

public function setUp() {
  parent::setUp();
  $this
    ->drupalCreateContentType([
    'type' => 'article',
  ]);
  $this->adminUser = $this
    ->drupalCreateUser([
    'edit any article content',
    'delete any article content',
    'administer nodes',
    'administer content types',
    'administer users',
    'administer blocks',
    'administer taxonomy',
    'administer content lock',
  ]);
  $this->permissions1 = [
    'create article content',
    'edit any article content',
    'delete any article content',
    'access content',
    'administer blocks',
    'administer taxonomy',
  ];
  $this->permissions2 = [
    'create article content',
    'edit any article content',
    'delete any article content',
    'access content',
    'administer blocks',
    'administer taxonomy',
    'break content lock',
  ];

  // Create articles nodes.
  $this->article1 = $this
    ->drupalCreateNode([
    'type' => 'article',
    'title' => 'Article 1',
  ]);

  // Create vocabulary and terms.
  $this->vocabulary = $this
    ->createVocabulary();
  $this->term1 = $this
    ->createTerm($this->vocabulary);
  $this->user1 = $this
    ->drupalCreateUser($this->permissions1);
  $this->user2 = $this
    ->drupalCreateUser($this->permissions2);
  node_access_rebuild();
  $this
    ->cronRun();
  $this
    ->setNewDatetimeTimeService();
  $this
    ->drupalLogin($this->adminUser);
  $edit = [
    'content_lock_timeout_minutes' => 10,
    'content_lock_timeout_on_edit' => 1,
  ];
  $this
    ->drupalPostForm('/admin/config/content/content_lock/timeout', $edit, t('Save configuration'));
  $this->lockService = \Drupal::service('content_lock');
}