You are here

public function FppPermissionsTest::testCreateBundlePermission in Fieldable Panels Panes (FPP) 7

Confirm that the 'create bundle' permission works correctly.

File

tests/fpp.permissions.test, line 104
Tests for the Fieldable Panels Panes module to ensure the permissions work.

Class

FppPermissionsTest
Tests for the Fieldable Panels Panes module to ensure the permissions work.

Code

public function testCreateBundlePermission() {

  // Create a user with the admin permission.
  $permissions = array(
    "create fieldable {$this->bundle}",
  );
  $this->user = $this
    ->createUser($permissions);
  $this
    ->drupalLogin($this->user);

  // Load the 'add' page.
  $this
    ->drupalGet('admin/structure/fieldable-panels-panes/' . $this->bundle . '/add');
  $this
    ->assertResponse(200, 'Loaded the Add page for the default FPP type.');

  // Save the record.
  $args = array(
    'title' => t('Test'),
  );
  $this
    ->drupalPost(NULL, $args, t('Save'));
  $this
    ->assertResponse(200);
  $this
    ->assertText(t('The entity has been saved.'));

  // Confirm the record was saved.
  $this
    ->drupalGet('admin/structure/fieldable-panels-panes/' . $this->bundle);
  $this
    ->assertNoText(t('There are currently no entities of this type.'));

  // Try loading it.
  $this
    ->drupalGet('admin/structure/fieldable-panels-panes/view/1');
  $this
    ->assertResponse(200, 'Loaded the FPP object.');

  // Not using the page title or the H1 to confirm the string because both
  // end up with HTML around them, so checking for the H2 tag as the pane's
  // title will be repeated.
  $this
    ->assertRaw('<h2>' . $this->title . '</h2>');

  // Try editing it.
  $this
    ->drupalGet('admin/structure/fieldable-panels-panes/view/1/edit');
  $this
    ->assertResponse(403, 'Unable to edit the FPP object.');
}