summaryrefslogtreecommitdiffstatshomepage
path: root/tests/phpunit/includes/testcase-ajax.php
Commit message (Collapse)AuthorAge
* Docs: Fix various typos and spelling mistakes.Pascal Birchler2024-04-12
| | | | | | | Props swissspidy, jucaduca, sergeybiryukov. See #60699. git-svn-id: https://develop.svn.wordpress.org/trunk@57987 602fd350-edb4-49c9-b593-d223f7449a82
* Build/Test Tools: Implement use of the `void` solution.Sergey Biryukov2021-08-07
| | | | | | | | | | | | | | | | | | | | | | | > PHPUnit 8.0.0 introduced a `void` return type declaration to the "fixture" methods – `setUpBeforeClass()`, `setUp()`, `tearDown()` and `tearDownAfterClass()`. As the `void` return type was not introduced until PHP 7.1, this makes it more difficult to create cross-version compatible tests when using fixtures, due to signature mismatches. > > The `Yoast\PHPUnitPolyfills\TestCases\TestCase` overcomes the signature mismatch by having two versions. The correct one will be loaded depending on the PHPUnit version being used. > > When using this TestCase, if an individual test, or another TestCase which extends this TestCase, needs to overload any of the "fixture" methods, it should do so by using a snake_case variant of the original fixture method name, i.e. `set_up_before_class()`, `set_up()`, `assert_pre_conditions()`, `assert_post_conditions()`, `tear_down()`, and `tear_down_after_class()`. > > The snake_case methods will automatically be called by PHPUnit. > > > IMPORTANT: The snake_case methods should not call the PHPUnit parent, i.e. do not use `parent::setUp()` from within an overloaded `set_up()` method. If necessary, DO call `parent::set_up()`. Reference: https://github.com/Yoast/PHPUnit-Polyfills#testcases This commit renames all declared fixture methods, and calls to parent versions of those fixture methods, from camelCase to snake_case. Follow-up to [51559-51567]. Props jrf, hellofromTonya, johnbillion, netweb, dd32, pputzer, SergeyBiryukov. See #46149. git-svn-id: https://develop.svn.wordpress.org/trunk@51568 602fd350-edb4-49c9-b593-d223f7449a82
* Build/Test Tools: Fix and standardise calls to the `tearDown()` method in ↵John Blackbourn2021-02-27
| | | | | | | | | | | the test suite. The parent method should be called after any test-specific teardown. See #52625 git-svn-id: https://develop.svn.wordpress.org/trunk@50450 602fd350-edb4-49c9-b593-d223f7449a82
* Build/Test Tools: Fix and standardise calls to the `setUp()` and ↵John Blackbourn2021-02-27
| | | | | | | | | | | `setUpBeforeClass()` methods in the test suite. The parent methods should always be called before any test-specific functionality is set up, unless there is a specific and documented reason. See #52625 git-svn-id: https://develop.svn.wordpress.org/trunk@50449 602fd350-edb4-49c9-b593-d223f7449a82
* Build/Test Tools: Remove unused posts from AJAX test `setUp()`.Peter Wilson2020-11-25
| | | | | | | | | Removes the creation of five posts from the AJAX test suite `setUp()` function, replacing it with a shared fixture only where required. See #51802. git-svn-id: https://develop.svn.wordpress.org/trunk@49696 602fd350-edb4-49c9-b593-d223f7449a82
* Docs: Update the code example in `WP_Ajax_UnitTestCase::dieHandler()` ↵Sergey Biryukov2020-09-18
| | | | | | | | | | DocBlock to use `expectException()`. Follow-up to [48996], [48997]. See #51344. git-svn-id: https://develop.svn.wordpress.org/trunk@48998 602fd350-edb4-49c9-b593-d223f7449a82
* Docs: Improve inline comments per the documentation standards.Sergey Biryukov2020-01-29
| | | | | | | | Includes minor code layout fixes for better readability. See #48303. git-svn-id: https://develop.svn.wordpress.org/trunk@47122 602fd350-edb4-49c9-b593-d223f7449a82
* Docs: Improve documentation for `tests/phpunit/includes/testcase-ajax.php`.Sergey Biryukov2020-01-05
| | | | | | | Props andizer, SergeyBiryukov. Fixes #47568. git-svn-id: https://develop.svn.wordpress.org/trunk@47041 602fd350-edb4-49c9-b593-d223f7449a82
* Privacy: Add unit tests for exporting and erasing personal data.Jonathan Desrosiers2019-03-15
| | | | | | | Props birgire, garrett-eclipse, desrosj. Fixes #43438. git-svn-id: https://develop.svn.wordpress.org/trunk@44909 602fd350-edb4-49c9-b593-d223f7449a82
* Code is Poetry.Gary Pendergast2017-11-30
| | | | | | | | | | | | WordPress' code just... wasn't. This is now dealt with. Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS. Fixes #41057. git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
* Build/Test tools: Move `wp_doing_ajax` defintion from class setup to test setup.Peter Wilson2017-10-23
| | | | | | | | | | | Moves defintion of ajax request in `WP_Ajax_UnitTestCase` to `setUp()` method to account for hooks being reset as part of `tearDown()`. Props matthias.thiel for report. Fixes #41561. git-svn-id: https://develop.svn.wordpress.org/trunk@41970 602fd350-edb4-49c9-b593-d223f7449a82
* Build/Test tools: Remove usage of `DOING_AJAX` from the test suite, so all ↵John Blackbourn2017-08-22
| | | | | | | | | | | | | tests that expect either an Ajax request or a non-Ajax request can operate without being skipped. Props Mte90 Fixes #41561 git-svn-id: https://develop.svn.wordpress.org/trunk@41293 602fd350-edb4-49c9-b593-d223f7449a82
* Docs: Correct some inline docs for the Ajax test case.John Blackbourn2017-07-23
| | | | | | | See #41017 git-svn-id: https://develop.svn.wordpress.org/trunk@41119 602fd350-edb4-49c9-b593-d223f7449a82
* Build/Test Tools: Fix PHP 5.2 compatibility for grandchild methods which ↵John Blackbourn2017-06-02
| | | | | | | | | | | | | expect exceptions to be raised. This is due to `is_callable( 'parent::setExpectedException' )` not being supported on PHP 5.2 when the method being checked only exists on the grandparent class. Props jdgrimes See #39822 git-svn-id: https://develop.svn.wordpress.org/trunk@40872 602fd350-edb4-49c9-b593-d223f7449a82
* Build/Test Tools: Move the `setExpectedException()` method into the ↵John Blackbourn2017-04-23
| | | | | | | | | | | `WP_Ajax_UnitTestCase` class to avoid a fatal error when PHPUnit 3.6 is in use. This needs more investigation but it gets the test suite on PHP 5.2 passing again. See #39822 git-svn-id: https://develop.svn.wordpress.org/trunk@40539 602fd350-edb4-49c9-b593-d223f7449a82
* Plugins: Move capability checks further up in `wp_ajax_update_plugin()` and ↵Dominik Schilling2016-07-27
| | | | | | | | | | | `wp_ajax_delete_plugin()`. Add tests for both Ajax handlers. Props Yorick Koster, swissspidy. Fixes #37490. git-svn-id: https://develop.svn.wordpress.org/trunk@38168 602fd350-edb4-49c9-b593-d223f7449a82
* Media: Remove an extra quote when sending a link of a media file to the editor.Dominik Schilling (ocean90)2016-04-21
| | | | | | | | | Introduced in [37035]. Props joemcgill, swissspidy, boonebgorges. Fixes #36578. git-svn-id: https://develop.svn.wordpress.org/trunk@37288 602fd350-edb4-49c9-b593-d223f7449a82
* Docs: Reference the correct variable in ↵Sergey Biryukov2016-04-14
| | | | | | | | | `WP_Ajax_UnitTestCase::_handleAjax()` documentation. Props meitar. Fixes #36522. git-svn-id: https://develop.svn.wordpress.org/trunk@37199 602fd350-edb4-49c9-b593-d223f7449a82
* AJAX UNIT TESTS: Have you ever wondered why these take 600 forevers to run? ↵Scott Taylor2015-10-21
| | | | | | | | | They all eventually call `do_action( 'admin_init' )`, which has `_maybe_update_core`, `_maybe_update_plugins`, and `_maybe_update_themes` hooked to it. REMOVE THEM, and AJAX unit tests run like the wind. `Tests_Ajax_Response` is still slow. See #30017, #33968. git-svn-id: https://develop.svn.wordpress.org/trunk@35311 602fd350-edb4-49c9-b593-d223f7449a82
* Unit Tests: after [35225], make `factory` a method/getter on ↵Scott Taylor2015-10-17
| | | | | | | | | | | `WP_UnitTestCase` and add magic methods for BC for every plugin that is extending `WP_UnitTestCase` and accessing the `$factory` instance prop. Props nerrad, wonderboymusic. See #30017, #33968. git-svn-id: https://develop.svn.wordpress.org/trunk@35242 602fd350-edb4-49c9-b593-d223f7449a82
* Unit Tests: one `$factory` to rule them all, and it shall be `static`. Scott Taylor2015-10-16
| | | | | | | | | | | | | Using more than one instance of `WP_UnitTest_Factory` causes all kinds of craziness, due to out-of-sync internal generator sequences. Since we want to use `setUpBeforeClass`, we were creating ad hoc instances. To avoid that, we were injecting one `static` instance via Dependency Injection in `wpSetUpBeforeClass`. All tests should really use the `static` instance, so we will remove the instance prop `$factory`. Replace `$this->factory` with `self::$factory` over 2000 times. Rewrite all of the tests that were hard-coding dynamic values. #YOLOFriday git-svn-id: https://develop.svn.wordpress.org/trunk@35225 602fd350-edb4-49c9-b593-d223f7449a82
* Tests: Remove the `@runTestsInSeparateProcesses` annotation for Ajax tests.Dominik Schilling (ocean90)2015-10-15
| | | | | | | | | | | They were added 3 years ago in [846/tests] because tests weren't excluded from the normal runs. Reverts [35209] because it doesn't work with Xdebug. `Tests_Ajax_Response::test_response_charset_in_header` is the only test which needs to run in a separate process, see [975/tests]. See #31491. git-svn-id: https://develop.svn.wordpress.org/trunk@35211 602fd350-edb4-49c9-b593-d223f7449a82
* Tests: Don't preserve the global state for Ajax tests when using an external ↵Dominik Schilling (ocean90)2015-10-15
| | | | | | | | | | object cache. Most of the Ajax tests are running in a separate PHP process, and thus PHPUnit attempts to preserve the global state from the parent process by serializing all globals. But this doesn't work for external object caches so we have to disable this "feature". See #31491. git-svn-id: https://develop.svn.wordpress.org/trunk@35209 602fd350-edb4-49c9-b593-d223f7449a82
* Autosave: refactor autosave.js, use heartbeat for transport and move all ↵Andrew Ozz2014-01-22
| | | | | | "Add/Edit Post" related functionality to post.js. See #25272. git-svn-id: https://develop.svn.wordpress.org/trunk@26995 602fd350-edb4-49c9-b593-d223f7449a82
* Fix several esoteric errors related to AJAX unit tests for comments:Scott Taylor2013-09-14
| | | | | | | | | | | | | | | * `wp_ajax_get_comments()` relies on the `$post_id` global - even though `$_POST['p']` is passed to every action in the test methods. If `$post_id` is still lingering in between tests and doesn't match `p` in the request, the cap check might pass while the queries for comments will blow up. I added `unset( $GLOBALS['post_id'] )` to `Tests_Ajax_GetComments::setUp()`. * If the global `$post_id` is empty, but `$_REQUEST['p']` is not, `$post_id` is now set to `absint( $_REQUEST['p'] )` and sanity-checked in `wp_ajax_get_comments()`. * `map_meta_cap()` always assumes that `get_comment()` succeeds when checking for the `edit_comment` cap. It doesn't. I added sanity checks in a few places where it will break early if `get_post()` or `get_comment()` are empty. * `wp_update_comment()` always assumes `get_comment()` succeeds. It doesn't. I added a check for empty. All AJAX unit tests run and pass in debug mode. All general unit tests pass against these changes. Fixes #25282. git-svn-id: https://develop.svn.wordpress.org/trunk@25438 602fd350-edb4-49c9-b593-d223f7449a82
* Remove the unnecessary call to `ob_end_clean()` directly after ↵Scott Taylor2013-09-13
| | | | | | | | | | `ob_get_clean()` in `WP_Ajax_UnitTestCase::dieHandler()`. This fixes a large number of AJAX errors in debug mode. See #25282. git-svn-id: https://develop.svn.wordpress.org/trunk@25432 602fd350-edb4-49c9-b593-d223f7449a82
* Move PHPUnit tests into a tests/phpunit directory.Andrew Nacin2013-08-29
wp-tests-config.php can/should reside in the root of a develop checkout. `phpunit` should be run from the root. see #25088. git-svn-id: https://develop.svn.wordpress.org/trunk@25165 602fd350-edb4-49c9-b593-d223f7449a82