Skip to content

Commit

Permalink
MDL-82119 exemptions: CI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Fragonite committed Aug 14, 2024
1 parent 9aae4a9 commit e23294d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public function find_by(array $criteria, int $limitfrom = 0, int $limitnum = 0):
*/
public function find_exemption(string $component, string $itemtype, int $itemid, int $contextid): exemption {
global $DB;
// exemptions model: We know that only one exemption can exist based on these properties.
// Exemptions model: We know that only one exemption can exist based on these properties.
$record = $DB->get_record($this->exemptiontable, [
'component' => $component,
'itemtype' => $itemtype,
Expand Down
26 changes: 26 additions & 0 deletions exemptions/tests/component_exemption_service_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ protected function get_mock_repository(array $mockstore) {

/**
* Test confirming the deletion of exemptions by type and item, but with no optional context filter provided.
*
* @covers ::delete_exemptions_by_type_and_item
*/
public function test_delete_exemptions_by_type_and_item(): void {
[$user1context, $user2context, $course1context, $course2context] = $this->setup_users_and_courses();
Expand Down Expand Up @@ -243,6 +245,8 @@ public function test_delete_exemptions_by_type_and_item(): void {

/**
* Test confirming the deletion of exemptions by type and item and with the optional context filter provided.
*
* @covers ::delete_exemptions_by_type_and_item
*/
public function test_delete_exemptions_by_type_and_item_with_context(): void {
[$user1context, $user2context, $course1context, $course2context] = $this->setup_users_and_courses();
Expand Down Expand Up @@ -300,6 +304,8 @@ public function test_delete_exemptions_by_type_and_item_with_context(): void {

/**
* Test getting a component_exemption_service from the static locator.
*
* @covers ::get_service_for_component
*/
public function test_get_service_for_component(): void {
$userservice = \core_exemptions\service_factory::get_service_for_component('core_course');
Expand All @@ -308,6 +314,8 @@ public function test_get_service_for_component(): void {

/**
* Test confirming an item can be exempt only once.
*
* @covers ::create_exemption
*/
public function test_create_exemption_basic(): void {
[$user1context, $user2context, $course1context, $course2context] = $this->setup_users_and_courses();
Expand All @@ -327,6 +335,8 @@ public function test_create_exemption_basic(): void {

/**
* Test confirming that an exception is thrown if trying to create an item for a non-existent component.
*
* @covers ::__construct
*/
public function test_create_exemption_nonexistent_component(): void {
// Get a component_exemption_service for the user.
Expand All @@ -339,6 +349,8 @@ public function test_create_exemption_nonexistent_component(): void {

/**
* Test fetching exemptions for single user, by area.
*
* @covers ::find_exemptions_by_type
*/
public function test_find_exemptions_by_type_single_user(): void {
[$user1context, $user2context, $course1context, $course2context] = $this->setup_users_and_courses();
Expand All @@ -365,6 +377,8 @@ public function test_find_exemptions_by_type_single_user(): void {

/**
* Test fetching exemptions for single user, by area.
*
* @covers ::find_all_exemptions
*/
public function test_find_all_exemptions(): void {
[$user1context, $user2context, $course1context, $course2context] = $this->setup_users_and_courses();
Expand Down Expand Up @@ -401,6 +415,8 @@ public function test_find_all_exemptions(): void {

/**
* Test confirming the pagination support for the find_exemptions_by_type() method.
*
* @covers ::find_exemptions_by_type
*/
public function test_find_exemptions_by_type_pagination(): void {
[$user1context, $user2context, $course1context, $course2context] = $this->setup_users_and_courses();
Expand Down Expand Up @@ -432,6 +448,8 @@ public function test_find_exemptions_by_type_pagination(): void {

/**
* Test confirming the basic deletion behaviour.
*
* @covers ::delete_exemption
*/
public function test_delete_exemption_basic(): void {
[$user1context, $user2context, $course1context, $course2context] = $this->setup_users_and_courses();
Expand All @@ -457,6 +475,8 @@ public function test_delete_exemption_basic(): void {

/**
* Test confirming the behaviour of the exemption_exists() method.
*
* @covers ::exemption_exists
*/
public function test_exemption_exists(): void {
[$user1context, $user2context, $course1context, $course2context] = $this->setup_users_and_courses();
Expand Down Expand Up @@ -489,6 +509,8 @@ public function test_exemption_exists(): void {

/**
* Test confirming the behaviour of the get_exemption() method.
*
* @covers ::get_exemption
*/
public function test_get_exemption(): void {
[$user1context, $user2context, $course1context, $course2context] = $this->setup_users_and_courses();
Expand Down Expand Up @@ -520,6 +542,8 @@ public function test_get_exemption(): void {

/**
* Test confirming the behaviour of the count_exemptions_by_type() method.
*
* @covers ::count_exemptions_by_type
*/
public function test_count_exemptions_by_type(): void {
[$user1context, $user2context, $course1context, $course2context] = $this->setup_users_and_courses();
Expand Down Expand Up @@ -550,6 +574,8 @@ public function test_count_exemptions_by_type(): void {

/**
* Verify that the join sql generated by get_join_sql_by_type is valid and can be used to include exemption information.
*
* @covers ::get_join_sql_by_type
*/
public function test_get_join_sql_by_type(): void {
global $DB;
Expand Down

0 comments on commit e23294d

Please sign in to comment.