protected function EntityLegalTestTrait::createDocument in Entity Legal 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Traits/EntityLegalTestTrait.php \Drupal\Tests\entity_legal\Traits\EntityLegalTestTrait::createDocument()
- 4.0.x tests/src/Traits/EntityLegalTestTrait.php \Drupal\Tests\entity_legal\Traits\EntityLegalTestTrait::createDocument()
Creates a random legal document entity.
Parameters
bool $require_signup: Whether or not to require new users to agree.
bool $require_existing: Whether or not to require existing users to agree.
array $settings: Additional settings to pass through to the document.
Return value
\Drupal\entity_legal\EntityLegalDocumentInterface The created legal document.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\Core\Entity\EntityStorageException
13 calls to EntityLegalTestTrait::createDocument()
- EntityLegalDocumentAcceptanceTest::testSubmissionForm in src/
Tests/ EntityLegalDocumentAcceptanceTest.php - Test that user has the ability to agree to legal documents.
- EntityLegalDocumentTest::testAdminOverviewUi in src/
Tests/ EntityLegalDocumentTest.php - Test the overview page contains a list of entities.
- EntityLegalDocumentTest::testDeleteForm in src/
Tests/ EntityLegalDocumentTest.php - Test the functionality of the delete form.
- EntityLegalDocumentTest::testEditForm in src/
Tests/ EntityLegalDocumentTest.php - Test the functionality of the edit form.
- EntityLegalDocumentVersionTest::testAdminOverviewUi in src/
Tests/ EntityLegalDocumentVersionTest.php - Test the overview page contains a list of entities.
File
- tests/
src/ Traits/ EntityLegalTestTrait.php, line 29
Class
- EntityLegalTestTrait
- Code reusing for Entity Legal tests.
Namespace
Drupal\Tests\entity_legal\TraitsCode
protected function createDocument($require_signup = FALSE, $require_existing = FALSE, array $settings = []) {
/** @var \Drupal\entity_legal\EntityLegalDocumentInterface $entity */
$entity = \Drupal::entityTypeManager()
->getStorage('entity_legal_document')
->create([
'id' => $this
->randomMachineName(32),
'label' => $this
->randomMachineName(),
'require_signup' => (int) $require_signup,
'require_existing' => (int) $require_existing,
'settings' => $settings,
]);
$entity
->save();
// Reset permissions cache to make new document permissions available.
$this
->checkPermissions([
$entity
->getPermissionView(),
$entity
->getPermissionExistingUser(),
]);
return $entity;
}