You are here

public function NodeorderPermissionsTest::testViewOrderNodesPageInTerm in Node Order 8

Tests viewing a term's nodes order page.

File

tests/src/Functional/NodeorderPermissionsTest.php, line 66

Class

NodeorderPermissionsTest
Tests user permissions.

Namespace

Drupal\Tests\nodeorder\Functional

Code

public function testViewOrderNodesPageInTerm() {

  // Orderable vocabulary.
  $vocabulary1 = $this
    ->drupalCreateVocabulary();
  $this->configFactory
    ->getEditable('nodeorder.settings')
    ->set('vocabularies', [
    $vocabulary1
      ->id() => TRUE,
  ])
    ->save();
  $term1 = $this
    ->drupalCreateTerm($vocabulary1);
  $vocabulary2 = $this
    ->drupalCreateVocabulary();
  $term2 = $this
    ->drupalCreateTerm($vocabulary2);
  $term1_order_url = Url::fromRoute('nodeorder.admin_order', [
    'taxonomy_term' => $term1
      ->id(),
  ]);
  $term2_order_url = Url::fromRoute('nodeorder.admin_order', [
    'taxonomy_term' => $term2
      ->id(),
  ]);
  $this
    ->drupalGet($term1_order_url);
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->drupalGet($term2_order_url);
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $user = $this
    ->drupalCreateUser([
    'administer taxonomy',
  ]);
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet($term1_order_url);
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->drupalGet($term2_order_url);
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $user = $this
    ->drupalCreateUser([
    'administer taxonomy',
    'order nodes within categories',
  ]);
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet($term1_order_url);
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalGet($term2_order_url);
  $this
    ->assertSession()
    ->statusCodeEquals(403);
}