CourseTestCase.test in Course 6
File
tests/CourseTestCase.test
View source
<?php
class CourseTestCase extends DrupalWebTestCase {
public function setUp() {
$deps = $this
->getModules();
call_user_func_array(array(
'parent',
'setUp',
), $deps);
$this->admin_user = $this
->drupalCreateUser(array(
'administer nodes',
'edit courses',
));
$this->student_user = $this
->drupalCreateUser(array(
'access content',
));
$this
->drupalLogin($this->admin_user);
course_get_handlers(NULL, TRUE);
autoload_flush_caches();
}
function createCourseNode(array $extra = array()) {
$node = $this
->drupalCreateNode(array(
'type' => 'course_test',
) + $extra);
return $node;
}
function getModules() {
return array(
'autoload',
'ahah_helper',
'ctools',
'uuid',
'course',
'course_test',
);
}
function createCourseObject($courseNode, $graded = FALSE) {
static $weight = 0;
if ($graded) {
$courseObject = course_get_course_object('course_test', 'course_test_graded_object');
}
else {
$courseObject = course_get_course_object('course_test', 'course_test_object');
}
$courseObject
->setCourse($courseNode->nid);
$courseObject
->setOption('weight', $weight++);
$courseObject
->save();
return $courseObject;
}
}