You are here

function CourseObjectTestCase::testCourseObjectBasicCrud in Course 8.2

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/CourseObjectTestCase.php \Drupal\Tests\course\Functional\CourseObjectTestCase::testCourseObjectBasicCrud()

Test basic save/load of CourseObjects.

File

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

Class

CourseObjectTestCase
Description of CourseObjectTestCase

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
    ->getId() > 0, 'Course object received ID.');
  $id = $courseObject
    ->getId();

  // Load by coid
  $courseObject = course_get_course_object_by_id($id);
  $this
    ->assertTrue($courseObject
    ->getId() == $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.');
}