protected function OpignoWebTestCase::createCourse in Opigno 7
Create a course and assign members to it.
Parameters
string $title = NULL:
object $creator = NULL:
int $private = NULL:
array $members = array(): A 2-dimensional array, where the key is the user ID and the value an array of roles. Ex: array(12 => array('manager', 'teacher'))
Return value
object
File
- tests/
OpignoWebTestCase.test, line 71 - Defines the base class for Opigno unit testing. This base class contains re-usable logic that will make it easier and faster to write Opigno-specific unit tests.
Class
- OpignoWebTestCase
- @file Defines the base class for Opigno unit testing. This base class contains re-usable logic that will make it easier and faster to write Opigno-specific unit tests.
Code
protected function createCourse($title = NULL, $creator = NULL, $private = NULL, $members = array()) {
$settings = array(
'type' => OPIGNO_COURSE_BUNDLE,
'title' => $title ? $title : $this
->randomName(8),
'body' => array(
LANGUAGE_NONE => array(
array(
'value' => $this
->randomName(16),
),
),
),
);
if (!empty($creator->uid)) {
$settings['uid'] = $creator->uid;
}
if (isset($private)) {
$settings['group_access'][LANGUAGE_NONE][0]['value'] = $private;
}
$node = $this
->drupalCreateNode($settings);
$this
->assertTrue(!empty($node->nid), 'Created a new course.');
if (!empty($members)) {
foreach ($members as $uid => $roles) {
$this
->addMemberToCourse($node, $uid, $roles);
}
}
return $node;
}