Address PR feedback and fix PHP unit tests

This commit is contained in:
Lourens Schep 2022-04-06 10:08:22 -03:00
parent a7ec024471
commit 828e34a974
3 changed files with 6 additions and 19 deletions

View File

@ -350,10 +350,11 @@ class TaskList {
*/
public function get_json() {
$this->possibly_track_completion();
// Track completion of non viewable tasks.
$tasks_json = array();
foreach ( $this->tasks as $task ) {
if ( ! $task->can_view() ) {
$task->possibly_track_completion();
$json = $task->get_json();
if ( $json['canView'] ) {
$tasks_json[] = $json;
}
}
@ -363,12 +364,7 @@ class TaskList {
'isHidden' => $this->is_hidden(),
'isVisible' => $this->is_visible(),
'isComplete' => $this->is_complete(),
'tasks' => array_map(
function( $task ) {
return $task->get_json();
},
$this->get_viewable_tasks()
),
'tasks' => $tasks_json,
'eventPrefix' => $this->prefix_event( '' ),
'displayProgressHeader' => $this->display_progress_header,
);

View File

@ -394,7 +394,7 @@ class WC_Admin_Tests_OnboardingTasks_Task extends WC_Unit_Test_Case {
*/
public function test_get_list_id() {
$task = new TestTask(
new TaskList( array( 'id' => 'setup' ) ),
new TaskList( array( 'id' => 'extended' ) ),
array(
'id' => 'wc-unit-test-task',
)

View File

@ -96,15 +96,6 @@ class TestTask extends Task {
return $this->content;
}
/**
* Parent ID.
*
* @return string
*/
public function get_parent_id() {
return 'extended';
}
/**
* Level.
*