function CourseObjectBookTestCase::testBookCourseObject in Course 7
Same name and namespace in other branches
- 6 modules/course_book/course_book.test \CourseObjectBookTestCase::testBookCourseObject()
- 7.2 modules/course_book/course_book.test \CourseObjectBookTestCase::testBookCourseObject()
File
- modules/course_book/course_book.test, line 27
Class
- CourseObjectBookTestCase
- Tests for Book support in Course
Code
function testBookCourseObject() {
$courseNode = $this
->createCourseNode();
$co1 = course_get_course_object('course_book', 'book');
$co1
->setOption('book_tracking', 'all');
$co1
->setCourse($courseNode->nid);
$co1
->save();
$this
->assertTrue($co1
->getInstanceId() > 0, 'book node created on course object save.');
$bp1 = $this
->drupalCreateNode(array(
'type' => 'book',
'book' => array(
'bid' => $co1
->getInstanceId(),
),
));
$bp2 = $this
->drupalCreateNode(array(
'type' => 'book',
'book' => array(
'bid' => $co1
->getInstanceId(),
),
));
course_enroll($courseNode, $this->student_user);
$this
->assertFalse($co1
->getFulfillment($this->student_user)
->isComplete(), 'Check that book object is not complete.');
$this
->drupalLogin($this->student_user);
$this
->drupalGet("node/" . $co1
->getInstanceId());
$this
->drupalGet("node/{$bp1->nid}");
$this
->assertFalse($co1
->getFulfillment($this->student_user)
->isComplete(), 'Check that book object is not complete after visiting 2/3 pages.');
$this
->drupalGet("node/{$bp2->nid}");
$this
->assertTrue($co1
->getFulfillment($this->student_user)
->isComplete(), 'Check that book object is now complete after visiting 3/3 pages.');
}