-
-
Notifications
You must be signed in to change notification settings - Fork 495
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1480 from WordPress-Coding-Standards/feature/norm…
…alize-unittest-case-file-names Normalize unittest case file names
- Loading branch information
Showing
5 changed files
with
106 additions
and
106 deletions.
There are no files selected for viewing
88 changes: 78 additions & 10 deletions
88
WordPress/Tests/NamingConventions/ValidHookNameUnitTest.1.inc
This file contains 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 |
---|---|---|
@@ -1,17 +1,85 @@ | ||
<?php | ||
|
||
// @codingStandardsChangeSetting WordPress.NamingConventions.ValidHookName additionalWordDelimiters - | ||
$this->do_action( 'someAction' ); // Ok - not WP do_action. | ||
SomeClass::do_action( 'someAction' ); // Ok - not WP do_action. | ||
prefix_do_action( 'someAction' ); // Ok - not WP do_action. | ||
|
||
// These should now be ok. | ||
do_action( "admin_head-$hook_suffix" ); | ||
do_action( 'admin_head-media-upload_popup' ); | ||
apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions ); | ||
apply_filters( "current_theme-supports-{$feature}", true, $args, $_wp_theme_features[$feature] ); | ||
|
||
// These should still give warnings. | ||
do_action( "admin_head*$hook_suffix" ); // Warning - use underscore. | ||
// Check for incorrect word separators. | ||
do_action( "admin_head-$hook_suffix" ); // Warning - use underscore. | ||
do_action( 'admin_head.media.upload_popup' ); // Warning - use underscore. | ||
apply_filters( "bulk_actions {$this->screen->id}", $this->_actions ); // Warning - use underscore. | ||
apply_filters( "current_theme/supports-{$feature}", true, $args, $_wp_theme_features[$feature] ); // Warning - use underscore. | ||
|
||
// @codingStandardsChangeSetting WordPress.NamingConventions.ValidHookName additionalWordDelimiters _ | ||
// Simple strings. | ||
do_action( "adminHead" ); // Error - use lowercase. | ||
do_action_ref_array( 'ADMINHEAD', array( $variable ) ); // Error - use lowercase. | ||
apply_filters( 'adminHead', $variable ); // Error - use lowercase. | ||
apply_filters_ref_array( 'ADMINHEAD', array( $variable ) ); // Error - use lowercase. | ||
|
||
// Variable hooks. | ||
do_action( $Hook_name ); // Ok. | ||
do_action( "{$Hook_Name}" ); // Ok. | ||
|
||
// Compound hook names. | ||
do_action( 'admin_head_' . $Type . '_action' ); // ok. | ||
do_action( 'admin_head_' . get_ID() . '_action' ); // Ok. | ||
do_action( 'admin_head_' . $post->ID . '_action' ); // Ok. | ||
|
||
do_action( 'admin_Head_' . $Type . '_Action' ); // Error - use lowercase. | ||
do_action( 'admin_Head_' . get_ID() . '_Action' ); // Error - use lowercase. | ||
do_action( 'admin_Head_' . $post->ID . '_Action' ); // Error - use lowercase. | ||
|
||
do_action( | ||
'admin_Head_' . $type, | ||
$variable | ||
); // Error - use lowercase. | ||
|
||
// More complex strings. | ||
do_action( "admin_head_$Post" ); // Ok. | ||
do_action( "admin_head_$Post[1]_action" ); // Ok. | ||
do_action( "admin_head_$Post[Test]_action" ); // Ok. | ||
do_action( "admin_head_${Post}_action" ); // Ok. | ||
do_action( "admin_head_$Post->ID" ); // Ok. | ||
do_action( "admin_head_{$Post}" ); // Ok. | ||
do_action( "admin_head_{$Post['Key']}_action" ); // Ok. | ||
do_action( "admin_head_{$Post[1][2]}_action" ); // Ok. | ||
do_action( "admin_head_{$post->ID}_action" ); // Ok. | ||
do_action( "admin_head_{$obj->Values[3]->name}_action" ); // Ok. | ||
do_action( "admin_head_{${$Name}}_action" ); // Ok. | ||
do_action( "admin_head_{$foo->{$baz[1]}}_action" ); // Ok. | ||
do_action( "admin_head_{${getName()}}_action" ); // Ok. | ||
do_action( "admin_head_{${$object->getName()}}_action" ); // Ok. | ||
|
||
do_action( "admin_Head_$Post" ); // Error - use lowercase. | ||
do_action( "admin_Head_$Post[1]_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_$Post[Test]_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_${Post}_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_$Post->ID" ); // Error - use lowercase. | ||
do_action( "admin_Head_{$Post}" ); // Error - use lowercase. | ||
do_action( "admin_Head_{$Post['Key']}_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_{$Post[1][2]}_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_{$post->ID}_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_{$obj->Values[3]->name}_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_{${$Name}}_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_{$foo->{$baz[1]}}_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_{${getName()}}_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_{${$object->getName()}}_Action" ); // Error - use lowercase. | ||
|
||
do_action( "admin_Head_$Post admin_Head_$Post" ); // Error - use lowercase + warning about space. | ||
do_action( "admin_Head_$Post[1]_Action_$Post[1]_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_$Post[Test]_Action_$Post[Test]_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_${Post}_Action_${Post}_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_$Post->ID admin_Head_$Post->ID" ); // Error - use lowercase + warning about space. | ||
do_action( "admin_Head_{$Post}_admin_Head_{$Post}" ); // Error - use lowercase. | ||
do_action( "admin_Head_{$Post['Key']}_Action_{$Post['Key']}_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_{$Post[1][2]}_Action_{$Post[1][2]}_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_{$post->ID}_Action_{$post->ID}_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_{$obj->Values[3]->name}-Action_{$obj->Values[3]->name}_Action" ); // Error - use lowercase + warning about dash. | ||
do_action( "admin_Head_{${$Name}}_Action_{${$Name}}_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_{$foo->{$baz[1]}}_Action_{$foo->{$baz[1]}}_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_{${getName()}}_Action_{${getName()}}_Action" ); // Error - use lowercase. | ||
do_action( "admin_Head_{${$object->getName()}}_Action_{${$object->getName()}}_Action" ); // Error - use lowercase. | ||
|
||
// Make sure that deprecated hook names are ignored for this sniff. | ||
do_action_deprecated( "admin_Head_$Post admin_Head_$Post" ); // Ok. | ||
apply_filters_deprecated( "admin_Head_$Post->ID admin_Head_$Post->ID" ); // Ok. |
10 changes: 5 additions & 5 deletions
10
WordPress/Tests/NamingConventions/ValidHookNameUnitTest.2.inc
This file contains 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 |
---|---|---|
@@ -1,17 +1,17 @@ | ||
<?php | ||
|
||
// @codingStandardsChangeSetting WordPress.NamingConventions.ValidHookName additionalWordDelimiters -/. | ||
// @codingStandardsChangeSetting WordPress.NamingConventions.ValidHookName additionalWordDelimiters - | ||
|
||
// These should now be ok. | ||
do_action( "admin_head-$hook_suffix" ); | ||
do_action( 'admin_head.media-upload_popup' ); | ||
do_action( 'admin_head-media-upload_popup' ); | ||
apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions ); | ||
apply_filters( "current_theme/supports-{$feature}", true, $args, $_wp_theme_features[$feature] ); | ||
apply_filters( "current_theme-supports-{$feature}", true, $args, $_wp_theme_features[$feature] ); | ||
|
||
// These should still give warnings. | ||
do_action( "admin_head*$hook_suffix" ); // Warning - use underscore. | ||
do_action( 'admin_head&media+upload_popup' ); // Warning - use underscore. | ||
do_action( 'admin_head.media.upload_popup' ); // Warning - use underscore. | ||
apply_filters( "bulk_actions {$this->screen->id}", $this->_actions ); // Warning - use underscore. | ||
apply_filters( "current_theme#supports-{$feature}", true, $args, $_wp_theme_features[$feature] ); // Warning - use underscore. | ||
apply_filters( "current_theme/supports-{$feature}", true, $args, $_wp_theme_features[$feature] ); // Warning - use underscore. | ||
|
||
// @codingStandardsChangeSetting WordPress.NamingConventions.ValidHookName additionalWordDelimiters _ |
17 changes: 17 additions & 0 deletions
17
WordPress/Tests/NamingConventions/ValidHookNameUnitTest.3.inc
This file contains 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,17 @@ | ||
<?php | ||
|
||
// @codingStandardsChangeSetting WordPress.NamingConventions.ValidHookName additionalWordDelimiters -/. | ||
|
||
// These should now be ok. | ||
do_action( "admin_head-$hook_suffix" ); | ||
do_action( 'admin_head.media-upload_popup' ); | ||
apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions ); | ||
apply_filters( "current_theme/supports-{$feature}", true, $args, $_wp_theme_features[$feature] ); | ||
|
||
// These should still give warnings. | ||
do_action( "admin_head*$hook_suffix" ); // Warning - use underscore. | ||
do_action( 'admin_head&media+upload_popup' ); // Warning - use underscore. | ||
apply_filters( "bulk_actions {$this->screen->id}", $this->_actions ); // Warning - use underscore. | ||
apply_filters( "current_theme#supports-{$feature}", true, $args, $_wp_theme_features[$feature] ); // Warning - use underscore. | ||
|
||
// @codingStandardsChangeSetting WordPress.NamingConventions.ValidHookName additionalWordDelimiters _ |
85 changes: 0 additions & 85 deletions
85
WordPress/Tests/NamingConventions/ValidHookNameUnitTest.inc
This file was deleted.
Oops, something went wrong.
This file contains 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