You are here

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

Confirm that the 'delete bundle' permission works correctly.

File

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

  // Create a user with the admin permission.
  $permissions = array(
    "create fieldable {$this->bundle}",
    "delete 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(403, 'Cannot add a new FPP object.');

  // Try deleting it.
  $this
    ->drupalGet('admin/structure/fieldable-panels-panes/view/1/delete');
  $this
    ->assertResponse(200, 'Loaded the FPP delete page.');
  $this
    ->assertRaw(t('Are you sure you want to delete %title?', array(
    '%title' => $this->title,
  )));
  $this
    ->drupalPost(NULL, array(), t('Delete'));
  $this
    ->assertResponse(200, 'The form was submitted.');
  $this
    ->assertRaw(t('@type %title has been deleted.', array(
    '@type' => fieldable_panels_panes_get_bundle_label($this->bundle),
    '%title' => $this->title,
  )));
}