Skip to content

Commit

Permalink
Fix deprecation notices on PHP 8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
m1r0 committed Jul 31, 2024
1 parent dfc51fa commit 0366ef2
Show file tree
Hide file tree
Showing 19 changed files with 150 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ private function get_learner_courses_html( $user_id ) {
$more_button = '';

foreach ( $courses as $course ) {
$html_items[] = '<a href="' . esc_url( $this->controller->get_learner_management_course_url( $course->ID ) ) .
$html_items[] = '<a href="' . esc_url( (string) $this->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 ) .
'</a>';
Expand Down
2 changes: 1 addition & 1 deletion includes/course-theme/class-sensei-course-theme-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion includes/data-port/class-sensei-data-port-utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion includes/lib/usage-tracking/class-usage-tracking-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] = [];
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 );
Expand Down
5 changes: 5 additions & 0 deletions tests/framework/factories/class-sensei-factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ class Sensei_Factory extends WP_UnitTest_Factory {
*/
public $question_category;

/**
* @var Sensei_UnitTest_Factory_For_Course_Category
*/
public $course_category;

/**
* @var WP_UnitTest_Factory_For_Message
*/
Expand Down
30 changes: 30 additions & 0 deletions tests/framework/trait-sensei-hpps-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,36 @@
* @since 4.20.0
*/
trait Sensei_HPPS_Helpers {
/**
* @var \Sensei\Internal\Student_Progress\Course_Progress\Repositories\Course_Progress_Repository_Interface
*/
private $_course_progress_repository;

/**
* @var \Sensei\Internal\Student_Progress\Lesson_Progress\Repositories\Lesson_Progress_Repository_Interface
*/
private $_lesson_progress_repository;

/**
* @var \Sensei\Internal\Student_Progress\Quiz_Progress\Repositories\Quiz_Progress_Repository_Interface
*/
private $_quiz_progress_repository;

/**
* @var \Sensei\Internal\Quiz_Submission\Submission\Repositories\Submission_Repository_Interface
*/
private $_quiz_submission_repository;

/**
* @var \Sensei\Internal\Quiz_Submission\Answer\Repositories\Answer_Repository_Interface
*/
private $_quiz_answer_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;

Expand Down
7 changes: 7 additions & 0 deletions tests/unit-tests/admin/test-class-sensei-setup-wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
14 changes: 14 additions & 0 deletions tests/unit-tests/blocks/test-class-sensei-block-view-results.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ class Sensei_Course_List_Filter_Block_Test extends WP_UnitTestCase {
<!-- wp:post-title {"level":1,"isLink":true,"fontSize":"large"} /-->
<!-- /wp:post-template --></div>
<!-- /wp:query -->';

/**
* @var Sensei_Unsupported_Theme_Handler_Course_Archive
*/
private $handler;

/**
* Set up the test.
*/
Expand Down
19 changes: 19 additions & 0 deletions tests/unit-tests/internal/emails/test-class-email-preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@
class Email_Preview_Test extends \WP_UnitTestCase {
use Sensei_Test_Login_Helpers;

/**
* @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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
7 changes: 7 additions & 0 deletions tests/unit-tests/test-class-sensei-guest-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
7 changes: 7 additions & 0 deletions tests/unit-tests/test-class-sensei-preview-user.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 0366ef2

Please sign in to comment.