You are here

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

Confirm that the 'edit bundle' permission works correctly.

File

tests/fpp.permissions.test, line 160
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 testCreateEditBundlePermission() {

  // Create a user with create & edit permission.
  $permissions = array(
    "create fieldable {$this->bundle}",
    "edit 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' => $this->title,
  );
  $this
    ->drupalPost(NULL, $args, t('Save'));
  $this
    ->assertResponse(200, 'The form was submitted.');
  $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 editing it.
  $this
    ->drupalGet('admin/structure/fieldable-panels-panes/view/1/edit');
  $this
    ->assertResponse(200, 'Loaded the edit page');
  $this
    ->assertField('title', $this->title);
}