mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-77350 favourites: Added class properties that are not declared
In PHP 8.2 and later, setting a value to an undeclared class property is deprecated and emits a deprecation notice. So we need to add missing class properties that still need to be declared. // Removed test_add_malformed_favourite() PHPUnit version >= 9.5 no longer converts PHP deprecations to exceptions by default. To comply with PHP 8.2, which will deprecate the dynamic properties, we need to remove test_add_malformed_favourite() because the test will raise a warning for dynamic property deprecations.
This commit is contained in:
parent
684343eee7
commit
4937a1fd1c
@ -59,6 +59,9 @@ class favourite {
|
||||
/** @var int $timemodified the time at which the last modification of the favourite took place.*/
|
||||
public $timemodified;
|
||||
|
||||
/** @var string $uniquekey favourite unique key.*/
|
||||
public $uniquekey;
|
||||
|
||||
/**
|
||||
* Favourite constructor.
|
||||
* @param string $component the frankenstyle name of the component containing the favourited item. E.g. 'core_course'.
|
||||
|
@ -95,7 +95,8 @@ class favourite_repository implements favourite_repository_interface {
|
||||
'ordering' => false,
|
||||
'timecreated' => false,
|
||||
'timemodified' => false,
|
||||
'id' => false
|
||||
'id' => false,
|
||||
'uniquekey' => false
|
||||
];
|
||||
|
||||
$requiredfields = array_filter($allowedfields, function($field) {
|
||||
|
@ -81,28 +81,6 @@ class repository_test extends \advanced_testcase {
|
||||
$favouritesrepo->add($favcourse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that malformed favourites cannot be saved.
|
||||
*/
|
||||
public function test_add_malformed_favourite() {
|
||||
list($user1context, $user2context, $course1context, $course2context) = $this->setup_users_and_courses();
|
||||
|
||||
// Create a favourites repository and favourite a course.
|
||||
$favouritesrepo = new favourite_repository($user1context);
|
||||
|
||||
$favcourse = new favourite(
|
||||
'core_course',
|
||||
'course',
|
||||
$course1context->instanceid,
|
||||
$course1context->id,
|
||||
$user1context->instanceid
|
||||
);
|
||||
$favcourse->something = 'something';
|
||||
|
||||
$this->expectException('moodle_exception');
|
||||
$favouritesrepo->add($favcourse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that incomplete favourites cannot be saved.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user