diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 525253103c..f0e196b23c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -55,7 +55,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- php: [7.4, 8.1]
+ php: [7.4, 8.2]
steps:
- name: Download Build Artifact
uses: actions/download-artifact@v3
diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml
index 3f97587007..cf8768247d 100644
--- a/.github/workflows/php.yml
+++ b/.github/workflows/php.yml
@@ -59,7 +59,7 @@ jobs:
matrix:
wp: ['latest']
wpmu: [0]
- php: ['7.4', '8.0']
+ php: ['7.4', '8.2']
include:
- php: 7.4
wp: '6.1'
diff --git a/changelog/fix-deprecation-notice-on-question-edit-screen b/changelog/fix-deprecation-notice-on-question-edit-screen
deleted file mode 100644
index 07b42e900b..0000000000
--- a/changelog/fix-deprecation-notice-on-question-edit-screen
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: fixed
-
-Deprecation notice on the question edit screen on PHP 8.1
diff --git a/changelog/fix-deprecation-notice-on-reports-screen b/changelog/fix-deprecation-notice-on-reports-screen
deleted file mode 100644
index 79e776a62c..0000000000
--- a/changelog/fix-deprecation-notice-on-reports-screen
+++ /dev/null
@@ -1,4 +0,0 @@
-Significance: patch
-Type: fixed
-
-Deprecation notice on the reports screen when using PHP 8.1
diff --git a/changelog/fix-deprecation-notices b/changelog/fix-deprecation-notices
new file mode 100644
index 0000000000..cccdf82670
--- /dev/null
+++ b/changelog/fix-deprecation-notices
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fixed
+
+Deprecation notices on PHP 8.2
diff --git a/includes/admin/class-sensei-learners-admin-bulk-actions-view.php b/includes/admin/class-sensei-learners-admin-bulk-actions-view.php
index 3ce7d7d657..85b383c1d7 100644
--- a/includes/admin/class-sensei-learners-admin-bulk-actions-view.php
+++ b/includes/admin/class-sensei-learners-admin-bulk-actions-view.php
@@ -490,7 +490,7 @@ private function get_learner_courses_html( $user_id ) {
$more_button = '';
foreach ( $courses as $course ) {
- $html_items[] = 'controller->get_learner_management_course_url( $course->ID ) ) .
'" class="sensei-students__enrolled-course" data-course-id="' . esc_attr( $course->ID ) . '">' .
esc_html( $course->post_title ) .
'';
diff --git a/includes/class-sensei-lesson.php b/includes/class-sensei-lesson.php
index bca4f514dc..3ffaa788f0 100755
--- a/includes/class-sensei-lesson.php
+++ b/includes/class-sensei-lesson.php
@@ -4804,7 +4804,7 @@ public static function course_signup_link() {
* @return {bool} Whether to show the course sign up notice.
*/
if ( apply_filters( 'sensei_lesson_show_course_signup_notice', $show_course_signup_notice, $course_id ) ) {
- $course_link = '';
+ $course_link = '';
$course_link .= esc_html__( 'course', 'sensei-lms' );
$course_link .= '';
diff --git a/includes/class-sensei-quiz.php b/includes/class-sensei-quiz.php
index a838f6201e..d5a8daf530 100755
--- a/includes/class-sensei-quiz.php
+++ b/includes/class-sensei-quiz.php
@@ -1,7 +1,6 @@
$feedback ) {
- $answers_feedback[ $question_id ] = base64_decode( $feedback );
+ $answers_feedback[ $question_id ] = base64_decode( (string) $feedback );
}
diff --git a/includes/course-theme/class-sensei-course-theme-styles.php b/includes/course-theme/class-sensei-course-theme-styles.php
index 789a95f3a7..608fe9770f 100644
--- a/includes/course-theme/class-sensei-course-theme-styles.php
+++ b/includes/course-theme/class-sensei-course-theme-styles.php
@@ -203,7 +203,7 @@ private static function get_property_value( $value ) {
);
$value = "var(--wp--$unwrapped_name)";
} elseif ( preg_match( '/^[a-z0-9-]+$/i', $value ) ) {
- $value = "var(--wp--preset--color--${value})";
+ $value = "var(--wp--preset--color--{$value})";
}
return $value;
diff --git a/includes/data-port/class-sensei-data-port-utilities.php b/includes/data-port/class-sensei-data-port-utilities.php
index 5619a5a453..c17ce889f7 100644
--- a/includes/data-port/class-sensei-data-port-utilities.php
+++ b/includes/data-port/class-sensei-data-port-utilities.php
@@ -402,7 +402,7 @@ private static function create_term( $term_name, $taxonomy_name, $teacher_user_i
*
* @return array|string[]
*/
- public static function split_list_safely( $str_list, $remove_quotes = false ) {
+ public static function split_list_safely( string $str_list, bool $remove_quotes = false ) {
if ( empty( trim( $str_list ) ) ) {
return [];
}
diff --git a/includes/data-port/models/class-sensei-import-question-model.php b/includes/data-port/models/class-sensei-import-question-model.php
index 71430371ac..845d1de620 100644
--- a/includes/data-port/models/class-sensei-import-question-model.php
+++ b/includes/data-port/models/class-sensei-import-question-model.php
@@ -352,7 +352,7 @@ private function get_taxonomy_terms() {
$taxonomy_terms[ Sensei_Data_Port_Question_Schema::TAXONOMY_QUESTION_CATEGORY ] = [];
- $category_list = Sensei_Data_Port_Utilities::split_list_safely( $this->get_value( Sensei_Data_Port_Question_Schema::COLUMN_CATEGORIES ), true );
+ $category_list = Sensei_Data_Port_Utilities::split_list_safely( (string) $this->get_value( Sensei_Data_Port_Question_Schema::COLUMN_CATEGORIES ), true );
if ( ! empty( $category_list ) ) {
foreach ( $category_list as $category ) {
$category_term = Sensei_Data_Port_Utilities::get_term( $category, Sensei_Data_Port_Question_Schema::TAXONOMY_QUESTION_CATEGORY );
diff --git a/includes/internal/emails/class-email-list-table.php b/includes/internal/emails/class-email-list-table.php
index 7d2325bf6e..fcaa337209 100644
--- a/includes/internal/emails/class-email-list-table.php
+++ b/includes/internal/emails/class-email-list-table.php
@@ -8,8 +8,6 @@
namespace Sensei\Internal\Emails;
use Sensei_List_Table;
-use WP_Post;
-use WP_Query;
if ( ! defined( 'ABSPATH' ) ) {
exit;
@@ -130,7 +128,7 @@ protected function get_row_data( $post ) {
$description = $is_available ?
sprintf(
'%2$s%3$s',
- esc_url( get_edit_post_link( $post ) ),
+ esc_url( (string) get_edit_post_link( $post ) ),
get_post_meta( $post->ID, '_sensei_email_description', true ),
$this->row_actions( $actions )
) : sprintf(
diff --git a/includes/lib/usage-tracking/class-usage-tracking-base.php b/includes/lib/usage-tracking/class-usage-tracking-base.php
index e81c78aa1e..3c5f741ae3 100644
--- a/includes/lib/usage-tracking/class-usage-tracking-base.php
+++ b/includes/lib/usage-tracking/class-usage-tracking-base.php
@@ -263,7 +263,7 @@ private function send_tracks_request( $event, $properties = array(), $event_time
$p = array();
foreach ( $properties as $key => $value ) {
- $p[] = rawurlencode( $key ) . '=' . rawurlencode( $value );
+ $p[] = rawurlencode( $key ) . '=' . rawurlencode( (string) $value );
}
$pixel .= '?' . implode( '&', $p ) . '&_=_'; // EOF marker.
diff --git a/includes/lib/usage-tracking/tests/test-class-usage-tracking.php b/includes/lib/usage-tracking/tests/test-class-usage-tracking.php
index a60e3b36dd..1680c32343 100644
--- a/includes/lib/usage-tracking/tests/test-class-usage-tracking.php
+++ b/includes/lib/usage-tracking/tests/test-class-usage-tracking.php
@@ -21,6 +21,13 @@ class Sensei_Base_Usage_Tracking_Test extends WP_UnitTestCase {
private $event_counts = array();
private $track_http_request = array();
+ /**
+ * Usage tracking test subclass instance.
+ *
+ * @var Usage_Tracking_Test_Subclass
+ */
+ private $usage_tracking;
+
public function setUp(): void {
parent::setUp();
// Update the class name here to match the Usage Tracking class.
diff --git a/includes/rest-api/class-sensei-rest-api-course-progress-controller.php b/includes/rest-api/class-sensei-rest-api-course-progress-controller.php
index 0c0b83a315..7633c6b623 100644
--- a/includes/rest-api/class-sensei-rest-api-course-progress-controller.php
+++ b/includes/rest-api/class-sensei-rest-api-course-progress-controller.php
@@ -35,7 +35,7 @@ class Sensei_REST_API_Course_Progress_Controller extends \WP_REST_Controller {
*
* @param string $namespace Routes namespace.
*/
- public function __construct( $namespace ) {
+ public function __construct( $namespace ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.namespaceFound -- The variable name if defined in the WP_REST_Controller class.
$this->namespace = $namespace;
}
@@ -74,6 +74,7 @@ public function batch_delete_items( WP_REST_Request $request ) {
$student = new WP_User( $student_id );
$result[ $student_id ] = false;
if ( $student->exists() ) {
+ $result[ $student_id ] = array();
foreach ( $course_ids as $course_id ) {
$result[ $student_id ][ $course_id ] = false;
if ( Sensei_Utils::has_started_course( $course_id, $student_id ) ) {
@@ -83,7 +84,7 @@ public function batch_delete_items( WP_REST_Request $request ) {
}
}
- return new WP_REST_Response( $result, WP_HTTP::OK );
+ return new WP_REST_Response( $result, WP_Http::OK );
}
/**
diff --git a/includes/rest-api/class-sensei-rest-api-course-students-controller.php b/includes/rest-api/class-sensei-rest-api-course-students-controller.php
index db86d740e5..eb2b32979a 100644
--- a/includes/rest-api/class-sensei-rest-api-course-students-controller.php
+++ b/includes/rest-api/class-sensei-rest-api-course-students-controller.php
@@ -80,6 +80,7 @@ public function batch_create_items( WP_REST_Request $request ) {
$user = new WP_User( $user_id );
$result[ $user_id ] = false;
if ( $user->exists() ) {
+ $result[ $user_id ] = array();
foreach ( $course_ids as $course_id ) {
$course_enrolment = Sensei_Course_Enrolment::get_course_instance( $course_id );
$result[ $user_id ][ $course_id ] = $course_enrolment->enrol( $user_id );
diff --git a/phpunit.xml b/phpunit.xml
index d878d8528b..f2c52a9080 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -6,6 +6,7 @@
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
+ convertDeprecationsToExceptions="true"
verbose="true"
>
diff --git a/tests/framework/factories/class-sensei-factory.php b/tests/framework/factories/class-sensei-factory.php
index 80d1d6c94f..74c798ba3c 100644
--- a/tests/framework/factories/class-sensei-factory.php
+++ b/tests/framework/factories/class-sensei-factory.php
@@ -45,41 +45,64 @@ class Sensei_Factory extends WP_UnitTest_Factory {
protected $basic_test_question_ids;
/**
+ * Course factory.
+ *
* @var WP_UnitTest_Factory_For_Course
*/
public $course;
/**
+ * Lesson factory.
+ *
* @var WP_UnitTest_Factory_For_Lesson
*/
public $lesson;
/**
+ * Quiz factory.
+ *
* @var WP_UnitTest_Factory_For_Quiz
*/
public $quiz;
/**
+ * Question factory.
+ *
* @var WP_UnitTest_Factory_For_Question
*/
public $question;
/**
+ * Multiple question factory.
+ *
* @var WP_UnitTest_Factory_For_Multiple_Question
*/
public $multiple_question;
/**
+ * Module factory.
+ *
* @var WP_UnitTest_Factory_For_Module
*/
public $module;
/**
+ * Question category factory.
+ *
* @var WP_UnitTest_Factory_For_Question_Category
*/
public $question_category;
/**
+ * Course category factory.
+ *
+ * @var Sensei_UnitTest_Factory_For_Course_Category
+ */
+ public $course_category;
+
+ /**
+ * Message factory.
+ *
* @var WP_UnitTest_Factory_For_Message
*/
public $message;
diff --git a/tests/framework/trait-sensei-hpps-helpers.php b/tests/framework/trait-sensei-hpps-helpers.php
index 01def59d0f..06f52caf36 100644
--- a/tests/framework/trait-sensei-hpps-helpers.php
+++ b/tests/framework/trait-sensei-hpps-helpers.php
@@ -6,6 +6,7 @@
*/
// phpcs:disable WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid -- Using PHPUnit conventions.
+// phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore
use Sensei\Internal\Quiz_Submission\Answer\Repositories\Answer_Repository_Factory;
use Sensei\Internal\Quiz_Submission\Grade\Repositories\Grade_Repository_Factory;
@@ -25,6 +26,48 @@
* @since 4.20.0
*/
trait Sensei_HPPS_Helpers {
+ /**
+ * Course progress repository.
+ *
+ * @var \Sensei\Internal\Student_Progress\Course_Progress\Repositories\Course_Progress_Repository_Interface
+ */
+ private $_course_progress_repository;
+
+ /**
+ * Lesson progress repository.
+ *
+ * @var \Sensei\Internal\Student_Progress\Lesson_Progress\Repositories\Lesson_Progress_Repository_Interface
+ */
+ private $_lesson_progress_repository;
+
+ /**
+ * Quiz repository.
+ *
+ * @var \Sensei\Internal\Student_Progress\Quiz_Progress\Repositories\Quiz_Progress_Repository_Interface
+ */
+ private $_quiz_progress_repository;
+
+ /**
+ * Submission repository.
+ *
+ * @var \Sensei\Internal\Quiz_Submission\Submission\Repositories\Submission_Repository_Interface
+ */
+ private $_quiz_submission_repository;
+
+ /**
+ * Answer repository.
+ *
+ * @var \Sensei\Internal\Quiz_Submission\Answer\Repositories\Answer_Repository_Interface
+ */
+ private $_quiz_answer_repository;
+
+ /**
+ * Grade repository.
+ *
+ * @var \Sensei\Internal\Quiz_Submission\Grade\Repositories\Grade_Repository_Interface
+ */
+ private $_quiz_grade_repository;
+
private function enable_hpps_tables_repository() {
Sensei()->settings->settings['experimental_progress_storage_repository'] = Progress_Storage_Settings::TABLES_STORAGE;
diff --git a/tests/unit-tests/admin/test-class-sensei-setup-wizard.php b/tests/unit-tests/admin/test-class-sensei-setup-wizard.php
index cdc03f6254..c8767d0a80 100644
--- a/tests/unit-tests/admin/test-class-sensei-setup-wizard.php
+++ b/tests/unit-tests/admin/test-class-sensei-setup-wizard.php
@@ -14,6 +14,13 @@
class Sensei_Setup_Wizard_Test extends WP_UnitTestCase {
use Sensei_Test_Redirect_Helpers;
+ /**
+ * The original screen.
+ *
+ * @var WP_Screen
+ */
+ private $original_screen;
+
/**
* Set up before the class.
*/
@@ -339,7 +346,9 @@ public function testRenderWizardPage_WhenRendered_ClearsRedirectOption() {
update_option( 'sensei_activation_redirect', 1 );
// Act.
+ ob_start();
Sensei()->setup_wizard->render_wizard_page();
+ ob_end_clean();
// Assert.
$this->assertFalse( get_option( 'sensei_activation_redirect', false ) );
diff --git a/tests/unit-tests/blocks/test-class-sensei-block-course-progress.php b/tests/unit-tests/blocks/test-class-sensei-block-course-progress.php
index 4f189f58f6..c3bc49a322 100644
--- a/tests/unit-tests/blocks/test-class-sensei-block-course-progress.php
+++ b/tests/unit-tests/blocks/test-class-sensei-block-course-progress.php
@@ -14,6 +14,13 @@ class Sensei_Course_Progress_Block_Test extends WP_UnitTestCase {
*/
private $block;
+ /**
+ * The course post.
+ *
+ * @var WP_Post
+ */
+ private $course;
+
/**
* Factory for setting up testing data.
*
diff --git a/tests/unit-tests/blocks/test-class-sensei-block-learner-courses.php b/tests/unit-tests/blocks/test-class-sensei-block-learner-courses.php
index 5d3b903ab1..d6d090583e 100644
--- a/tests/unit-tests/blocks/test-class-sensei-block-learner-courses.php
+++ b/tests/unit-tests/blocks/test-class-sensei-block-learner-courses.php
@@ -17,6 +17,20 @@ class Sensei_Block_Learner_Courses_Test extends WP_UnitTestCase {
*/
private $block;
+ /**
+ * The course post.
+ *
+ * @var WP_Post
+ */
+ private $course;
+
+ /**
+ * Factory for setting up testing data.
+ *
+ * @var Sensei_Factory
+ */
+ protected $factory;
+
/**
* Set up the test.
*/
diff --git a/tests/unit-tests/blocks/test-class-sensei-block-view-results.php b/tests/unit-tests/blocks/test-class-sensei-block-view-results.php
index 75cfd98f83..075917a87e 100644
--- a/tests/unit-tests/blocks/test-class-sensei-block-view-results.php
+++ b/tests/unit-tests/blocks/test-class-sensei-block-view-results.php
@@ -17,6 +17,20 @@ class Sensei_Block_View_Results_Test extends WP_UnitTestCase {
*/
private $block;
+ /**
+ * The course post.
+ *
+ * @var WP_Post
+ */
+ private $course;
+
+ /**
+ * Factory for setting up testing data.
+ *
+ * @var Sensei_Factory
+ */
+ protected $factory;
+
/**
* Block content.
*/
diff --git a/tests/unit-tests/blocks/test-class-sensei-continue-course-block.php b/tests/unit-tests/blocks/test-class-sensei-continue-course-block.php
index 01b42b447a..bd19f0b112 100644
--- a/tests/unit-tests/blocks/test-class-sensei-continue-course-block.php
+++ b/tests/unit-tests/blocks/test-class-sensei-continue-course-block.php
@@ -17,6 +17,20 @@ class Sensei_Continue_Course_Block_Test extends WP_UnitTestCase {
*/
private $block;
+ /**
+ * The course post.
+ *
+ * @var WP_Post
+ */
+ private $course;
+
+ /**
+ * Factory for setting up testing data.
+ *
+ * @var Sensei_Factory
+ */
+ protected $factory;
+
/**
* Block content.
*/
diff --git a/tests/unit-tests/blocks/test-class-sensei-course-list-filter-block.php b/tests/unit-tests/blocks/test-class-sensei-course-list-filter-block.php
index 5621e10721..c65341dce4 100644
--- a/tests/unit-tests/blocks/test-class-sensei-course-list-filter-block.php
+++ b/tests/unit-tests/blocks/test-class-sensei-course-list-filter-block.php
@@ -60,6 +60,14 @@ class Sensei_Course_List_Filter_Block_Test extends WP_UnitTestCase {
';
+
+ /**
+ * Course archive
+ *
+ * @var Sensei_Unsupported_Theme_Handler_Course_Archive
+ */
+ private $handler;
+
/**
* Set up the test.
*/
diff --git a/tests/unit-tests/blocks/test-class-sensei-global-blocks.php b/tests/unit-tests/blocks/test-class-sensei-global-blocks.php
index 65fdd16780..7519da164c 100644
--- a/tests/unit-tests/blocks/test-class-sensei-global-blocks.php
+++ b/tests/unit-tests/blocks/test-class-sensei-global-blocks.php
@@ -64,6 +64,10 @@ public function testEnqueueBlockAssets_WhenCalled_EnqueueBlockAssets() {
/* Assert */
$this->assertTrue( wp_script_is( 'sensei-course-list-filter' ) );
$this->assertTrue( wp_style_is( 'sensei-global-blocks-style' ) );
+
+ /* Reset */
+ wp_dequeue_script( 'sensei-course-list-filter' );
+ wp_dequeue_style( 'sensei-global-blocks-style' );
}
/**
@@ -71,8 +75,6 @@ public function testEnqueueBlockAssets_WhenCalled_EnqueueBlockAssets() {
*/
public function testEnqueueBlockAssets_WhenCalledOnAdmin_NotEnqueueCourseListFilter() {
/* Arrange */
-
- $this->markTestSkipped( 'This test requires WordPress 5.8 or higher.' );
set_current_screen( 'edit-post' );
/* Act */
@@ -80,6 +82,9 @@ public function testEnqueueBlockAssets_WhenCalledOnAdmin_NotEnqueueCourseListFil
/* Assert */
$this->assertFalse( wp_script_is( 'sensei-course-list-filter' ) );
+
+ /* Reset */
+ wp_dequeue_style( 'sensei-global-blocks-style' );
}
diff --git a/tests/unit-tests/internal/emails/test-class-email-preview.php b/tests/unit-tests/internal/emails/test-class-email-preview.php
index 13268d91b4..e846fecb93 100644
--- a/tests/unit-tests/internal/emails/test-class-email-preview.php
+++ b/tests/unit-tests/internal/emails/test-class-email-preview.php
@@ -18,6 +18,27 @@
class Email_Preview_Test extends \WP_UnitTestCase {
use Sensei_Test_Login_Helpers;
+ /**
+ * Factory instance.
+ *
+ * @var Sensei_Factory
+ */
+ protected $factory;
+
+ /**
+ * Email_Sender mock.
+ *
+ * @var \PHPUnit\Framework\MockObject\MockObject
+ */
+ protected $email_sender;
+
+ /**
+ * Sensei_Assets mock.
+ *
+ * @var \PHPUnit\Framework\MockObject\MockObject
+ */
+ protected $assets;
+
public function setUp(): void {
parent::setUp();
$this->factory = new Sensei_Factory();
diff --git a/tests/unit-tests/internal/emails/test-class-email-user-profile-settings.php b/tests/unit-tests/internal/emails/test-class-email-user-profile-settings.php
index 76a7faf96f..9896d02f09 100644
--- a/tests/unit-tests/internal/emails/test-class-email-user-profile-settings.php
+++ b/tests/unit-tests/internal/emails/test-class-email-user-profile-settings.php
@@ -39,6 +39,13 @@ class Email_User_Profile_Settings_Test extends \WP_UnitTestCase {
*/
protected $list_table;
+ /**
+ * Email subscription instance.
+ *
+ * @var \Sensei\Internal\Emails\Email_Subscription
+ */
+ protected $subscription;
+
public function setUp(): void {
parent::setUp();
diff --git a/tests/unit-tests/test-class-sensei-guest-user.php b/tests/unit-tests/test-class-sensei-guest-user.php
index b962e6939b..defddef976 100644
--- a/tests/unit-tests/test-class-sensei-guest-user.php
+++ b/tests/unit-tests/test-class-sensei-guest-user.php
@@ -20,6 +20,13 @@ class Sensei_Guest_User_Test extends WP_UnitTestCase {
*/
protected $factory;
+ /**
+ * Guest user instance.
+ *
+ * @var Sensei_Guest_User
+ */
+ protected $guest_user;
+
/**
* Set up the test.
*/
diff --git a/tests/unit-tests/test-class-sensei-preview-user.php b/tests/unit-tests/test-class-sensei-preview-user.php
index b1e248bdf6..4e3c5a596e 100644
--- a/tests/unit-tests/test-class-sensei-preview-user.php
+++ b/tests/unit-tests/test-class-sensei-preview-user.php
@@ -20,6 +20,13 @@ class Sensei_Preview_User_Test extends WP_UnitTestCase {
*/
protected $factory;
+ /**
+ * Preview user instance.
+ *
+ * @var Sensei_Preview_User
+ */
+ protected $preview_user;
+
/**
* Set up the test.
*/