You are here

function CourseObjectSignupTestCase::testSignupCourseObject in Course 7.2

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

Test the fulfillment of an attendance object.

File

modules/course_signup/course_signup.test, line 65

Class

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

Code

function testSignupCourseObject() {

  // Create a course with 1 signup.
  $courseNode = $this
    ->createCourseNode(array(
    'signup_user_reg' => 0,
    'signup_enabled' => 1,
    'signup_status' => 1,
  ));
  $co1 = course_get_course_object('course_signup', 'signup_attendance');
  $co1
    ->setCourse($courseNode->nid);
  $co1
    ->save();
  $this
    ->assertEqual($co1
    ->getInstanceId(), $courseNode->nid, 'Signup node is the course node.');

  // Enroll the user in the course
  course_enroll($courseNode, $this->student_user);
  $co1 = course_get_course_object_by_id($co1
    ->getId());
  $this
    ->assertFalse($co1
    ->getFulfillment($this->student_user)
    ->isComplete(), 'Object not complete.');
  $co1
    ->takeCourseObject();
  $this
    ->assertFalse($co1
    ->getFulfillment($this->student_user)
    ->isComplete(), 'Object still not complete after taking.');

  // Get signup and mark it attended.
  $signup = db_query("SELECT * FROM {signup_log} WHERE nid = :nid and uid = :uid", array(
    ':nid' => $courseNode->nid,
    ':uid' => $this->student_user->uid,
  ))
    ->fetch();
  signup_mark_attended_action($signup);
  $this
    ->assertTrue($co1
    ->getFulfillment($this->student_user)
    ->isComplete(), 'Check that attendance is completed.');
}