Address PR feedback and fix PHP unit tests
This commit is contained in:
parent
a7ec024471
commit
828e34a974
|
@ -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,
|
||||
);
|
||||
|
|
|
@ -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',
|
||||
)
|
||||
|
|
|
@ -96,15 +96,6 @@ class TestTask extends Task {
|
|||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parent ID.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_parent_id() {
|
||||
return 'extended';
|
||||
}
|
||||
|
||||
/**
|
||||
* Level.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue