RecipeNodeAccessTest.php in Recipe 7.2
File
src/Tests/RecipeNodeAccessTest.php
View source
<?php
namespace Drupal\recipe\Tests;
class RecipeNodeAccessTest extends \DrupalWebTestCase {
protected $adminUser;
protected $nodeTitle;
public static function getInfo() {
return array(
'name' => 'Recipe node access',
'description' => 'Tests display of nodes in recipe lists for node access.',
'group' => 'Recipe',
);
}
public function setUp() {
parent::setUp(array(
'recipe',
'node_access_test',
));
$this->adminUser = $this
->drupalCreateUser(array(
'create recipe content',
'edit own recipe content',
'administer blocks',
));
$this
->drupalLogin($this->adminUser);
node_access_rebuild();
variable_set('node_access_test_private', TRUE);
$this->nodeTitle = $this
->randomName(16);
$edit = array(
'title' => $this->nodeTitle,
'recipe_description[' . LANGUAGE_NONE . '][0][value]' => $this
->randomName(16),
'recipe_yield' => 1,
'private' => TRUE,
);
$this
->drupalPost('node/add/recipe', $edit, 'Save');
}
public function testRecentRecipeBoxNodeAccess() {
$this
->drupalLogout();
$this
->drupalGet('node/1');
$this
->assertResponse(403);
$this
->drupalGet('recipe');
$this
->assertNoLink($this->nodeTitle);
$this
->drupalLogin($this->adminUser);
$edit = array(
'private' => FALSE,
);
$this
->drupalPost('node/1/edit', $edit, 'Save');
$this
->drupalLogout();
$this
->drupalGet('node/1');
$this
->assertResponse(200);
$this
->drupalGet('recipe');
$this
->assertLink($this->nodeTitle);
}
}