Skip to content

Commit

Permalink
MDL-65323 core_favourites: replace use of deprecated phpunit methods
Browse files Browse the repository at this point in the history
  • Loading branch information
snake committed Sep 13, 2019
1 parent a672f02 commit 35500af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions favourites/tests/repository_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function test_add_all_basic() {
$timenow = time(); // Reference only, to check that the created item has a time equal to or greater than this.
$favourites = $favouritesrepo->add_all($favcourses);

$this->assertInternalType('array', $favourites);
$this->assertIsArray($favourites);
$this->assertCount(2, $favourites);
foreach ($favourites as $favourite) {
// Verify we get the favourite back.
Expand Down Expand Up @@ -304,12 +304,12 @@ public function test_find_by() {

// From the repo, get the list of favourites for the 'core_course/course' area.
$userfavourites = $favouritesrepo->find_by(['component' => 'core_course', 'itemtype' => 'course']);
$this->assertInternalType('array', $userfavourites);
$this->assertIsArray($userfavourites);
$this->assertCount(1, $userfavourites);

// Try to get a list of favourites for a non-existent area.
$userfavourites = $favouritesrepo->find_by(['component' => 'core_cannibalism', 'itemtype' => 'course']);
$this->assertInternalType('array', $userfavourites);
$this->assertIsArray($userfavourites);
$this->assertCount(0, $userfavourites);
}

Expand Down Expand Up @@ -496,7 +496,7 @@ public function test_update() {
$favourite1->ordering = 1;
$favourite1 = $favouritesrepo->update($favourite1);
$this->assertInstanceOf(favourite::class, $favourite1);
$this->assertAttributeEquals('1', 'ordering', $favourite1);
$this->assertEquals('1', $favourite1->ordering);
}

public function test_delete() {
Expand Down
16 changes: 8 additions & 8 deletions favourites/tests/user_favourite_service_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,14 @@ public function test_find_favourites_by_type_single_user() {

// Verify we can get favourites by area.
$favourites = $service->find_favourites_by_type('core_course', 'course');
$this->assertInternalType('array', $favourites);
$this->assertIsArray($favourites);
$this->assertCount(1, $favourites); // We only get favourites for the 'core_course/course' area.
$this->assertAttributeEquals($fav1->id, 'id', $favourites[$fav1->id]);
$this->assertEquals($fav1->id, $favourites[$fav1->id]->id);

$favourites = $service->find_favourites_by_type('core_course', 'anothertype');
$this->assertInternalType('array', $favourites);
$this->assertIsArray($favourites);
$this->assertCount(1, $favourites); // We only get favourites for the 'core_course/course' area.
$this->assertAttributeEquals($fav2->id, 'id', $favourites[$fav2->id]);
$this->assertEquals($fav2->id, $favourites[$fav2->id]->id);
}

/**
Expand All @@ -252,14 +252,14 @@ public function test_find_favourites_by_type_multiple_users() {

// Verify find_favourites_by_type only returns results for the user to which the service is scoped.
$user1favourites = $user1service->find_favourites_by_type('core_course', 'course');
$this->assertInternalType('array', $user1favourites);
$this->assertIsArray($user1favourites);
$this->assertCount(1, $user1favourites); // We only get favourites for the 'core_course/course' area for $user1.
$this->assertAttributeEquals($fav1->id, 'id', $user1favourites[$fav1->id]);
$this->assertEquals($fav1->id, $user1favourites[$fav1->id]->id);

$user2favourites = $user2service->find_favourites_by_type('core_course', 'course');
$this->assertInternalType('array', $user2favourites);
$this->assertIsArray($user2favourites);
$this->assertCount(1, $user2favourites); // We only get favourites for the 'core_course/course' area for $user2.
$this->assertAttributeEquals($fav2->id, 'id', $user2favourites[$fav2->id]);
$this->assertEquals($fav2->id, $user2favourites[$fav2->id]->id);
}

/**
Expand Down

0 comments on commit 35500af

Please sign in to comment.