Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
56df70d
wp-admin/includes/privacy-tools.php: Fix a PHP 8.0 fatal "Parameter #…
xknown Nov 9, 2020
c44e87a
Sends json error when '_export_data_grouped' exists but not array.
hellofromtonya Nov 29, 2020
2ac2209
Removes extra fix to keep this PR focused on one function.
hellofromtonya Nov 29, 2020
f8edbcc
Merge branch 'master' into fix/php8.0/51423-wp-admin/includes/privacy…
hellofromtonya Nov 29, 2020
a1185ff
Adds tests for array_merge warning json error.
hellofromtonya Nov 29, 2020
79ac839
Abstracts setup for export contents to make it easier to add tests.
hellofromtonya Nov 29, 2020
901ff24
Adds tests to validate groups json behavior.
hellofromtonya Nov 29, 2020
00e73a0
Adds tests for json export to validate export data grouped.
hellofromtonya Nov 29, 2020
8ab0d23
Merge branch 'master' into fix/php8.0/51423-wp-admin/includes/privacy…
hellofromtonya Feb 5, 2021
324af66
Adds _doing_it_wrong when meta value exists but is not an array.
Mar 18, 2021
2f242e1
Updates the tests.
Mar 18, 2021
5baeff0
Fixes test naming.
Mar 18, 2021
ef28395
Fixes closing ) placement for __().
Mar 19, 2021
11551b8
Cast to array when not an array.
Mar 19, 2021
ae22009
Skip array_merge when not an array.
Mar 19, 2021
3a9db91
Make json contents test more robust.
Mar 19, 2021
47f7ba0
Remove extra fix (new PR).
Mar 22, 2021
2483915
Sets vars to match current values to ensure same report output results.
Mar 22, 2021
44d9507
Fixes tests.
Mar 22, 2021
11361ca
Adds more test data for invalid type.
Mar 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make json contents test more robust.
The timestamp in the about group can be off by 1 second
between the code and test. Why? It depends upon the
system clock of when each current_time() is called.

To avoid failed tests when this happens, this commit
extracts and uses the timestamp from the report's JSON.
  • Loading branch information
hellofromtonya committed Mar 19, 2021
commit 3a9db91c44dc48df96417cd1136029fad6568b63
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,14 @@ public function test_html_contents() {
* @param string $expected_json Expected groups JSON. Default is empty string.
*/
public function test_json_contents( $groups, $expected_json = '' ) {
$about_group = '{"Personal Data Export for [email protected]":{"about":{"group_label":"About","group_description":"Overview of export report.","items":{"about-1":[{"name":"Report generated for","value":"[email protected]"},{"name":"For site","value":"Test Blog"},{"name":"At URL","value":"http:\/\/example.org"},{"name":"On","value":"' . current_time( 'mysql' ) . '"}]}}';
$report_dir = $this->setup_export_contents_test( $groups );
$report_contents_json = file_get_contents( $report_dir . 'export.json' );

// The about group: to avoid a second time difference, use the report's "on" timestamp.
$about_group = '{"Personal Data Export for [email protected]":{"about":{"group_label":"About","group_description":"Overview of export report.","items":{"about-1":[{"name":"Report generated for","value":"[email protected]"},{"name":"For site","value":"Test Blog"},{"name":"At URL","value":"http:\/\/example.org"},{"name":"On","value":"';
$timestamp = substr( $report_contents_json, strlen( $about_group ), strlen( current_time( 'mysql' ) ) );
$about_group .= $timestamp . '"}]}}';

$expected = $about_group;
if ( ! is_null( $groups ) ) {
if ( ! is_array( $groups ) ) {
Expand Down