Make WordPress Core

Opened 6 years ago

Closed 4 years ago

Last modified 4 years ago

#46567 closed task (blessed) (fixed)

Run AJAX test group for multisite

Reported by: desrosj's profile desrosj Owned by: desrosj's profile desrosj
Milestone: 5.7 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: needs-unit-tests has-patch needs-refresh
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 years ago.
46567.2.diff (2.5 KB) - added by desrosj 6 years ago.

Download all attachments as: .zip

Change History (17)

@desrosj
6 years ago

#1 @desrosj
6 years ago

  • Keywords has-patch added; needs-patch removed

#2 @garrett-eclipse
6 years 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 years 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.


6 years ago

#5 @johnbillion
6 years ago

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

@desrosj
6 years ago

#6 @desrosj
6 years 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
6 years 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.


6 years ago

#9 @netweb
5 years ago

I've not looked closely at the patch, but is anything preventing you from landing this @desrosj ?

If there is could you please bump the milestone to 5.4, thanks

#10 @desrosj
5 years ago

  • Keywords needs-refresh added

@netweb The patch needs to be refreshed to run the tests within the Docker environment on Travis. I actually started looking at this yesterday and did not get to finish the patch. I plan to punt early next week if I don't get a chance to return to it.

#11 @desrosj
5 years ago

  • Milestone changed from 5.3 to Future Release

I am going to punt this for now. It's a test related ticket, so can be moved back whenever there is time to finish refreshing

#13 @desrosj
4 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 49835:

Build/Test Tools: Run the Ajax test group for multisite.

This will help catch issues with Ajax related functionality on multisite.

A few tests have also been marked as skipWithMultisite() as they require network admin level capabilities when performing the same operations on a multisite install.

Props garrett-eclipse, netweb.
Fixes #46567.

#15 @desrosj
4 years ago

  • Milestone changed from Future Release to 5.7
Note: See TracTickets for help on using tickets.