You are here

function CourseContextTestCase::testDetermineContext in Course 7.2

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

Testing finding course and objects via parameter search.

File

tests/CourseContextTestCase.test, line 20

Class

CourseContextTestCase
Tests for Course context

Code

function testDetermineContext() {
  $courseNode = $this
    ->createCourseNode();

  // Create an object and give it an instance.
  $co1 = $this
    ->createCourseObject($courseNode);
  $co1
    ->setInstanceId(1234)
    ->save();

  // Find course object via cgco.
  $find_co1 = course_get_course_object('course_test', 'course_test_object', 1234);
  $this
    ->assertEqual($co1
    ->getId(), $find_co1
    ->getId(), 'Found the same course object.');

  // Find the course via cdc.
  $find_course1 = course_determine_context('course_test', 'course_test_object', 1234);
  $this
    ->assertEqual($find_course1->nid, $courseNode->nid, 'Context came back to the same course.');
}