You are here

public function SimpleWidgetTest::testSimpleCreateAccess in Inline Entity Form 8

Tests if the entity create access works in the simple widget.

File

tests/src/FunctionalJavascript/SimpleWidgetTest.php, line 195

Class

SimpleWidgetTest
Tests the IEF simple widget.

Namespace

Drupal\Tests\inline_entity_form\FunctionalJavascript

Code

public function testSimpleCreateAccess() {

  // Get the xpath selectors for the fields in this test.
  $nested_title_field_xpath = $this
    ->getXpathForNthInputByLabelText('Title', 2);
  $assert_session = $this
    ->assertSession();

  // Create a user who does not have access to create ief_test_custom nodes.
  $this
    ->drupalLogin($this
    ->createUser([
    'create ief_simple_single content',
  ]));
  $this
    ->drupalGet('node/add/ief_simple_single');
  $assert_session
    ->elementNotExists('xpath', $nested_title_field_xpath);

  // Now test with a user has access to create ief_test_custom nodes.
  $this
    ->drupalLogin($this->user);
  $this
    ->drupalGet('node/add/ief_simple_single');
  $assert_session
    ->elementExists('xpath', $nested_title_field_xpath);
}