function CourseObjectWebformTestCase::testWebformCourseObject in Course 6
Same name and namespace in other branches
- 7.2 modules/course_webform/course_webform.test \CourseObjectWebformTestCase::testWebformCourseObject()
- 7 modules/course_webform/course_webform.test \CourseObjectWebformTestCase::testWebformCourseObject()
File
- modules/
course_webform/ course_webform.test, line 32
Class
- CourseObjectWebformTestCase
- Tests for conditional event-based access to course objects.
Code
function testWebformCourseObject() {
$this
->drupalLogin($this->webform_admin);
// Create a course with 1 webform.
$courseNode = $this
->createCourseNode();
$co1 = course_get_course_object('course_webform', 'webform');
$co1
->setCourse($courseNode->nid);
$co1
->save();
$this
->assertTrue($co1
->getInstanceId() > 0, 'Webform node created on course object save.');
$webformNode = node_load($co1
->getInstanceId());
$this
->assertTrue($webformNode->type == 'webform', 'Webform node is a webform.');
// Add a question.
$this
->drupalGet("node/{$webformNode->nid}/webform");
$this
->drupalPost(NULL, array(
'add[name]' => 'test',
'add[type]' => 'textfield',
), 'Add');
$this
->drupalPost(NULL, array(), 'Save component');
// Take the webform.
$this
->drupalGet("node/{$webformNode->nid}");
$this
->assertFalse($co1
->getFulfillment()
->isComplete(), 'Check that webform is not completed yet.');
$this
->drupalPost(NULL, array(
'submitted[test]' => 1,
), 'Submit');
// Reload because something happened in the DB.
$co1 = course_get_course_object_by_id($co1
->getId(), $this->webform_admin);
$this
->assertTrue($co1
->getFulfillment()
->isComplete(), 'Check that webform is completed.');
}