本文整理汇总了PHP中advanced_testcase::assertTrue方法的典型用法代码示例。如果您正苦于以下问题:PHP advanced_testcase::assertTrue方法的具体用法?PHP advanced_testcase::assertTrue怎么用?PHP advanced_testcase::assertTrue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类advanced_testcase
的用法示例。
在下文中一共展示了advanced_testcase::assertTrue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_user_and_enrol
/**
* creates a user and enroles him into the given course as teacher or student
* @param advanced_testcase $tc
* @param unknown $course
* @param string $is_teacher
* @param stdClass $user userobject to enrol.
* @return stdClass
*/
public static function create_user_and_enrol(advanced_testcase $tc, $course, $is_teacher = false, $user = NULL)
{
$user = $tc->getDataGenerator()->create_user();
if ($is_teacher) {
if (empty(self::$teacher_role)) {
global $DB;
// enrole teacher and student
self::$teacher_role = $DB->get_record('role', array('shortname' => 'editingteacher'));
}
$enroled = $tc->getDataGenerator()->enrol_user($user->id, $course->id, self::$teacher_role->id);
} else {
$enroled = $tc->getDataGenerator()->enrol_user($user->id, $course->id);
}
$tc->assertTrue($enroled, 'trying to enrol already enroled user');
return $user;
}