course_signup.test in Course 6
File
modules/course_signup/course_signup.test
View source
<?php
require_once drupal_get_path('module', 'course') . '/tests/CourseTestCase.test';
module_load_include('inc', 'signup', 'includes/scheduler');
class CourseObjectSignupTestCase extends CourseTestCase {
public static function getInfo() {
return array(
'name' => 'Course signup',
'description' => 'Ensure that the Course signup integration functions properly.',
'group' => 'Course',
);
}
public function getModules() {
$modules = parent::getModules();
$modules[] = 'signup';
$modules[] = 'course_signup';
return $modules;
}
function setUp() {
parent::setUp();
variable_set('signup_node_default_state_course_test', 'enabled_on');
}
function testSignupEnrollment() {
global $user;
$courseNode = $this
->createCourseNode(array(
'signup_user_reg' => 0,
'signup_enabled' => 1,
));
$form = array(
'nid' => $courseNode->nid,
'uid' => $user->uid,
);
$sid = signup_sign_up_user($form);
$enroll = course_enrolment_load($courseNode->nid, $user->uid);
$this
->assertTrue($enroll->eid > 0, 'Found enrollment after signing up.');
signup_cancel_signup($sid);
$enroll = course_enrolment_load($courseNode->nid, $user->uid);
$this
->assertFalse($enroll, 'Cancelled enrollment after cancelling signup.');
}
}