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() {
|
public function get_json() {
|
||||||
$this->possibly_track_completion();
|
$this->possibly_track_completion();
|
||||||
// Track completion of non viewable tasks.
|
$tasks_json = array();
|
||||||
foreach ( $this->tasks as $task ) {
|
foreach ( $this->tasks as $task ) {
|
||||||
if ( ! $task->can_view() ) {
|
$json = $task->get_json();
|
||||||
$task->possibly_track_completion();
|
if ( $json['canView'] ) {
|
||||||
|
$tasks_json[] = $json;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,12 +364,7 @@ class TaskList {
|
||||||
'isHidden' => $this->is_hidden(),
|
'isHidden' => $this->is_hidden(),
|
||||||
'isVisible' => $this->is_visible(),
|
'isVisible' => $this->is_visible(),
|
||||||
'isComplete' => $this->is_complete(),
|
'isComplete' => $this->is_complete(),
|
||||||
'tasks' => array_map(
|
'tasks' => $tasks_json,
|
||||||
function( $task ) {
|
|
||||||
return $task->get_json();
|
|
||||||
},
|
|
||||||
$this->get_viewable_tasks()
|
|
||||||
),
|
|
||||||
'eventPrefix' => $this->prefix_event( '' ),
|
'eventPrefix' => $this->prefix_event( '' ),
|
||||||
'displayProgressHeader' => $this->display_progress_header,
|
'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() {
|
public function test_get_list_id() {
|
||||||
$task = new TestTask(
|
$task = new TestTask(
|
||||||
new TaskList( array( 'id' => 'setup' ) ),
|
new TaskList( array( 'id' => 'extended' ) ),
|
||||||
array(
|
array(
|
||||||
'id' => 'wc-unit-test-task',
|
'id' => 'wc-unit-test-task',
|
||||||
)
|
)
|
||||||
|
|
|
@ -96,15 +96,6 @@ class TestTask extends Task {
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Parent ID.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function get_parent_id() {
|
|
||||||
return 'extended';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Level.
|
* Level.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue