You are here

function CourseObjectSignupTestCase::testSignupEnrollment in Course 6

Same name and namespace in other branches
  1. 7.2 modules/course_signup/course_signup.test \CourseObjectSignupTestCase::testSignupEnrollment()
  2. 7 modules/course_signup/course_signup.test \CourseObjectSignupTestCase::testSignupEnrollment()

File

modules/course_signup/course_signup.test, line 35

Class

CourseObjectSignupTestCase
Test class for dealing with adding and removing elements from the course outline.

Code

function testSignupEnrollment() {
  global $user;

  // Create a signup node.
  $courseNode = $this
    ->createCourseNode(array(
    'signup_user_reg' => 0,
    'signup_enabled' => 1,
  ));

  // Sign the user up
  $form = array(
    'nid' => $courseNode->nid,
    'uid' => $user->uid,
  );
  $sid = signup_sign_up_user($form);

  // Check the enrollment.
  $enroll = course_enrolment_load($courseNode->nid, $user->uid);
  $this
    ->assertTrue($enroll->eid > 0, 'Found enrollment after signing up.');

  // Cancel the signup and check the enrollment.
  signup_cancel_signup($sid);
  $enroll = course_enrolment_load($courseNode->nid, $user->uid);
  $this
    ->assertFalse($enroll, 'Cancelled enrollment after cancelling signup.');
}