You are here

public function RecipeNodeAccessTest::testRecentRecipeBoxNodeAccess in Recipe 7

Same name and namespace in other branches
  1. 7.2 src/Tests/RecipeNodeAccessTest.php \Drupal\recipe\Tests\RecipeNodeAccessTest::testRecentRecipeBoxNodeAccess()

Tests node_access for nodes displayed in recipe lists.

File

src/Tests/RecipeNodeAccessTest.php, line 74

Class

RecipeNodeAccessTest
Tests display of nodes in recipe lists for node access.

Namespace

Drupal\recipe\Tests

Code

public function testRecentRecipeBoxNodeAccess() {

  // Logout and assert that the anonymous user can't access the node.
  $this
    ->drupalLogout();
  $this
    ->drupalGet('node/1');
  $this
    ->assertResponse(403);

  // Assert that a link to the test recipe can't be seen at /recipe.
  $this
    ->drupalGet('recipe');
  $this
    ->assertNoLink($this->nodeTitle);

  // Log in as the admin_user and set the recipe node as public.
  $this
    ->drupalLogin($this->adminUser);
  $edit = array(
    'private' => FALSE,
  );
  $this
    ->drupalPost('node/1/edit', $edit, 'Save');

  // Logout and assert that the anonymous user can access the node.
  $this
    ->drupalLogout();
  $this
    ->drupalGet('node/1');
  $this
    ->assertResponse(200);

  // Logout and assert that two links to the test recipe can be seen at
  // /recipe. One should be from the /recipe page Recent Recipes box and the
  // other should be from the Latest Recipes block.
  $this
    ->drupalGet('recipe');
  $this
    ->assertLink($this->nodeTitle, 0);
  $this
    ->assertLink($this->nodeTitle, 1);
}