Skip to content

Commit

Permalink
php 8.2 compatibilite: fix "Class "local_entities_external" not found…
Browse files Browse the repository at this point in the history
…" and similar error s in phpunit tests
  • Loading branch information
semteacher committed Nov 21, 2023
1 parent 7b6570d commit 4eb4ef3
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tests/external_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@

namespace local_entities;

use advanced_testcase;
use invalid_response_exception;
use invalid_parameter_exception;
use moodle_exception;
use external_api;
use local_entities_external;

/**
* Tests for the external class of local_entities.
*
Expand All @@ -34,7 +41,7 @@
* - list_all_subentries
* Tests are parameterised, i.e. there's a data provider for each
*/
class external_test extends \advanced_testcase {
class external_test extends advanced_testcase {

/**
* data for unit tests of update_entity that are expected to run without exceptions
Expand Down Expand Up @@ -83,8 +90,8 @@ public function update_exceptions_data_provider(): array {
public function test_local_entities_update_entity($id, $data, $expected) {
$this->resetAfterTest(true);
$this->setAdminUser();
$resultraw = \local_entities_external::update_entity($id, $data);
$result = \external_api::clean_returnvalue(\local_entities_external::update_entity_returns(), $resultraw);
$resultraw = local_entities_external::update_entity($id, $data);
$result = external_api::clean_returnvalue(local_entities_external::update_entity_returns(), $resultraw);
$this->assertEquals($expected, $result);
}

Expand All @@ -96,14 +103,14 @@ public function test_local_entities_update_entity($id, $data, $expected) {
* @return void
* @dataProvider update_exceptions_data_provider
* @covers \local_entities_external::update_entity
* @throws \invalid_response_exception
* @throws \moodle_exception
* @throws invalid_response_exception
* @throws moodle_exception
*/
public function test_local_entities_update_entity_exceptions($id, $data, $expected) {
$this->resetAfterTest(true);
$this->setAdminUser();
$this->expectException(\invalid_parameter_exception::class);
\local_entities_external::update_entity($id, $data);
$this->expectException(invalid_parameter_exception::class);
local_entities_external::update_entity($id, $data);
}

/**
Expand Down

0 comments on commit 4eb4ef3

Please sign in to comment.