function CourseEnrollmentTestCase::testCourseEnrollment in Course 7
Same name and namespace in other branches
- 6 tests/CourseEnrollmentTestCase.test \CourseEnrollmentTestCase::testCourseEnrollment()
- 7.2 tests/CourseEnrollmentTestCase.test \CourseEnrollmentTestCase::testCourseEnrollment()
Test for enrollment access and timestamping.
File
- tests/
CourseEnrollmentTestCase.test, line 20
Class
- CourseEnrollmentTestCase
- Tests for Course enrollment
Code
function testCourseEnrollment() {
global $user;
$courseNode = $this
->createCourseNode();
$result = course_enroll_access($courseNode);
$this
->assertTrue($result['success'], 'Check that the user is allowed to self enroll into this course.');
$result = course_take_course_access($courseNode);
$this
->assertFalse($result['success'], 'Check that the user cannot enroll in the course.');
course_enroll($courseNode, $user);
$result = course_take_course_access($courseNode, $user, TRUE);
$this
->assertTrue($result['success'], 'Check that the user can take the course.');
$enroll = course_enrollment_load($courseNode, $user);
$this
->assertTrue($enroll->eid > 0, 'Enrollment was created.');
$this
->assertTrue($enroll->created > 0, 'Enrollment has a creation timestamp.');
//$this->assertFalse($enroll->timestamp > 0, 'Check that user has not started course.');
// Take the course
course_take_course($courseNode);
$enroll = course_enrollment_load($courseNode, $user);
$this
->assertTrue($enroll->timestamp > 0, 'Check for start of course timestamp.');
}