You are here

function CertificateTestCase::testCertificateTemplates in Certificate 7.3

Same name and namespace in other branches
  1. 8.3 certificate.test \CertificateTestCase::testCertificateTemplates()
  2. 7.2 certificate.test \CertificateTestCase::testCertificateTemplates()
  3. 3.x certificate.test \CertificateTestCase::testCertificateTemplates()

Test the token replacement inside of certificates.

File

./certificate.test, line 189
certificate.test

Class

CertificateTestCase
Tests for Certificate.

Code

function testCertificateTemplates() {

  // We give them the permission because we have to preview it here.
  $account = $this
    ->drupalCreateUser(array(
    'administer certificates',
  ));
  $activity_node = $this
    ->drupalCreateNode(array(
    'title' => 'My test certifiable type',
    'type' => $this->contentType->type,
  ));
  $content = array(
    'title' => 'Test Certificate',
    'name' => 'test_certificate',
    'orientation' => 'portrait',
    'certificate_body' => array(
      LANGUAGE_NONE => array(
        array(
          'value' => 'My Certificate Body [node:title] [user:name]',
        ),
      ),
    ),
    'type' => 'certificate',
  );
  $certificate = entity_create('certificate', $content);
  entity_save('certificate', $certificate);
  $firstletter = $account->name[0];

  // Map the first letter of the user's name to the certificate.
  certificate_update_node_mappings($activity_node->nid, array(
    'firstletter' => array(
      $firstletter => $certificate->name,
    ),
  ));
  $this
    ->drupalLogin($account);
  $this
    ->drupalGet("node/{$activity_node->nid}/certificate", array(
    'query' => array(
      'certificate_ok' => 1,
      'preview' => TRUE,
    ),
  ));
  $this
    ->assertText("My Certificate Body {$activity_node->title} {$account->name}", "Saw certificate body.");
}