You are here

protected function EntityLegalTestCase::createDocumentVersion in Entity Legal 7

Same name and namespace in other branches
  1. 7.2 tests/entity_legal.common.test \EntityLegalTestCase::createDocumentVersion()

Create a document version.

Parameters

EntityLegalDocument $document: The document to add the version to.

bool $save_as_default: Whether to save the version as the default for the document.

Return value

EntityLegalDocumentVersion The created legal document version.

8 calls to EntityLegalTestCase::createDocumentVersion()
EntityLegalDocumentAcceptanceTestCase::testSubmissionForm in tests/entity_legal.acceptance.test
Test that user has the ability to agree to legal documents.
EntityLegalDocumentVersionTestCase::testAdminOverviewUi in tests/entity_legal.version.test
Test the overview page contains a list of entities.
EntityLegalDocumentVersionTestCase::testEditForm in tests/entity_legal.version.test
Test the functionality of the edit form.
EntityLegalMethodsTestCase::testMessageMethod in tests/entity_legal.methods.test
Drupal message method test.
EntityLegalMethodsTestCase::testPopupMethod in tests/entity_legal.methods.test
JQuery UI dialog method test.

... See full list

File

tests/entity_legal.common.test, line 89
Common test class file.

Class

EntityLegalTestCase
Common Simpletest class for all legal tests.

Code

protected function createDocumentVersion(EntityLegalDocument $document, $save_as_default = FALSE) {
  $entity = entity_create(ENTITY_LEGAL_DOCUMENT_VERSION_ENTITY_NAME, array(
    'name' => $this
      ->randomName(64),
    'document_name' => $document
      ->identifier(),
    'label' => $this
      ->randomName(),
    'acceptance_label' => $this
      ->randomName(),
    'entity_legal_document_text' => array(
      LANGUAGE_NONE => array(
        array(
          'value' => $this
            ->randomName(),
        ),
      ),
    ),
  ));
  $entity
    ->save();
  if ($save_as_default) {
    $document
      ->setPublishedVersion($entity);
    $document
      ->save();
  }
  return $entity;
}