-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7670 from Automattic/fix/report-not-exporting
Fix some reports not exporting all rows
- Loading branch information
Showing
5 changed files
with
111 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: fixed | ||
|
||
Some reports not exporting all rows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
tests/unit-tests/test-class-sensei-analysis-lesson-list-table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/** | ||
* Sensei Analysis Lesson List Table Unit Test. | ||
* | ||
* @covers Sensei_Analysis_Lesson_List_Table | ||
*/ | ||
class Sensei_Analysis_Lesson_List_Table_Test extends WP_UnitTestCase { | ||
/** | ||
* Factory object. | ||
* | ||
* @var Sensei_Factory | ||
*/ | ||
protected $factory; | ||
|
||
/** | ||
* Set up the test. | ||
*/ | ||
public function setUp(): void { | ||
parent::setUp(); | ||
|
||
$this->factory = new Sensei_Factory(); | ||
} | ||
|
||
public function testGenerateReport_StudentsByLesson_ReturnsCorrectNumberOfRows() { | ||
/* Arrange. */ | ||
$course_id = $this->factory->course->create(); | ||
$lesson_id = $this->factory->lesson->create( | ||
[ | ||
'meta_input' => [ | ||
'_lesson_course' => $course_id, | ||
], | ||
] | ||
); | ||
|
||
$user1_id = $this->factory->user->create(); | ||
$user2_id = $this->factory->user->create(); | ||
$user3_id = $this->factory->user->create(); | ||
|
||
Sensei_Utils::start_user_on_course( $user1_id, $course_id ); | ||
Sensei_Utils::start_user_on_course( $user2_id, $course_id ); | ||
Sensei_Utils::start_user_on_course( $user3_id, $course_id ); | ||
|
||
Sensei_Utils::user_start_lesson( $user1_id, $lesson_id ); | ||
Sensei_Utils::user_start_lesson( $user2_id, $lesson_id ); | ||
Sensei_Utils::user_start_lesson( $user3_id, $lesson_id ); | ||
|
||
/* Act. */ | ||
$table = new Sensei_Analysis_Lesson_List_Table( $lesson_id ); | ||
$export_data = $table->generate_report( 'lesson-name-learners-overview' ); | ||
|
||
/* Assert. */ | ||
self::assertSame( 4, count( $export_data ) ); // Header row + 3 students. | ||
} | ||
} |