public function EntityLegalDocumentVersionTestCase::testCreateForm in Entity Legal 7.2
Same name and namespace in other branches
- 7 tests/entity_legal.version.test \EntityLegalDocumentVersionTestCase::testCreateForm()
Test the functionality of the create form.
File
- tests/
entity_legal.version.test, line 47 - Test for legal document version entity admin ui.
Class
- EntityLegalDocumentVersionTestCase
- Simpletest class for document versioning.
Code
public function testCreateForm() {
$document = $this
->createDocument();
$test_label = $this
->randomName();
$test_name = $this
->randomName();
$document_text = $this
->randomName();
$acceptance_label = $this
->randomName();
$this
->drupalLogin($this->adminUser);
$this
->drupalPost('admin/structure/legal/manage/' . $document
->identifier() . '/add', array(
'label' => $test_label,
'name' => $test_name,
'entity_legal_document_text[und][0][value]' => $document_text,
'acceptance_label' => $acceptance_label,
), 'Save');
// Load a reset version of the entity.
$created_version = $this
->getUncachedEntity(ENTITY_LEGAL_DOCUMENT_VERSION_ENTITY_NAME, $test_name);
$document = $this
->getUncachedEntity(ENTITY_LEGAL_DOCUMENT_ENTITY_NAME, $document
->identifier());
$this
->assertTrue(!empty($created_version), 'Document version was successfully created');
$this
->drupalGet('admin/structure/legal/manage/' . $document
->identifier());
$this
->assertText($test_label, 'Document version found on document page');
if ($created_version) {
$this
->assertEqual($test_label, $created_version
->label(), 'Label was saved correctly');
$this
->assertEqual($test_name, $created_version
->identifier(), 'Name was saved correctly');
$this
->assertEqual($acceptance_label, $created_version->acceptance_label, 'Acceptance label saved correctly');
$this
->assertEqual($document_text, $created_version->entity_legal_document_text[LANGUAGE_NONE][0]['value'], 'Document text is correct');
$this
->assertEqual($document
->identifier(), $created_version->document_name, 'Corresponding document is set correctly');
$this
->assertEqual($document->published_version, $created_version
->identifier(), 'Published version set on document');
}
}