CourseObjectManualTest.php in Course 3.x
File
modules/course_object_manual/tests/src/Functional/CourseObjectManualTest.php
View source
<?php
namespace Drupal\Tests\course_object_manual\Functional;
use Drupal\course\Entity\CourseObject;
use Drupal\Tests\course\Functional\CourseObjectTest;
use function course_get_course_object_by_id;
class CourseObjectManualTest extends CourseObjectTest {
protected static $modules = [
'course_object_manual',
];
public function testCourseObjectManual() {
$account = $this
->drupalCreateUser();
$course = $this
->createCourse();
$co1 = CourseObject::create([
'object_type' => 'manual',
]);
$co1
->setCourse($course);
$co1
->save();
$course
->enroll($account);
$this
->drupalLogin($account);
$this
->drupalGet($co1
->getUrl());
$this
->assertText('Your instructor has not given you a pass/fail grade yet.');
$co1
->getFulfillment($account)
->setGrade(0)
->save();
$this
->drupalGet($co1
->getUrl());
$this
->assertText('Your instructor has marked you as failed.');
$co1
->getFulfillment($account)
->setGrade(100)
->setComplete(1)
->save();
$this
->drupalGet($co1
->getUrl());
$this
->assertText('Your instructor has marked you as passed.');
}
}