You are here

public function NodeEditTest::testNodeFormWithoutOverridePremiumPermission in Node Option Premium 8

Tests that an editor by default may not alter the node's premium setting.

File

tests/src/Functional/NodeEditTest.php, line 27

Class

NodeEditTest
Tests editing nodes.

Namespace

Drupal\Tests\nopremium\Functional

Code

public function testNodeFormWithoutOverridePremiumPermission() {

  // Create a user who may create/edit articles, but may *not* set premium.
  $editor = $this
    ->drupalCreateUser([
    'create article content',
    'edit any article content',
  ]);
  $this
    ->drupalLogin($editor);

  // Go to node create page and assert that there's no premium field there.
  $this
    ->drupalGet('node/add/article');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->fieldNotExists('premium[value]');

  // Check also for an existing node.
  $node = $this
    ->drupalCreateNode([
    'type' => 'article',
  ]);
  $this
    ->drupalGet(sprintf('node/%s/edit', $node
    ->id()));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains('Edit Article');
  $this
    ->assertSession()
    ->fieldNotExists('premium[value]');
}