You are here

function CourseEnrollmentTestCase::testCourseDuration in Course 6

Same name and namespace in other branches
  1. 7.2 tests/CourseEnrollmentTestCase.test \CourseEnrollmentTestCase::testCourseDuration()
  2. 7 tests/CourseEnrollmentTestCase.test \CourseEnrollmentTestCase::testCourseDuration()

Test for course duration being set properly on enrollment.

File

tests/CourseEnrollmentTestCase.test, line 47

Class

CourseEnrollmentTestCase
Tests for Course enrollment

Code

function testCourseDuration() {
  global $user;
  $courseNode = $this
    ->createCourseNode();
  $courseNode->course['duration'] = 30;
  node_save($courseNode);
  $enroll = course_enrolment_load($courseNode, $user);
  $this
    ->assertFalse($enroll, 'Check that enrollment does not exist.');
  course_take_course($courseNode);
  $enroll = course_enrolment_load($courseNode, $user);
  $this
    ->assertTrue($enroll->enrol_end > time(), 'Duration end got set with course start.');
}