public function EntityLegalDocumentVersionTestCase::testEditForm in Entity Legal 7
Same name and namespace in other branches
- 7.2 tests/entity_legal.version.test \EntityLegalDocumentVersionTestCase::testEditForm()
Test the functionality of the edit form.
File
- tests/
entity_legal.version.test, line 85 - Test for legal document version entity admin ui.
Class
- EntityLegalDocumentVersionTestCase
- Simpletest class for document versioning.
Code
public function testEditForm() {
$document = $this
->createDocument();
$version = $this
->createDocumentVersion($document);
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/structure/legal/manage/' . $document
->identifier() . '/manage/' . $version
->identifier());
// Test field default values.
$this
->assertFieldByName('label', $version
->label(), 'Label is set correctly for version');
$this
->assertFieldByName('entity_legal_document_text[und][0][value]', $version->entity_legal_document_text[LANGUAGE_NONE][0]['value'], 'Document text is set correctly for version');
$this
->assertFieldByName('acceptance_label', $version->acceptance_label, 'Acceptance label is set correctly for version');
// Test that changing values saves correctly.
$new_label = $this
->randomName();
$new_text = $this
->randomName();
$new_acceptance_label = $this
->randomName();
$this
->drupalPost('admin/structure/legal/manage/' . $document
->identifier() . '/manage/' . $version
->identifier(), array(
'label' => $new_label,
'entity_legal_document_text[und][0][value]' => $new_text,
'acceptance_label' => $new_acceptance_label,
), 'Save');
$version = $this
->getUncachedEntity(ENTITY_LEGAL_DOCUMENT_VERSION_ENTITY_NAME, $version
->identifier());
$this
->assertEqual($new_label, $version
->label(), 'Label was saved correctly');
$this
->assertEqual($new_text, $version->entity_legal_document_text[LANGUAGE_NONE][0]['value'], 'Document tex was saved correctly');
$this
->assertEqual($new_acceptance_label, $version->acceptance_label, 'Acceptance label was saved correctly');
}