You are here

public function CertificateTestCase::testCertificateMapping in Certificate 6.2

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

File

./certificate.test, line 46
certificate.test

Class

CertificateTestCase
Tests for Certificate.

Code

public function testCertificateMapping() {
  $activity_node = $this
    ->drupalCreateNode(array(
    'type' => $this->contentType->type,
  ));
  $certificate = $this
    ->drupalCreateNode(array(
    'type' => 'certificate',
  ));
  $u1 = $this
    ->drupalCreateUser();
  $firstletter = $u1->name[0];
  $this
    ->drupalLogin($u1);
  $GLOBALS['certificate_ok'] = TRUE;
  $this
    ->drupalGet("node/{$activity_node->nid}/certificate", array(
    'query' => 'certificate_ok',
  ));
  $this
    ->assertNoResponse(403, 'Did not get access denied.');
  $this
    ->assertNoText('Custom access denied message.', 'Did not find moduled provided access denied message on certificate page.');
  $this
    ->assertText('Sorry, there is no certificate available.', 'Found no certificate available text.');

  // Map the first letter of the user's name to the certificate.
  certificate_update_node_mappings($activity_node->nid, array(
    'firstletter' => array(
      $firstletter => $certificate->nid,
    ),
  ));
  certificate_course_node_template_settings($activity_node->nid);
  $this
    ->drupalGet("node/{$activity_node->nid}/certificate", array(
    'query' => 'certificate_ok',
  ));
  $this
    ->assertNoResponse(403, 'Did not get access denied.');
  $this
    ->assertNoText('Custom access denied message.', 'Did not find module provided access denied message on certificate page.');
  $this
    ->assertNoText('Sorry, there is no certificate available.', 'User received certificate.');
}