Repository navigation
Tests: Cover wp_enqueue_editor() default asset enqueue
#16236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shail-mehta
wants to merge
6
commits into
WordPress:trunk
Choose a base branch
from
shail-mehta:tests/66757-wp-enqueue-editor
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
be28a32
Tests: Cover `wp_enqueue_editor()` default asset enqueue
shail-mehta d14521c
Apply Feedback changes
shail-mehta 6f1ead0
Update ticket number in wp_enqueue_editor test
shail-mehta e5f8f8f
Merge branch 'trunk' into tests/66757-wp-enqueue-editor
shail-mehta da7460b
Apply Feedback changes
shail-mehta 7062c6e
Remove redundant set_current_screen( 'front' ) cleanup call
shail-mehta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Tests for the `wp_enqueue_editor()` function. | ||
| * | ||
| * @group general | ||
| * @group editor | ||
| * | ||
| * @covers ::wp_enqueue_editor | ||
| */ | ||
| class Tests_General_WpEnqueueEditor extends WP_UnitTestCase { | ||
|
|
||
| /** | ||
| * Tests that wp_enqueue_editor() loads the default editor assets and footer hooks. | ||
| * | ||
| * @ticket 66822 | ||
| */ | ||
| public function test_wp_enqueue_editor_enqueues_default_assets() { | ||
| $old_wp_scripts = $GLOBALS['wp_scripts'] ?? null; | ||
| $old_wp_styles = $GLOBALS['wp_styles'] ?? null; | ||
|
|
||
| try { | ||
| $GLOBALS['wp_scripts'] = new WP_Scripts(); | ||
| $GLOBALS['wp_styles'] = new WP_Styles(); | ||
|
|
||
| wp_enqueue_editor(); | ||
|
|
||
| $this->assertTrue( wp_script_is( 'editor', 'enqueued' ), 'The editor script should be enqueued.' ); | ||
| $this->assertTrue( wp_style_is( 'editor-buttons', 'enqueued' ), 'The editor-buttons style should be enqueued.' ); | ||
| $this->assertSame( | ||
| 45, | ||
| has_action( 'wp_print_footer_scripts', array( '_WP_Editors', 'print_default_editor_scripts' ) ), | ||
| 'print_default_editor_scripts should be hooked at priority 45.' | ||
| ); | ||
| $this->assertSame( | ||
| 1, | ||
| has_action( 'wp_print_footer_scripts', array( '_WP_Editors', 'force_uncompressed_tinymce' ) ), | ||
| 'force_uncompressed_tinymce should be hooked at priority 1.' | ||
| ); | ||
| } finally { | ||
| $GLOBALS['wp_scripts'] = $old_wp_scripts; | ||
| $GLOBALS['wp_styles'] = $old_wp_styles; | ||
| } | ||
| } | ||
|
lancewillett marked this conversation as resolved.
Resolved
|
||
|
|
||
| /** | ||
| * Tests that wp_enqueue_editor() hooks the footer callbacks to the admin footer in the admin. | ||
| * | ||
| * @ticket 66822 | ||
| */ | ||
| public function test_wp_enqueue_editor_uses_admin_footer_hook_in_admin() { | ||
| $old_wp_scripts = $GLOBALS['wp_scripts'] ?? null; | ||
| $old_wp_styles = $GLOBALS['wp_styles'] ?? null; | ||
|
|
||
| try { | ||
| $GLOBALS['wp_scripts'] = new WP_Scripts(); | ||
| $GLOBALS['wp_styles'] = new WP_Styles(); | ||
|
|
||
| set_current_screen( 'dashboard' ); | ||
|
|
||
| wp_enqueue_editor(); | ||
|
|
||
| $this->assertSame( | ||
| 45, | ||
| has_action( 'admin_print_footer_scripts', array( '_WP_Editors', 'print_default_editor_scripts' ) ), | ||
| 'The default editor scripts should be printed in the admin footer.' | ||
| ); | ||
| $this->assertSame( | ||
| 1, | ||
| has_action( 'admin_print_footer_scripts', array( '_WP_Editors', 'force_uncompressed_tinymce' ) ), | ||
| 'TinyMCE should be forced uncompressed in the admin footer.' | ||
| ); | ||
| $this->assertFalse( | ||
| has_action( 'wp_print_footer_scripts', array( '_WP_Editors', 'print_default_editor_scripts' ) ), | ||
| 'The front-end footer hook should not be used in the admin.' | ||
| ); | ||
| } finally { | ||
| $GLOBALS['wp_scripts'] = $old_wp_scripts; | ||
| $GLOBALS['wp_styles'] = $old_wp_styles; | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.