The `Block_Supported_Styles_Test` class is not a `TestCase` to be extended, but an actual concrete test class. In order to run as expected, it should be placed under `phpunit/tests/blocks/` along with the other block tests.
Additionally:
* Add missing visibility keywords to test methods.
* Update the expected results to the currently used format for the tests to pass.
* Remove two outdated tests. The functionality being tested there is no longer available in this manner, so these tests are redundant.
Follow-up to [49226], [49310].
Props jrf, aristath, youknowriad.
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51490 602fd350-edb4-49c9-b593-d223f7449a82
* Check if the object attribute exists before checking its value.
* Mention the field name in error messages in case of failure.
Follow-up to [51478], [51479], [51480].
Props jrf.
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51481 602fd350-edb4-49c9-b593-d223f7449a82
* Use `assertSame()` instead of `fail()` to display a proper message in case of failure.
* Add an optional `$message` parameter for consistency with other assertions.
Follow-up to [51478], [51479].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51480 602fd350-edb4-49c9-b593-d223f7449a82
All assertions in PHPUnit have a `$message` parameter. Setting this parameter allows to distinguish which assertion is failing when a test runs multiple assertions, making debugging of the tests easier.
This optional parameter is now added for the assertion methods in the `WP_UnitTestCase_Base` class that were missing it.
Props jrf.
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51478 602fd350-edb4-49c9-b593-d223f7449a82
A concrete test class should be suffixed with `Test`, not `UnitTestCase(s)`.
Follow-up to [25053].
Props jrf.
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51476 602fd350-edb4-49c9-b593-d223f7449a82
Using the `assertContains()` and `assertNotContains()` methods with string haystacks was deprecated in PHPUnit 8 and removed in PHPUnit 9.
While WordPress test suite currently only supports PHPUnit up to 7.5.x, this allows us to switch to newer assertions ahead of adding full support for PHPUnit 8+.
These methods introduced in PHPUnit 7.5 should be used as an alternative:
* `assertStringContainsString()`
* `assertStringContainsStringIgnoringCase`
* `assertStringNotContainsString()`
* `assertStringNotContainsStringIgnoringCase`
As WordPress currently uses PHPUnit 5.7.x to run tests on PHP 5.6, polyfills for these methods were added to the `WP_UnitTestCase` class for PHPUnit < 7.5.
Follow-up to [51331], [51451], [51461].
Props jrf, dd32, SergeyBiryukov.
See #53363, #46149.
git-svn-id: https://develop.svn.wordpress.org/trunk@51462 602fd350-edb4-49c9-b593-d223f7449a82
This replaces instances of `assertFalse( stripos( ... ) )` with `assertStringNotContainsString()` or `assertStringNotContainsStringIgnoringCase()` to use native PHPUnit functionality.
Going forward, these methods introduced in PHPUnit 7.5 should be used for similar assertions:
* `assertStringContainsString()`
* `assertStringContainsStringIgnoringCase()`
* `assertStringNotContainsString()`
* `assertStringNotContainsStringIgnoringCase()`
As WordPress currently uses PHPUnit 5.7.x to run tests on PHP 5.6, polyfills for these methods are now added to the `WP_UnitTestCase` class for PHPUnit < 7.5.
Follow-up to [51335], [51337], [51367], [51397], [51403], [51404], [51436], [51438], [51448], [51449], [51451], [51453], [51454].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51461 602fd350-edb4-49c9-b593-d223f7449a82
This replaces instances of `assertTrue( ... > 0 )` with `assertGreaterThan()` to use native PHPUnit functionality.
Follow-up to [51335], [51337], [51367], [51397], [51403], [51404], [51436], [51438], [51448], [51449], [51451], [51453].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51454 602fd350-edb4-49c9-b593-d223f7449a82
This replaces instances of `assertSame( true, ... )` with `assertTrue()` to use native PHPUnit functionality.
Follow-up to [38832].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51453 602fd350-edb4-49c9-b593-d223f7449a82
This avoids a "Class not found" PHP fatal error when running these tests separately.
Follow-up to [38832].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51452 602fd350-edb4-49c9-b593-d223f7449a82
This replaces instances of `assertTrue( strpos( ... ) > 0 )` with `assertStringContainsString()` to use native PHPUnit functionality.
Going forward, these methods introduced in PHPUnit 7.5 should be used for similar assertions:
* `assertStringContainsString()`
* `assertStringNotContainsString()`
As WordPress currently uses PHPUnit 5.7.x to run tests on PHP 5.6, polyfills for these methods are now added to the `WP_UnitTestCase` class for PHPUnit < 7.5.
Follow-up to [51335], [51337], [51367], [51397], [51403], [51404], [51436], [51438], [51448], [51449].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51451 602fd350-edb4-49c9-b593-d223f7449a82
`wp_autosave()` only updates drafts and auto-drafts created by the current user if the post is not locked.
As a result of previous Ajax test refactoring, setting the current user and creating a test post ended up in different methods, with the user being set after the post is already created.
This resulted in the test post being created with the `post_author` field set to zero, and the current user check in `wp_autosave()` failed. Instead of updating the original post as the test intended, it created a new autosave.
The test only passed accidentally due to `assertGreaterThanOrEqual()` not performing a strict type check.
Follow-up to [26995], [35311].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51450 602fd350-edb4-49c9-b593-d223f7449a82
This replaces instances of `assertSame( 0, strpos( ... ) )` with `assertStringStartsWith()` to use native PHPUnit functionality.
Follow-up to [51335], [51337], [51367], [51397], [51403], [51404], [51436], [51438], [51448].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51449 602fd350-edb4-49c9-b593-d223f7449a82
This replaces instances of `assertTrue( is_string( ... ) )` with `assertIsString()` to use native PHPUnit functionality.
Follow-up to [51335], [51337], [51367], [51397], [51403], [51404], [51436], [51438].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51448 602fd350-edb4-49c9-b593-d223f7449a82
This includes:
- Suggestion List: Check if a node exists to scroll into view.
- Autocomplete: reset state for empty text.
- Adds auxiliary class names for editor styles in the widgets editor.
- Extract snackbars into a separate component.
- Rich text: run input rules after composition end.
- iframe: load inline styles.
- Multi select: select all: restore ref callback.
- Writing flow: allow select all from empty selection.
- Post Excerpt: Fix excerpt_more filter conflict and remove wordCount attribute.
- Add the percent unit to the default units in Core.
Props desrosj.
See #53397.
git-svn-id: https://develop.svn.wordpress.org/trunk@51443 602fd350-edb4-49c9-b593-d223f7449a82
This replaces instances of `assertTrue( is_numeric( ... ) )` with `assertIsNumeric()` to use native PHPUnit functionality.
Follow-up to [51335], [51337], [51367], [51397], [51403], [51404], [51436].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51438 602fd350-edb4-49c9-b593-d223f7449a82
This replaces instances of `assertTrue( is_a( ... ) )` with `assertInstanceOf()` to use native PHPUnit functionality.
Follow-up to [51335], [51337], [51367], [51397], [51403], [51404].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51436 602fd350-edb4-49c9-b593-d223f7449a82
This provides a consistent global starting state for tests that interact with admin screens.
Individual tests no longer need to invoke `set_current_screen( 'front' )` (or an alternative implementation) as a reset.
Follow-up to [29251], [29860], [31046], [36721], [38678], [48908], [50433].
Props hellofromTonya, johnbillion.
Fixes#53431.
git-svn-id: https://develop.svn.wordpress.org/trunk@51419 602fd350-edb4-49c9-b593-d223f7449a82
This improves the consistency of test skipping and ensures that:
* The `@requires` annotations use the right condition and format, and are on the right level (class vs. function).
* Inline conditions with a `markTestSkipped()` call are only used when annotations cannot be used.
* All `markTestSkipped()` calls contain a verbose explanation of why the test is being skipped.
Props jrf, hellofromTonya.
Fixes#53009.
git-svn-id: https://develop.svn.wordpress.org/trunk@51415 602fd350-edb4-49c9-b593-d223f7449a82
This switches `WP_REST_Sidebars_Controller` to use `wp_sidebar_description()` for retrieving the `description` of a given sidebar instead of referencing the value in the `$wp_registered_sidebars` global variable directly.
`wp_sidebar_description()` uses `wp_kses()` to only allow the default list of `$allowed_tags` to be present in a sidebar’s `description`.
Props timothyblynjacobs, desrosj.
Fixes#53646.
git-svn-id: https://develop.svn.wordpress.org/trunk@51408 602fd350-edb4-49c9-b593-d223f7449a82
This replaces instances of `assertTrue( in_array( ... ) )` with `assertContains()` to use native PHPUnit functionality.
Follow-up to [51335], [51337], [51367], [51397], [51403].
Props hellofromTonya, jrf, SergeyBiryukov.
Fixes#53123. See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51404 602fd350-edb4-49c9-b593-d223f7449a82
This replaces instances of `assertTrue( empty( ... ) )` with `assertEmpty()` to use native PHPUnit functionality.
Follow-up to [51335], [51337], [51367], [51397].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51403 602fd350-edb4-49c9-b593-d223f7449a82
This replaces instances of `assertTrue( isset( ... ) )` with `assertArrayHasKey()` to use native PHPUnit functionality.
Follow-up to [51335], [51337], [51367].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51397 602fd350-edb4-49c9-b593-d223f7449a82
This commit fixes an issue with the color.duotone & spacing.units in which empty values didn't override previous origins, resulting in that a theme couldn't provide an empty set for this via its theme.json.
Props nosolosw, youknowriad, aristath.
See #53175.
git-svn-id: https://develop.svn.wordpress.org/trunk@51383 602fd350-edb4-49c9-b593-d223f7449a82
When a widget is removed from a sidebar, if it was removed from the middle of the list, the widgets property would become an object with numeric keys.
The sidebars controller now forces the widgets property to be a list.
Props walbo.
Fixes#53612.
git-svn-id: https://develop.svn.wordpress.org/trunk@51377 602fd350-edb4-49c9-b593-d223f7449a82
This adds unit tests to ensure `get_block_editor_settings()` properly maps some previously experimental features to their correct locations in the array of contextualized block editor settings returned by the function.
Follow up to [51149], [51213].
Props felipeelia.
Fixes#53458.
git-svn-id: https://develop.svn.wordpress.org/trunk@51369 602fd350-edb4-49c9-b593-d223f7449a82
This replaces instances of `assertSame( [number], count( ... ) )` with `assertCount()` to use native PHPUnit functionality.
Follow-up to [51335], [51337].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51367 602fd350-edb4-49c9-b593-d223f7449a82
Previously errors were not displayed or logged, but the original intention was only to prevent them from being displayed. Hiding them from logs makes problems like #53492 much harder to debug.
This makes the handling of errors in `ms-files` consistent with the REST API, `admin-ajax`, and XML-RPC.
Props iandunn, johnjamesjacoby.
Fixes#53493.
git-svn-id: https://develop.svn.wordpress.org/trunk@51358 602fd350-edb4-49c9-b593-d223f7449a82
This improves the logic within `excerpt_remove_blocks()` to better handle `innerBlocks`. This prevents an empty excerpt from being returned when `core/columns`, `core/column`, and `core/group` blocks are present.
This issue has been surfaced in the Query Loop block, where excerpts can be set to display.
Props aristath.
Fixes#53604.
git-svn-id: https://develop.svn.wordpress.org/trunk@51348 602fd350-edb4-49c9-b593-d223f7449a82
Includes the following fixes:
- [Block Library]: Less warnings when blocks try to render themselves.
- Reset z-index on focused widget form
- Refactor appender margin.
- Fix slash inserter for widgets screen.
- Widget screens: set html block as freeform content handler.
- Widget Block: widget_id is undefined when a widget is placed.
- Add <CopyHandler> to WidgetAreasBlockEditorProvider
- Add width: 100% to components-base-control inside wp-block-legacy-widget
- [Widgets editor] Replace the "technical" error notice a more user-friendly one
- Fix legacy widget height overflow
- Fix "Select all" behavior in the editor
- Increase specificity of the NoPreview CSS rules to avoid conflicts with theme styles
- Fix move to widget area checkmark
- Replace legacy widget icon with its new version
- [Block Library - Query Loop]: Set default block variations not to inherit from global query
See #53397.
git-svn-id: https://develop.svn.wordpress.org/trunk@51344 602fd350-edb4-49c9-b593-d223f7449a82
This replaces instances of `assertTrue( is_object( ... ) )` with `assertIsObject()` to use native PHPUnit functionality.
Follow-up to [51331], [51335].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51337 602fd350-edb4-49c9-b593-d223f7449a82
This replaces instances of `assertTrue( is_array( ... ) )` with `assertIsArray()` to use native PHPUnit functionality.
Follow-up to [51331].
See #53363.
git-svn-id: https://develop.svn.wordpress.org/trunk@51335 602fd350-edb4-49c9-b593-d223f7449a82
The `assertInternalType()` and `assertNotInternalType()` methods are deprecated in PHPUnit 8 and removed in PHPUnit 9.
While WordPress test suite currently only supports PHPUnit up to 7.5.x, this allows us to switch to newer assertions ahead of adding full support for PHPUnit 8+.
These methods introduced in PHPUnit 7.5 should be used as an alternative:
* `assertIsArray()`
* `assertIsBool()`
* `assertIsFloat()`
* `assertIsInt()`
* `assertIsNumeric()`
* `assertIsObject()`
* `assertIsResource()`
* `assertIsString()`
* `assertIsScalar()`
* `assertIsCallable()`
* `assertIsIterable()`
* `assertIsNotArray()`
* `assertIsNotBool()`
* `assertIsNotFloat()`
* `assertIsNotInt()`
* `assertIsNotNumeric()`
* `assertIsNotObject()`
* `assertIsNotResource()`
* `assertIsNotString()`
* `assertIsNotScalar()`
* `assertIsNotCallable()`
* `assertIsNotIterable()`
As WordPress currently uses PHPUnit 5.7.x to run tests on PHP 5.6, polyfills for these methods are now added to the `WP_UnitTestCase` class for PHPUnit < 7.5.
Props pbearne, jrf, dd32, SergeyBiryukov.
Fixes#53491. See #46149.
git-svn-id: https://develop.svn.wordpress.org/trunk@51331 602fd350-edb4-49c9-b593-d223f7449a82
This resets the `WP_Widget::$updated` flag when deleting a widget, to avoid blocking all future updates in a request.
Props noisysocks, andraganescu.
Fixes#53557.
git-svn-id: https://develop.svn.wordpress.org/trunk@51277 602fd350-edb4-49c9-b593-d223f7449a82
When querying multiple post types, check the `read_private_posts` capability for each post type when determining which post statuses to return. This ensures private posts appear in search results and archives for users permitted to read them.
Props leogermani, hellofromTonya, jeffpaul, peterwilsoncc.
Fixes#48556.
git-svn-id: https://develop.svn.wordpress.org/trunk@51276 602fd350-edb4-49c9-b593-d223f7449a82
[51259] introduced a PHP notice that was not actually fixed by [51265]. Reverting these changes in order to investigate further.
See #53397.
git-svn-id: https://develop.svn.wordpress.org/trunk@51268 602fd350-edb4-49c9-b593-d223f7449a82
This also adds support for the viewScript for blocks fixing
the PDF preview for file blocks.
Props desrosj, gziolo.
See #53397.
git-svn-id: https://develop.svn.wordpress.org/trunk@51259 602fd350-edb4-49c9-b593-d223f7449a82