You are here

public function CourseObjectAccessTimeTestCase::testCourseObjectRestrictByRelease in Course 6

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

Test course object open date.

File

tests/CourseObjectAccessTimeTestCase.test, line 22

Class

CourseObjectAccessTimeTestCase
Tests for course object access based on time.

Code

public function testCourseObjectRestrictByRelease() {
  $now = time();
  $courseNode = $this
    ->createCourseNode();
  $options = array();

  // Test restricting by release.
  $o1 = $this
    ->createCourseObject($courseNode);

  // Set the release to 100 seconds in the future.
  $options['plugins']['access']['timing']['release'] = gmdate('c', $now + 100);
  $o1
    ->addOptions($options);
  $this
    ->assertFalse($o1
    ->access('take'), 'Check that user cannot take not released object.');
  $this
    ->assertTrue($o1
    ->access('see'), 'Check that user can still see not released object.');

  // Set the hide until release option.
  $options['plugins']['access']['timing']['release_hidden'] = 1;
  $o1
    ->addOptions($options);
  $this
    ->assertFalse($o1
    ->access('see'), 'Check that object is hidden if hidden is checked and object is not released.');
}