You are here

function CourseAccessTestCase::testDurationExpiration in Course 6

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

Test the enrollment duration. This does not test the enrollment end date being set correctly.

See also

CourseEnrollmentTestCase::testCourseDuration()

File

tests/CourseAccessTestCase.test, line 25

Class

CourseAccessTestCase
Tests for conditional event-based access to course objects.

Code

function testDurationExpiration() {
  global $user;
  $courseNode = $this
    ->createCourseNode();

  // Set expiration to 30 days.
  $courseNode->course['duration'] = 30;
  node_save($courseNode);
  course_enrol($courseNode, $user);

  // Expire the duration.
  $enroll = course_enrolment_load($courseNode, $user);
  $enroll->enrol_end = 1;
  course_enrolment_save($enroll);
  $result = course_take_course_access($courseNode, $user, TRUE);
  $this
    ->assertFalse($result['success'], 'User cannot access course with expired enrollment.');
}