public function EntityLegalDocumentTest::testCreateForm in Entity Legal 8.2
Same name and namespace in other branches
- 4.0.x src/Tests/EntityLegalDocumentTest.php \Drupal\entity_legal\Tests\EntityLegalDocumentTest::testCreateForm()
- 3.0.x src/Tests/EntityLegalDocumentTest.php \Drupal\entity_legal\Tests\EntityLegalDocumentTest::testCreateForm()
Test the functionality of the create form.
File
- src/
Tests/ EntityLegalDocumentTest.php, line 36
Class
- EntityLegalDocumentTest
- Tests admin functionality for the legal document entity.
Namespace
Drupal\entity_legal\TestsCode
public function testCreateForm() {
$test_label = $this
->randomMachineName();
$test_id = $this
->randomMachineName();
$this
->drupalLogin($this->adminUser);
$this
->drupalPostForm('admin/structure/legal/add', [
'label' => $test_label,
'id' => $test_id,
'settings[new_users][require]' => 1,
'settings[new_users][require_method]' => 'form_inline',
'settings[existing_users][require]' => 1,
'settings[existing_users][require_method]' => 'redirect',
], 'Save');
// Load a reset version of the entity.
/** @var \Drupal\entity_legal\EntityLegalDocumentInterface $created_document */
$created_document = $this
->getUncachedEntity(ENTITY_LEGAL_DOCUMENT_ENTITY_NAME, $test_id);
$this
->assertTrue(!empty($created_document), 'Document was successfully created');
if ($created_document) {
$this
->assertEqual($test_label, $created_document
->label(), 'Label was saved correctly');
$this
->assertEqual($test_id, $created_document
->id(), 'ID was saved correctly');
$this
->assertEqual(1, $created_document
->get('require_signup'), 'Signup requirement was saved correctly');
$this
->assertEqual(1, $created_document
->get('require_existing'), 'Existing user requirement was saved correctly');
$this
->assertEqual('form_inline', $created_document
->get('settings')['new_users']['require_method'], 'Existing user requirement was saved correctly');
$this
->assertEqual('redirect', $created_document
->get('settings')['existing_users']['require_method'], 'Existing user requirement was saved correctly');
}
}