From 7ea33ed771fed0e9a6a3f5c2fb61067455699024 Mon Sep 17 00:00:00 2001 From: Leon Stringer Date: Mon, 4 Nov 2024 16:29:56 +0000 Subject: [PATCH] 70 Fix: PHPUnit warnings Fix warnings during PHPUnit tests: 1. Deprecated: Creation of dynamic property filter_ally\renderables\wrapper::$candownload is deprecated in .../filter/ally/tests/filter_test.php on line 870 2. assertObjectHasAttribute() is deprecated and will be removed in PHPUnit 10. Refactor your test to use assertObjectHasProperty() instead. --- classes/renderables/wrapper.php | 1 + tests/jwthelper_test.php | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/classes/renderables/wrapper.php b/classes/renderables/wrapper.php index ad9ed1a..d5ae899 100644 --- a/classes/renderables/wrapper.php +++ b/classes/renderables/wrapper.php @@ -29,4 +29,5 @@ class wrapper implements \renderable { public $url; public $canviewfeedback; public $isimage; + public $candownload; } diff --git a/tests/jwthelper_test.php b/tests/jwthelper_test.php index 26c398c..f34011e 100644 --- a/tests/jwthelper_test.php +++ b/tests/jwthelper_test.php @@ -56,12 +56,12 @@ protected function validate_token($token, $userid, $courseid, $roles) { $payload = \Firebase\JWT\JWT::decode($token, new Key($secret, 'HS256')); - $this->assertObjectHasAttribute('return_url', $payload); - $this->assertObjectHasAttribute('iat', $payload); - $this->assertObjectHasAttribute('user_id', $payload); - $this->assertObjectHasAttribute('course_id', $payload); - $this->assertObjectHasAttribute('locale', $payload); - $this->assertObjectHasAttribute('roles', $payload); + $this->assertObjectHasProperty('return_url', $payload); + $this->assertObjectHasProperty('iat', $payload); + $this->assertObjectHasProperty('user_id', $payload); + $this->assertObjectHasProperty('course_id', $payload); + $this->assertObjectHasProperty('locale', $payload); + $this->assertObjectHasProperty('roles', $payload); $this->assertSame($payload->return_url, $CFG->wwwroot); if ($userid != null) {