function CourseObjectContentTestCase::testContentCourseObjectCreation in Course 8.3
Same name and namespace in other branches
- 8.2 modules/course_content/tests/src/Functional/CourseObjectContentTestCase.php \Drupal\Tests\course_content\Functional\CourseObjectContentTestCase::testContentCourseObjectCreation()
Test course content object creation.
File
- modules/
course_content/ tests/ src/ Functional/ CourseObjectContentTestCase.php, line 21
Class
- CourseObjectContentTestCase
- Tests content in courses.
Namespace
Drupal\Tests\course_content\FunctionalCode
function testContentCourseObjectCreation() {
$ct1 = $this
->drupalCreateContentType();
$ct1
->setThirdPartySetting('course_content', 'use', 1);
$ct1
->save();
// Save a new object, which should create a node with our new content type.
$course = $this
->createCourse();
$co1 = CourseObject::create([
'object_type' => 'content',
]);
$co1
->setCourse($course
->id());
$co1
->save();
// Reload course.
foreach ($course
->getObjects() as $courseObject) {
$node = Node::load($courseObject
->getInstanceId());
$this
->assertEqual($node
->bundle(), $ct1
->id(), "Node type saved is the same node type specified by the course object.");
}
}