You are here

public function RecipeNodeAccessTest::setUp in Recipe 7

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

File

src/Tests/RecipeNodeAccessTest.php, line 38

Class

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

Namespace

Drupal\recipe\Tests

Code

public function setUp() {

  // Enable modules required for testing.
  parent::setUp(array(
    'recipe',
    'node_access_test',
  ));

  // Create and log in the admin user with Recipe content permissions.
  $this->adminUser = $this
    ->drupalCreateUser(array(
    'create recipe content',
    'edit own recipe content',
    'administer blocks',
  ));
  $this
    ->drupalLogin($this->adminUser);

  // Set the variable to enable private nodes with node_access_test.
  node_access_rebuild();
  variable_set('node_access_test_private', TRUE);

  // Create a test recipe node.
  $this->nodeTitle = $this
    ->randomName(16);
  $edit = array(
    'title' => $this->nodeTitle,
    'recipe_description[value]' => $this
      ->randomName(16),
    'recipe_yield' => 1,
    'private' => TRUE,
  );
  $this
    ->drupalPost('node/add/recipe', $edit, 'Save');

  // Enable the Newest Recipes and Recipe Summary blocks.
  $edit = array(
    "blocks[recipe_recent][region]" => 'sidebar_first',
  );
  $this
    ->drupalPost('admin/structure/block', $edit, t('Save blocks'));
}