CourseOutlineUiTestCase.test in Course 7.2
File
tests/CourseOutlineUiTestCase.test
View source
<?php
class CourseOutlineUiTestCase extends CourseTestCase {
public static function getInfo() {
return array(
'name' => 'Course outline',
'description' => 'Ensure that the Course outline functions properly.',
'group' => 'Course',
);
}
function createCourseObjectUi($courseNode) {
$edit = array();
$edit["more[object_type]"] = 'course_test-course_test_object';
$this
->drupalPost(NULL, $edit, t('Add object'));
$this
->assertText(t('Test course object'));
}
function testCourseOutlineCrud() {
$courseNode = $this
->createCourseNode();
$this
->drupalGet("node/{$courseNode->nid}/course-outline");
$this
->createCourseObjectUi($courseNode);
$this
->clickLink('Settings');
}
function testCourseOutlineMaxOccurences() {
$courseNode = $this
->createCourseNode();
$this
->drupalGet("node/{$courseNode->nid}/course-outline");
$this
->createCourseObjectUi($courseNode);
$this
->createCourseObjectUi($courseNode);
$elements = $this
->xpath('//select[@id=:id]//option[@value=:option]', array(
':id' => 'edit-more-object-type',
':option' => 'course_test-course_test_object',
));
$this
->assertTrue((bool) $elements, 'User able to add up to maxOccurances of course objects.');
$this
->createCourseObjectUi($courseNode);
$elements = $this
->xpath('//select[@id=:id]//option[@value=:option]', array(
':id' => 'edit-more-object-type',
':option' => 'course_test-course_test_object',
));
$this
->assertFalse((bool) $elements, 'User was not able to add more than maxOccurances of course objects.');
}
function testObjectDeletion() {
$this
->testCourseOutlineCrud();
$this
->drupalPost(NULL, array(), t('Delete'));
$this
->assertText('Object will be removed from outline');
$this
->drupalPost(NULL, array(), t('Save outline'));
$this
->assertNoText(t('Test course object'));
}
}