CourseObjectTest.php in Course 3.x
File
tests/src/Functional/CourseObjectTest.php
View source
<?php
namespace Drupal\Tests\course\Functional;
class CourseObjectTest extends CourseTestBase {
function testCourseObjectBasicCrud() {
$course = $this
->createCourse();
$courseObject = $this
->createCourseObject($course);
$this
->assertTrue($courseObject
->id() > 0, 'Course object received ID.');
$id = $courseObject
->id();
$courseObject = course_get_course_object_by_id($id);
$this
->assertTrue($courseObject
->id() == $id, 'Loaded course object by ID.');
$courseObject
->delete();
$courseObject = course_get_course_object_by_id($id);
$this
->assertFalse($courseObject, 'Check that deleted object no longer exists.');
}
function testCourseObjectConfigurations() {
$courseNode = $this
->createCourse();
$co1 = $this
->createCourseObject($courseNode);
$co1
->setOption('test_option', 'FIND_ME');
$co1
->save();
$id = $co1
->id();
$co2 = course_get_course_object_by_id($id);
$this
->assertEqual($co2
->getOption('test_option'), 'FIND_ME', 'Check that options save and load successfully.');
}
function xtestCourseObjectConstruction() {
$course = $this
->createCourse();
$this
->createCourseObject($course);
$courseObjects = array_values($course
->getObjects());
$courseObject = reset($courseObjects);
$getCourse = $courseObject
->getCourse();
$this
->assertEqual(spl_object_hash($course), spl_object_hash($getCourse), 'Check that Courses inside of CourseObjects inside of Course are the same.');
}
}