CourseObjectTestCase.test in Course 6
File
tests/CourseObjectTestCase.test
View source
<?php
require_once drupal_get_path('module', 'course') . '/tests/CourseTestCase.test';
class CourseObjectTestCase extends CourseTestCase {
public static function getInfo() {
return array(
'name' => 'Course objects',
'description' => 'Ensure that Course objects function properly.',
'group' => 'Course',
);
}
function testCourseObjectBasicCrud() {
$courseNode = $this
->createCourseNode();
$courseObject = $this
->createCourseObject($courseNode);
$this
->assertTrue($courseObject
->getId() > 0, 'Course object received ID.');
$id = $courseObject
->getId();
$courseObject = course_get_course_object_by_id($id);
$this
->assertTrue($courseObject
->getId() == $id, 'Loaded course object by ID.');
course_outline_delete_object($courseObject
->getOptions());
$courseObject = course_get_course_object_by_id($id);
$this
->assertFalse($courseObject, 'Check that deleted object no longer exists.');
}
function testCourseObjectConfigurations() {
$courseNode = $this
->createCourseNode();
$co1 = $this
->createCourseObject($courseNode);
$co1
->setOption('test_option', 'FIND_ME');
$co1
->save();
$id = $co1
->getId();
$co2 = course_get_course_object_by_id($id);
$this
->assertEqual($co2
->getOption('test_option'), 'FIND_ME', 'Check that options save and load successfully.');
}
function testCourseObjectConstruction() {
$courseNode = $this
->createCourseNode();
$this
->createCourseObject($courseNode);
$course = course_get_course($courseNode);
$courseObject = reset($course
->getObjects());
$getCourse = $courseObject
->getCourse();
$this
->assertEqual(spl_object_hash($course), spl_object_hash($getCourse), 'Check that Courses inside of CourseObjects inside of Course are the same.');
}
}