You are here

function CourseObjectAccessTestCase::testDisabledCourseObjects in Course 6

Same name and namespace in other branches
  1. 7.2 tests/CourseObjectAccessTestCase.test \CourseObjectAccessTestCase::testDisabledCourseObjects()
  2. 7 tests/CourseObjectAccessTestCase.test \CourseObjectAccessTestCase::testDisabledCourseObjects()

Test disabled course objects.

File

tests/CourseObjectAccessTestCase.test, line 124

Class

CourseObjectAccessTestCase
Tests for course object access.

Code

function testDisabledCourseObjects() {

  // Create a course.
  $courseNode = $this
    ->createCourseNode();

  // Use the student user.
  $user = $this->student_user;
  $o1 = $this
    ->createCourseObject($courseNode);

  // By default, should be visible.
  $this
    ->assertTrue($o1
    ->access('see', $user));

  // Make object enabled.
  $o1
    ->setOption('enabled', 1)
    ->save();
  $this
    ->assertTrue($o1
    ->access('see', $user));

  // Make object disabled.
  $o1
    ->setOption('enabled', 0)
    ->save();
  $this
    ->assertFalse($o1
    ->access('see', $user));
}