Make WordPress Core

Opened 6 weeks ago

Last modified 2 weeks ago

#66223 new defect (bug)

Add tests for wp_admin_bar_shortlink_menu

Reported by: r1k0 Owned by:
Priority: normal Milestone: Awaiting Review
Component: Build/Test Tools Version:
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses: tests

Description

Checks when the shortlink exists and when it doesn't.

Change History (10)

This ticket was mentioned in ​PR #13883 on ​WordPress/wordpress-develop by ​@r1k0.


6 weeks ago
#1

  • Keywords has-patch has-unit-tests added

Tests when shortlink when shortlink doesn't exists and when it does.

Trac ticket: #66223

Use of AI Tools

AI assistance: Yes
Tool(s): ChatGPT
Used for: Initial code skeleton and test suggestions; final implementation and tests were reviewed and edited by me.

​@mukesh27 commented on ​PR #13883:


6 weeks ago
#2

Tests with multiple assertions are missing the message parameter.

​@r1k0 commented on ​PR #13883:


6 weeks ago
#3

Updated

​@r1k0 commented on ​PR #13883:


6 weeks ago
#4

Updated with suggested changes

​@r1k0 commented on ​PR #13883:


6 weeks ago
#5

Updated

#6 @anntrauf
6 weeks ago

Tested PR #13883 for ticket #66223.

Environment:

  • WordPress trunk (7.2-alpha)
  • PHP 8.3.26
  • PHPUnit 9.6.37
  • Windows 10 / Docker
  • Single site

Test command:
npm run test:php -- --filter wp_admin_bar_shortlink_menu

Result:
PASS

Both tests passed successfully:
2 tests, 7 assertions.

The tests cover the shortlink empty and shortlink available scenarios as described in the ticket.

​@r1k0 commented on ​PR #13883:


6 weeks ago
#7

Thank you for the review.

Updated with suggested changes and add the special characters tests.

​@r1k0 commented on ​PR #13883:


6 weeks ago
#8

Thank you again @mukeshpanchal27. Applied all the changes suggested.
Re-run the tests and they are all passing.

#9 @lancewillett
2 weeks ago

In 65105:

Tests: Cover admin bar shortlink output.

Verify wp_admin_bar_shortlink_menu() omits the node for an empty shortlink, renders the expected link and input, and escapes attribute values.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/13883

Props r1k0, mukesh27, pbearne, anntrauf.
See #66223.

Note: See TracTickets for help on using tickets.