public function CertificateTestCase::testCertificateGlobalMapping in Certificate 8.3
Same name and namespace in other branches
- 7.3 certificate.test \CertificateTestCase::testCertificateGlobalMapping()
Test that global mappings correctly populate courses and local overrides are retained.
File
- ./
certificate.test, line 132 - certificate.test
Class
- CertificateTestCase
- Tests for Certificate.
Code
public function testCertificateGlobalMapping() {
$this
->drupalLogin($this->admin_user);
$activity_node = $this
->drupalCreateNode(array(
'type' => $this->contentType->type,
));
$values1 = array(
'title' => 'Cert 1',
'name' => 'cert_1',
'orientation' => 'portrait',
'certificate_body' => array(
LANGUAGE_NONE => array(
array(
'value' => 'My Certificate Body 1',
),
),
),
'type' => 'certificate',
);
$certificate1 = entity_create('certificate', $values1);
$certificate1
->save();
$values2 = array(
'title' => 'Cert 2',
'name' => 'cert_2',
'orientation' => 'portrait',
'certificate_body' => array(
LANGUAGE_NONE => array(
array(
'value' => 'My Certificate Body 2',
),
),
),
'type' => 'certificate',
);
$certificate2 = entity_create('certificate', $values2);
$certificate2
->save();
// Set globals
$this
->drupalGet('admin/structure/certificates/mapping');
$this
->drupalPost(NULL, array(
'certificate[map][firstletter][a]' => 'cert_1',
'certificate[map][firstletter][b]' => 'cert_2',
), t('Update'));
// Verify defaults pull through
$this
->drupalGet("node/{$activity_node->nid}/edit");
$this
->assertOptionSelected('edit-certificate-map-firstletter-a', 'cert_1', 'Certificate 1 populated from global.');
$this
->assertOptionSelected('edit-certificate-map-firstletter-b', 'cert_2', 'Certificate 2 populated from global.');
// Change local mappings
$this
->drupalPost(NULL, array(
'certificate[map][firstletter][a]' => '-1',
// Prevent
'certificate[map][firstletter][b]' => '',
// No action
'certificate[map][firstletter][c]' => 'cert_1',
'certificate[map][firstletter][d]' => 'cert_2',
), t('Save'));
// Verify locals retained
$this
->drupalGet("node/{$activity_node->nid}/edit");
$this
->assertOptionSelected('edit-certificate-map-firstletter-a', '-1', '"a" mapping populuated from local');
$this
->assertOptionSelected('edit-certificate-map-firstletter-b', '', '"b" mapping populuated from local');
$this
->assertOptionSelected('edit-certificate-map-firstletter-c', 'cert_1', '"c" mapping populuated from local');
$this
->assertOptionSelected('edit-certificate-map-firstletter-d', 'cert_2', '"d" mapping populuated from local');
}