public function CourseObjectAccessTimeTestCase::testCourseObjectRestrictByExpiration in Course 7.2
Same name and namespace in other branches
- 6 tests/CourseObjectAccessTimeTestCase.test \CourseObjectAccessTimeTestCase::testCourseObjectRestrictByExpiration()
- 7 tests/CourseObjectAccessTimeTestCase.test \CourseObjectAccessTimeTestCase::testCourseObjectRestrictByExpiration()
Test course object expiration date.
File
- tests/
CourseObjectAccessTimeTestCase.test, line 44
Class
- CourseObjectAccessTimeTestCase
- Tests for course object access based on time.
Code
public function testCourseObjectRestrictByExpiration() {
$now = REQUEST_TIME;
$courseNode = $this
->createCourseNode();
$options = array();
global $user;
// Test restricting by expiration.
$o2 = $this
->createCourseObject($courseNode);
// Set the expiration to 10 seconds ago.
$options['plugins']['access']['timing']['expiration'] = gmdate('c', $now - 100);
$o2
->addOptions($options)
->save();
$this
->assertFalse($o2
->access('take', $user), 'Check that user cannot take expired course object.');
$this
->assertTrue($o2
->access('see', $user), 'Check that user can see expired course object.');
// Set the hide when expired option.
$options['plugins']['access']['timing']['expiration_hidden'] = 1;
$o2
->addOptions($options)
->save();
$this
->assertFalse($o2
->access('see', $user), 'Check that object is hidden if hidden is checked and object is expired.');
}