WordPress.org

Make WordPress Core

Opened 6 months ago

Last modified 4 months ago

#46567 assigned task (blessed)

Run AJAX test group for multisite

Reported by: desrosj Owned by: desrosj
Milestone: 5.3 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-unit-tests has-patch
Focuses: multisite Cc:

Description

In the test suite, tests within the ajax group are only run when explicitly passed as an argument in --group. These are tested for single site installs, but not multisite.

Some recent tests added in [44909] are failing when running the --group ajax tests on multisite because of how capabilities for those actions are mapped for multisite installs.

I am proposing to add phpunit -c tests/phpunit/multisite.xml --group ajax to the test suite.

There is a patch on #43438 that fixes the failures associated with [44909], but there are several others that should also be fixed before this can be added.

Attachments (2)

46567.diff (515 bytes) - added by desrosj 6 months ago.
46567.2.diff (2.5 KB) - added by desrosj 5 months ago.

Download all attachments as: .zip

Change History (10)

@desrosj
6 months ago

#1 @desrosj
6 months ago

  • Keywords has-patch added; needs-patch removed

#2 @garrett-eclipse
6 months ago

Hi @desrosj I just wanted to provide test results to help this work move forward.
Once I applied the patch from #43438 all the privacy tests were corrected leaving a single error and 4 failures listed below;

There was 1 error:

1) Tests_Ajax_Attachments::test_wp_ajax_send_attachment_to_editor_should_return_a_link
Undefined index: file

/Users/garretthyder/WordPress/43438-unit-tests/tests/phpunit/includes/abstract-testcase.php:1155
/Users/garretthyder/WordPress/43438-unit-tests/tests/phpunit/tests/ajax/Attachments.php:84

--

There were 4 failures:

1) Tests_Ajax_Delete_Plugin::test_delete_plugin
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    0 => true
+    0 => false
     1 => Array (
         'delete' => 'plugin'
         'slug' => 'foo'
-        'plugin' => 'foo.php'
-        'pluginName' => ''
+        'errorMessage' => 'Sorry, you are not allowed to... site.'
     )
 )

/Users/garretthyder/WordPress/43438-unit-tests/tests/phpunit/includes/abstract-testcase.php:654
/Users/garretthyder/WordPress/43438-unit-tests/tests/phpunit/tests/ajax/DeletePlugin.php:156

2) Tests_Ajax_Manage_Themes::test_update_theme
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
     1 => Array (
         'update' => 'theme'
         'slug' => 'twentyten'
-        'errorMessage' => 'The theme is at the latest version.'
-        'oldVersion' => '2.8'
+        'errorMessage' => 'Sorry, you are not allowed to update themes for this site.'
+        'oldVersion' => ''
         'newVersion' => ''
-        'debug' => Array (...)
     )
 )

/Users/garretthyder/WordPress/43438-unit-tests/tests/phpunit/includes/abstract-testcase.php:654
/Users/garretthyder/WordPress/43438-unit-tests/tests/phpunit/tests/ajax/ManageThemes.php:138

3) Tests_Ajax_Manage_Themes::test_uppercase_theme_slug
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
     1 => Array (
         'update' => 'theme'
         'slug' => 'camelCase'
-        'oldVersion' => '1.0'
+        'oldVersion' => ''
         'newVersion' => ''
-        'errorMessage' => 'The theme is at the latest version.'
-        'debug' => Array (...)
+        'errorMessage' => 'Sorry, you are not allowed to update themes for this site.'
     )
 )

/Users/garretthyder/WordPress/43438-unit-tests/tests/phpunit/includes/abstract-testcase.php:654
/Users/garretthyder/WordPress/43438-unit-tests/tests/phpunit/tests/ajax/ManageThemes.php:169

4) Tests_Ajax_Update_Plugin::test_update_plugin
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
     1 => Array (
         'update' => 'plugin'
         'slug' => 'hello-dolly'
-        'plugin' => 'hello.php'
-        'pluginName' => 'Hello Dolly'
-        'errorMessage' => 'Plugin update failed.'
-        'oldVersion' => 'Version 1.7.2'
+        'errorMessage' => 'Sorry, you are not allowed to update plugins for this site.'
+        'oldVersion' => ''
         'newVersion' => ''
-        'debug' => Array (...)
     )
 )

/Users/garretthyder/WordPress/43438-unit-tests/tests/phpunit/includes/abstract-testcase.php:654
/Users/garretthyder/WordPress/43438-unit-tests/tests/phpunit/tests/ajax/UpdatePlugin.php:167

ERRORS!
Tests: 160, Assertions: 670, Errors: 1, Failures: 4, Skipped: 1.

#3 @swissspidy
6 months ago

  • Summary changed from Run AJAX test gruoup for multisite to Run AJAX test group for multisite

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


5 months ago

#5 @johnbillion
5 months ago

  • Keywords needs-unit-tests added; 2nd-opinion removed

@desrosj
5 months ago

#6 @desrosj
5 months ago

  • Owner set to desrosj
  • Status changed from new to assigned

46567.2.diff skips the failing tests on multisite. The next step would be to write tests that only run on multisite.

Worth noting, the Undefined index: file notice is being caused because an error is returned by wp_upload_bits() due to .txt files being disallowed for security purposes.

#7 @pento
5 months ago

  • Milestone changed from 5.2 to 5.3

Bumping to 5.3

This ticket was mentioned in Slack in #core by marybaum. View the logs.


4 months ago

Note: See TracTickets for help on using tickets.