public function EntityLegalDocumentVersionTest::testEditForm in Entity Legal 8.2
Same name and namespace in other branches
- 4.0.x src/Tests/EntityLegalDocumentVersionTest.php \Drupal\entity_legal\Tests\EntityLegalDocumentVersionTest::testEditForm()
- 3.0.x src/Tests/EntityLegalDocumentVersionTest.php \Drupal\entity_legal\Tests\EntityLegalDocumentVersionTest::testEditForm()
Test the functionality of the edit form.
File
- src/
Tests/ EntityLegalDocumentVersionTest.php, line 76
Class
- EntityLegalDocumentVersionTest
- Tests admin functionality for the legal document version entity.
Namespace
Drupal\entity_legal\TestsCode
public function testEditForm() {
$document = $this
->createDocument();
$version = $this
->createDocumentVersion($document);
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/structure/legal/manage/' . $document
->id() . '/manage/' . $version
->id());
// Test field default values.
$this
->assertFieldByName('label', $version
->label(), 'Label is set correctly for version');
$this
->assertFieldByName('entity_legal_document_text[0][value]', $version
->get('entity_legal_document_text')[0]->value, 'Document text is set correctly for version');
$this
->assertFieldByName('acceptance_label', $version
->get('acceptance_label')->value, 'Acceptance label is set correctly for version');
// Test that changing values saves correctly.
$new_label = $this
->randomMachineName();
$new_text = $this
->randomMachineName();
$new_acceptance_label = $this
->randomMachineName();
$this
->drupalPostForm('admin/structure/legal/manage/' . $document
->id() . '/manage/' . $version
->id(), [
'label' => $new_label,
'entity_legal_document_text[0][value]' => $new_text,
'acceptance_label' => $new_acceptance_label,
], 'Save');
/** @var \Drupal\entity_legal\EntityLegalDocumentVersionInterface $version */
$version = $this
->getUncachedEntity(ENTITY_LEGAL_DOCUMENT_VERSION_ENTITY_NAME, $version
->id());
$this
->assertEqual($new_label, $version
->label(), 'Label was saved correctly');
$this
->assertEqual($new_text, $version
->get('entity_legal_document_text')[0]->value, 'Document tex was saved correctly');
$this
->assertEqual($new_acceptance_label, $version
->get('acceptance_label')->value, 'Acceptance label was saved correctly');
}