You are here

function CourseTestCase::createCourseObject in Course 7.2

Same name and namespace in other branches
  1. 6 tests/CourseTestCase.test \CourseTestCase::createCourseObject()
  2. 7 tests/CourseTestCase.test \CourseTestCase::createCourseObject()

Create a new persistent course object on a Course.

Parameters

stdClass $courseNode:

Return value

Course

17 calls to CourseTestCase::createCourseObject()
CourseContextTestCase::testDetermineContext in tests/CourseContextTestCase.test
Testing finding course and objects via parameter search.
CourseContextTestCase::testMultiContext in tests/CourseContextTestCase.test
Test objects that belong to multiple courses.
CourseGradeTestCase::testCourseFinalGrade in tests/CourseGradeTestCase.test
Test that the final grade is calculated correctly.
CourseGradeTestCase::testCourseGradeAccess in tests/CourseGradeTestCase.test
Test that the course grade access plugin functions properly.
CourseObjectAccessConditionalTestCase::testTimeAfterCompletion in tests/CourseObjectAccessConditionalTestCase.test
Test the completion based trigger for object access.

... See full list

File

tests/CourseTestCase.test, line 42

Class

CourseTestCase
Master class for Course tests.

Code

function createCourseObject($courseNode, $graded = FALSE) {
  static $weight = 0;
  if ($graded) {
    $courseObject = course_get_course_object('course_test', 'course_test_graded_object');
  }
  else {
    $courseObject = course_get_course_object('course_test', 'course_test_object');
  }
  $courseObject
    ->setCourse($courseNode->nid);
  $courseObject
    ->setOption('weight', $weight++);
  $courseObject
    ->save();
  return $courseObject;
}