You are here

public function CertificateTestCase::testCertificateMapping in Certificate 3.x

Same name and namespace in other branches
  1. 8.3 certificate.test \CertificateTestCase::testCertificateMapping()
  2. 6.2 certificate.test \CertificateTestCase::testCertificateMapping()
  3. 7.3 certificate.test \CertificateTestCase::testCertificateMapping()
  4. 7.2 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' => array(
      'certificate_ok' => 1,
    ),
  ));
  $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,
    ),
  ));
  $this
    ->drupalGet("node/{$activity_node->nid}/certificate", array(
    'query' => array(
      'certificate_ok' => 1,
    ),
  ));
  $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.');
}