function CourseTestBase::createCourseObject in Course 3.x
Create a new persistent course object on a Course.
Parameters
Course $course:
Return value
17 calls to CourseTestBase::createCourseObject()
- CourseContextTest::testDetermineContext in tests/
src/ Functional/ CourseContextTest.php - Testing finding course and objects via parameter search.
- CourseContextTest::testMultiContext in tests/
src/ Functional/ CourseContextTest.php - Test objects that belong to multiple courses.
- CourseGradeTest::testCourseFinalGrade in tests/
src/ Functional/ CourseGradeTest.php - Test that the final grade is calculated correctly.
- CourseGradeTest::testCourseGradeAccess in tests/
src/ Functional/ CourseGradeTest.php - Test that the course grade access plugin functions properly.
- CourseObjectAccessConditionalTest::testTimeAfterCompletion in tests/
src/ Functional/ CourseObjectAccessConditionalTest.php - Test the completion based trigger for object access.
File
- tests/
src/ Functional/ CourseTestBase.php, line 60
Class
- CourseTestBase
- Master class for Course tests.
Namespace
Drupal\Tests\course\FunctionalCode
function createCourseObject(Course $course, $graded = FALSE) {
static $weight = 0;
if ($graded) {
$courseObject = CourseObject::create([
'object_type' => 'course_test_graded_object',
]);
}
else {
$courseObject = CourseObject::create([
'object_type' => 'course_test_object',
]);
}
$courseObject
->setCourse($course);
$courseObject
->setOption('weight', $weight++);
$courseObject
->save();
return $courseObject;
}