You are here

function CourseAccessTestCase::testDurationExpiration in Course 7.2

Same name and namespace in other branches
  1. 6 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 23

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_enroll($courseNode, $user);

  // Expire the duration.
  $enroll = course_enrollment_load($courseNode, $user);
  $enroll->enroll_end = 1;
  course_enrollment_save($enroll);
  $result = course_access_course('take', $courseNode, $user, TRUE);
  $this
    ->assertFalse($result['success'], 'User cannot access course with expired enrollment.');
}