| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
class DPIStudyUndergradTest extends DrupalTestCase {
|
| 5 |
function get_info() {
|
| 6 |
return array(
|
| 7 |
'name' => t('Undergrad'),
|
| 8 |
'desc' => t('Do a run through the DPI study as an undergraduate.'),
|
| 9 |
'group' => 'DPI Study'
|
| 10 |
);
|
| 11 |
}
|
| 12 |
|
| 13 |
function setUp() {
|
| 14 |
parent::setUp();
|
| 15 |
|
| 16 |
$this->drupalModuleEnable('dpistudy');
|
| 17 |
$this->drupalVariableSet('dpistudy_irb_consent_active', '1');
|
| 18 |
}
|
| 19 |
|
| 20 |
function tearDown() {
|
| 21 |
parent::tearDown();
|
| 22 |
}
|
| 23 |
|
| 24 |
function testParticipate() {
|
| 25 |
|
| 26 |
$url = $this->drupalGet('/dpistudy/?k=ugrd');
|
| 27 |
|
| 28 |
$session_id = getCookie('sessid');
|
| 29 |
|
| 30 |
$this->assertText('Get your Digital Propensity Index score!');
|
| 31 |
$this->assertText('not sure. Take me somewhere else.');
|
| 32 |
|
| 33 |
$this->clickSubmit(t('I consent'));
|
| 34 |
|
| 35 |
$this->assertText('Digital Propensity Index Questionnaire');
|
| 36 |
|
| 37 |
// 0 should unset the field as if the question was omitted by the participant
|
| 38 |
for ($i=1; $i<47; $this->setField("question_$i", rand(0, 3)), $i++);
|
| 39 |
|
| 40 |
$this->clickSubmit(t('Submit'));
|
| 41 |
|
| 42 |
for ($i=5; $i>=1; $i--) {
|
| 43 |
$this->assertText(t('Just @num more!', array('@num' => $i)));
|
| 44 |
$this->assertText(t('This question is timed'));
|
| 45 |
$this->clickSubmit(t('Submit'));
|
| 46 |
}
|
| 47 |
$this->assertText(t('Last one!'));
|
| 48 |
$this->assertText(t('This question is timed'));
|
| 49 |
$this->clickSubmit(t('Submit'));
|
| 50 |
|
| 51 |
$this->assertText(t('Your Digital Propensity Index score!'));
|
| 52 |
$this->assertPattern(t('/Your Digital Propensity Index score is <strong>\d+<\/strong>\. A score of \d+ would represent the far extreme Digital Immigrant as opposed to the other extreme of \d+ for a pure Digital Native\./'));
|
| 53 |
|
| 54 |
$url = url('logout', array('absolute' => TRUE));
|
| 55 |
$this->get($url);
|
| 56 |
}
|
| 57 |
}
|