You are here

public function EntityLegalDocumentTestCase::testEditForm in Entity Legal 7.2

Same name and namespace in other branches
  1. 7 tests/entity_legal.document.test \EntityLegalDocumentTestCase::testEditForm()

Test the functionality of the edit form.

File

tests/entity_legal.document.test, line 77
Test file include for legal document.

Class

EntityLegalDocumentTestCase
Simpletest class for legal document entities.

Code

public function testEditForm() {
  $document = $this
    ->createDocument(TRUE, TRUE, array(
    'new_users' => array(
      'require_method' => 'form_inline',
    ),
    'existing_users' => array(
      'require_method' => 'redirect',
    ),
  ));
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('admin/structure/legal/manage/' . $document
    ->identifier());

  // Test field default values.
  $this
    ->assertFieldByName('label', $document
    ->label(), 'Label is set correctly for document');
  $this
    ->assertFieldByName('settings[new_users][require]', 1, 'Require new users set correctly');
  $this
    ->assertFieldByName('settings[new_users][require_method]', 'form_inline', 'Require existing users set correctly');
  $this
    ->assertFieldByName('settings[existing_users][require]', 1, 'Require existing users set correctly');
  $this
    ->assertFieldByName('settings[existing_users][require_method]', 'redirect', 'Require existing users set correctly');

  // Test that changing values saves correctly.
  $new_label = $this
    ->randomName();
  $this
    ->drupalPost('admin/structure/legal/manage/' . $document
    ->identifier(), array(
    'label' => $new_label,
    'settings[new_users][require]' => FALSE,
    'settings[new_users][require_method]' => 'form_link',
    'settings[existing_users][require]' => FALSE,
    'settings[existing_users][require_method]' => 'popup',
  ), 'Save');
  $document = $this
    ->getUncachedEntity(ENTITY_LEGAL_DOCUMENT_ENTITY_NAME, $document
    ->identifier());
  $this
    ->assertEqual($new_label, $document
    ->label(), 'Label was saved correctly');
  $this
    ->assertEqual(0, $document->require_signup, 'Signup requirement was saved correctly');
  $this
    ->assertEqual(0, $document->require_existing, 'Existing user requirement was saved correctly');
  $this
    ->assertEqual('form_link', $document
    ->getSetting('new_users', 'require_method'), 'Form link method was saved correctly');
  $this
    ->assertEqual('popup', $document
    ->getSetting('existing_users', 'require_method'), 'Popup require method was saved correctly');
}