Skip to content

Commit

Permalink
Update for Course tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kusaljayawardhana committed Oct 21, 2024
1 parent c336825 commit a53c9b0
Showing 1 changed file with 82 additions and 28 deletions.
110 changes: 82 additions & 28 deletions tests/Feature/Backend/Courses/CourseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,60 +32,114 @@ public function a_course_manager_can_access_the_create_course_page()
/** @test */
public function a_course_can_be_created_via_livewire()
{
$this->loginAsCourseManager();

$semester = Semester::factory()->create();

Livewire::test(\App\Http\Livewire\Backend\CreateCourses::class)
->set('academicProgram', 'undergraduate')
->set('semester', (string) $semester->id)
->set('version', '1')
->set('type', 'Core')
->set('code', 'CS101')
->set('name', 'Introduction to Computer Science')
->set('credits', 3)
->set('content', 'Basic concepts of computer science.')
->set('objectives', 'Learn the basics of computer science')
->set('time_allocation', ['lecture' => 3, 'tutorial' => 1, 'practical' => 1])
->set('marks_allocation', ['practicals' => 20, 'mid_exam' => 30, 'end_exam' => 50])
->set('ilos', ['knowledge' => ['Understand basic algorithms'], 'skills' => ['Implement basic programs']])
->set('references', ['Introduction to Algorithms'])
->call('submit')
->assertHasNoErrors();
$this->loginAsCourseManager();

$semester = Semester::factory()->create([
'academic_program' => 'undergraduate',
'version' => '1',
]);

Livewire::test(\App\Http\Livewire\Backend\CreateCourses::class)

->set('academicProgram', 'undergraduate')
->set('version', '1')
->set('semester', (string) $semester->id)
->set('type', 'Core')
->set('code', 'CL101')
->set('name', 'Introduction to Computer Science')
->set('credits', 3)
->set('content', 'Basic concepts of computer science.')
->set('teaching_methods', 'Lecture and practical')
->set('time_allocation', ['lecture' => 3, 'tutorial' => 1, 'practical' => 1])
->set('marks_allocation', ['practicals' => 20, 'mid_exam' => 30, 'end_exam' => 50])
->call('next')
->assertHasNoErrors()

->set('objectives', 'Learn the basics of computer science')
->set('ilos', [
'knowledge' => ['Understand basic algorithms'],
'skills' => ['Implement basic programs']
])
->call('next')
->assertHasNoErrors()

->set('references', ['Introduction to Algorithms'])
->set('modules', [
[
'name' => 'Module 1',
'description' => 'Introduction to programming',
'time_allocation' => ['lectures' => 2, 'tutorials' => 1, 'practicals' => 1]
]
])
->call('submit')
->assertHasNoErrors();

$this->assertDatabaseHas('courses', [
'code' => 'CS101',
'code' => 'CL101',
'name' => 'Introduction to Computer Science',
'credits' => 3,
'type' => 'Core',
]);
}


/** @test */
public function a_course_can_be_updated_via_livewire()
{
$this->loginAsCourseManager();
$course = Course::factory()->create();

Livewire::test(\App\Http\Livewire\Backend\EditCourses::class)
->set('course', $course)
$course = Course::factory()->create([
'academic_program' => 'undergraduate',
'version' => '1',
'type' => 'Core',
]);

$semester = Semester::factory()->create([
'academic_program' => 'undergraduate',
'version' => '1',
]);

Livewire::test(\App\Http\Livewire\Backend\EditCourses::class, ['course' => $course])
->set('academicProgram', $course->academic_program)
->set('semester', (string) $course->semester_id)
->set('version', (string) $course->version)
->set('semester', (string) $semester->id)
->set('type', $course->type)
->set('code', 'CS102')
->set('name', 'Advanced Computer Science')
->set('credits', 3)
->set('content', 'Advanced topics in computer science.')
->set('objectives', 'Learn advanced topics')
->set('teaching_methods', 'Lecture and practical')
->set('time_allocation', ['lecture' => 3, 'tutorial' => 1, 'practical' => 2])
->set('marks_allocation', ['practicals' => 30, 'mid_exam' => 20, 'end_exam' => 50])
->set('ilos', ['knowledge' => ['Understand advanced algorithms']])
->call('next')
->assertHasNoErrors()

->set('objectives', 'Learn advanced topics')
->set('ilos', [
'knowledge' => ['Understand advanced algorithms'],
'skills' => ['Implement advanced programs']
])
->call('next')
->assertHasNoErrors()

->set('references', ['Advanced Algorithms'])
->call('submit')
->set('modules', [
[
'name' => 'Module 1',
'description' => 'Advanced programming concepts',
'time_allocation' => ['lectures' => 2, 'tutorials' => 1, 'practicals' => 2]
]
])
->call('update')
->assertHasNoErrors();

$this->assertDatabaseHas('courses', [
'id' => $course->id,
'code' => 'CS102',
'name' => 'Advanced Computer Science',
'credits' => 3,
'type' => 'Core',
'content' => 'Advanced topics in computer science.',
]);
}

Expand Down

0 comments on commit a53c9b0

Please sign in to comment.