-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Application Passwords: Render a row header in the AJAX row template #12690
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
itzmekhokan
wants to merge
1
commit into
WordPress:trunk
Choose a base branch
from
itzmekhokan:fix/65707-app-password-ajax-th-header
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.
+66
−2
Open
Changes from all commits
Commits
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
59 changes: 59 additions & 0 deletions
59
tests/phpunit/tests/admin/wpApplicationPasswordsListTable.php
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,59 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * @group admin | ||
| * @group application-passwords | ||
| * | ||
| * @covers WP_Application_Passwords_List_Table | ||
| */ | ||
| class Tests_Admin_wpApplicationPasswordsListTable extends WP_UnitTestCase { | ||
|
|
||
| /** | ||
| * @var WP_Application_Passwords_List_Table | ||
| */ | ||
| private $table; | ||
|
|
||
| public function set_up() { | ||
| parent::set_up(); | ||
| $this->table = _get_list_table( | ||
| 'WP_Application_Passwords_List_Table', | ||
| array( 'screen' => 'application-passwords-user' ) | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Ensures the JavaScript row template used for a password created via AJAX | ||
| * renders the primary column as a `<th scope="row">` row header, matching | ||
| * the server-rendered markup from WP_List_Table::single_row_columns(). | ||
| * | ||
| * @ticket 65707 | ||
| * | ||
| * @covers WP_Application_Passwords_List_Table::print_js_template_row | ||
| */ | ||
| public function test_print_js_template_row_uses_th_row_header_for_primary_column() { | ||
| ob_start(); | ||
| $this->table->print_js_template_row(); | ||
| $html = ob_get_clean(); | ||
|
|
||
| // Assert on the tag structure and `scope="row"` rather than the localized | ||
| // column label, so the test does not depend on the current locale or on | ||
| // filters that adjust the column headers. | ||
| $this->assertMatchesRegularExpression( | ||
| '/<th class="name column-name has-row-actions column-primary" data-colname="[^"]*" scope="row">/', | ||
| $html, | ||
| 'The primary column should be rendered as a <th scope="row"> row header.' | ||
| ); | ||
|
Comment on lines
+41
to
+45
|
||
|
|
||
| $this->assertStringNotContainsString( | ||
| '<td class="name column-name', | ||
| $html, | ||
| 'The primary column should not be rendered as a <td> cell.' | ||
| ); | ||
|
|
||
| $this->assertStringContainsString( | ||
| '<td class="created column-created"', | ||
| $html, | ||
| 'Non-primary columns should still be rendered as <td> cells.' | ||
| ); | ||
| } | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
translatorscommentThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mukeshpanchal27. I looked into this, and I don't think a translators comment applies on this line — could you double-check?
This printf() only assembles the opening tag:
printf( '<%1$s class="%2$s" data-colname="%3$s"%4$s>', $tag, esc_attr( $classes ), esc_attr( wp_strip_all_tags( $display_name ) ), $scope );The
%1$s–%4$splaceholders are filled by$tag (th/td),$classes,$display_name, and$scope— none of them is a gettext call, so there's no translatable string here for a translators comment to describe. (The change from %s to numbered placeholders is just to keep the format readable now that there are four arguments.)Happy to add one if you were pointing at a different line — let me know.