You are here

function CourseObjectTest::testCourseObjectBasicCrud in Course 3.x

Test basic save/load of CourseObjects.

File

tests/src/Functional/CourseObjectTest.php, line 15

Class

CourseObjectTest
Tests Course objects

Namespace

Drupal\Tests\course\Functional

Code

function testCourseObjectBasicCrud() {
  $course = $this
    ->createCourse();

  // Create the course object
  $courseObject = $this
    ->createCourseObject($course);

  // Make sure the object saved.
  $this
    ->assertTrue($courseObject
    ->id() > 0, 'Course object received ID.');
  $id = $courseObject
    ->id();

  // Load by coid
  $courseObject = course_get_course_object_by_id($id);
  $this
    ->assertTrue($courseObject
    ->id() == $id, 'Loaded course object by ID.');

  // Delete
  $courseObject
    ->delete();
  $courseObject = course_get_course_object_by_id($id);
  $this
    ->assertFalse($courseObject, 'Check that deleted object no longer exists.');
}