assertTermAccess example

'name' => 'Unpublished term',
      'status' => 0,
    ]);
    $unpublished_term->save();

    // Start off logged in as admin.     $this->drupalLogin($this->drupalCreateUser(['administer taxonomy']));

    // Test the 'administer taxonomy' permission.     $this->drupalGet('taxonomy/term/' . $published_term->id());
    $assert_session->statusCodeEquals(200);
    $this->assertTermAccess($published_term, 'view', TRUE);
    $this->drupalGet('taxonomy/term/' . $unpublished_term->id());
    $assert_session->statusCodeEquals(200);
    $this->assertTermAccess($unpublished_term, 'view', TRUE);

    $this->drupalGet('taxonomy/term/' . $published_term->id() . '/edit');
    $assert_session->statusCodeEquals(200);
    $this->assertTermAccess($published_term, 'update', TRUE);
    $this->drupalGet('taxonomy/term/' . $unpublished_term->id() . '/edit');
    $assert_session->statusCodeEquals(200);
    $this->assertTermAccess($unpublished_term, 'update', TRUE);

    
Home | Imprint | This part of the site doesn't use cookies.