From a812f67465092b5c1fa744f3204b0673a6b6906c Mon Sep 17 00:00:00 2001 From: Mehraz Morshed Date: Sat, 5 Oct 2024 21:03:09 +0600 Subject: [PATCH 1/3] replace rand() by wp_rand() --- tests/framework/factories/class-sensei-factory.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/framework/factories/class-sensei-factory.php b/tests/framework/factories/class-sensei-factory.php index 74c798ba3c..b449bd198c 100644 --- a/tests/framework/factories/class-sensei-factory.php +++ b/tests/framework/factories/class-sensei-factory.php @@ -472,7 +472,7 @@ public function generate_user_quiz_answers( $quiz_id ) { if ( 'multiple-choice' == $type ) { // these answer can be found the question generate and attach answers function $question_meta = get_post_meta( $question->ID ); - $user_quiz_answers[ $question->ID ] = array( 0 => 'wrong1' . rand() ); + $user_quiz_answers[ $question->ID ] = array( 0 => 'wrong1' . wp_rand() ); } elseif ( 'boolean' == $type ) { @@ -487,15 +487,15 @@ public function generate_user_quiz_answers( $quiz_id ) { } elseif ( 'single-line' == $type ) { - $user_quiz_answers[ $question->ID ] = 'Single line answer for basic testing ' . rand(); + $user_quiz_answers[ $question->ID ] = 'Single line answer for basic testing ' . wp_rand(); } elseif ( 'gap-fill' == $type ) { - $user_quiz_answers[ $question->ID ] = 'OneWordScentencesForSampleAnswer ' . rand(); + $user_quiz_answers[ $question->ID ] = 'OneWordScentencesForSampleAnswer ' . wp_rand(); } elseif ( 'multi-line' == $type ) { - $user_quiz_answers[ $question->ID ] = 'Sample paragraph to test the answer ' . rand(); + $user_quiz_answers[ $question->ID ] = 'Sample paragraph to test the answer ' . wp_rand(); } elseif ( 'file-upload' == $type ) { @@ -798,7 +798,7 @@ public function generate_user_answers_feedback( $quiz_id ) { foreach ( $answers as $question_id => $answer ) { - $answers_feedback[ $question_id ] = 'Sample Feedback ' . rand(); + $answers_feedback[ $question_id ] = 'Sample Feedback ' . wp_rand(); } From 161362f17bc1dd99511ec88910cbf19f6fc4bf9d Mon Sep 17 00:00:00 2001 From: Mehraz Morshed Date: Sat, 5 Oct 2024 21:05:44 +0600 Subject: [PATCH 2/3] replace rand() by wp_rand() --- .../factories/class-wp-unittest-factory-for-question.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/framework/factories/class-wp-unittest-factory-for-question.php b/tests/framework/factories/class-wp-unittest-factory-for-question.php index d575e7fe57..a1785fe86e 100644 --- a/tests/framework/factories/class-wp-unittest-factory-for-question.php +++ b/tests/framework/factories/class-wp-unittest-factory-for-question.php @@ -42,9 +42,9 @@ public function get_sample_question_data( $type ) { 'question_type' => $type, 'question_category' => 'undefined', 'action' => 'add', - 'question' => 'Is this a sample' . $type . ' question ? _ ' . rand(), + 'question' => 'Is this a sample' . $type . ' question ? _ ' . wp_rand(), 'question_grade' => '1', - 'answer_feedback' => 'Answer Feedback sample ' . rand(), + 'answer_feedback' => 'Answer Feedback sample ' . wp_rand(), 'question_description' => ' Basic description for the question', 'question_media' => '', 'answer_order' => '', From 92bbff634b4168db510dd8f02bb4a5d3e67ae1e4 Mon Sep 17 00:00:00 2001 From: Mehraz Morshed Date: Sat, 5 Oct 2024 21:08:57 +0600 Subject: [PATCH 3/3] replace rand() by wp_rand() --- tests/unit-tests/test-class-quiz.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit-tests/test-class-quiz.php b/tests/unit-tests/test-class-quiz.php index 0af41f091f..0ab9d67f5b 100644 --- a/tests/unit-tests/test-class-quiz.php +++ b/tests/unit-tests/test-class-quiz.php @@ -312,9 +312,9 @@ public function testSaveUserAnswersUniquelyPerQuiz() { 'question_type' => 'single-line', 'question_category' => 'undefined', 'action' => 'add', - 'question' => 'Is this a sample' . 'single-line' . ' question ? _ ' . rand(), + 'question' => 'Is this a sample' . 'single-line' . ' question ? _ ' . wp_rand(), 'question_grade' => '1', - 'answer_feedback' => 'Answer Feedback sample ' . rand(), + 'answer_feedback' => 'Answer Feedback sample ' . wp_rand(), 'question_description' => ' Basic description for the question', 'question_media' => '', 'answer_order' => '',