WordPress.org

Make WordPress Core

Opened 6 weeks ago

Last modified 4 days ago

#51344 new task (blessed)

Unit test improvements for 5.6

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

Description

Background: #38266, #50913.

This ticket is for various fixes and improvements in PHPUnit tests that don't have a more specific ticket.

Change History (16)

#1 @SergeyBiryukov
6 weeks ago

In 48996:

Tests: Consistently use the expectException() method instead of the older @expectedException annotation.

See https://thephp.cc/news/2016/02/questioning-phpunit-best-practices

The method is available since PHPUnit 5.2, and WordPress currently supports PHPUnit 5.4 as the minimum version.

Follow-up to [48993].

See #51344.

#2 @SergeyBiryukov
6 weeks ago

In 48997:

Tests: Switch Ajax tests to use the expectException() method directly, instead of the WP_UnitTestCase_Base::setExpectedException() wrapper.

This brings some consistency with other tests.

Follow-up to [48996].

See #51344.

#3 @SergeyBiryukov
6 weeks ago

In 48998:

Docs: Update the code example in WP_Ajax_UnitTestCase::dieHandler() DocBlock to use expectException().

Follow-up to [48996], [48997].

See #51344.

#4 @SergeyBiryukov
6 weeks ago

In 48999:

Tests: Simplify PluralFormsTest::test_exceptions().

Previously, the test had to use an older pattern for catching the generic Exception exceptions for compatibility with PHPUnit 3.6 on PHP 5.2.

Now that WordPress supports PHPUnit 5.4 as the minimum version, the expectException() method can be used directly.

Follow-up to [41725], [41730].

See #51344.

#5 @SergeyBiryukov
6 weeks ago

In 49001:

Tests: Simplify the logic in WP_UnitTestCase_Base::setUpBeforeClass() and ::tearDownAfterClass().

See #51344.

#6 @SergeyBiryukov
6 weeks ago

In 49003:

Tests: Speed up slashed data tests by reusing shared fixtures.

Follow-up to [35249].

See #51344.

#7 @SergeyBiryukov
6 weeks ago

In 49004:

Coding Standards: Give the $id variable in slashed data tests a more descriptive name.

See #50767, #51344.

#8 @SergeyBiryukov
6 weeks ago

In 49005:

Tests: Speed up slashed data tests by reusing some more shared fixtures.

Follow-up to [35249], [49003].

See #51344.

#9 @SergeyBiryukov
6 weeks ago

In 49027:

Tests: Use consistent trailing punctuation in markTestSkipped() messages.

See #51344.

#10 @SergeyBiryukov
6 weeks ago

In 49030:

Tests: Fix typo in some markTestSkipped() messages.

See #51344.

#11 @SergeyBiryukov
6 weeks ago

In 49033:

Tests: Use consistent trailing punctuation in fail() messages.

See #51344.

#12 @SergeyBiryukov
3 weeks ago

In 49112:

Tests: Use consistent wording for the $position parameter in add_submenu_page() tests.

This replaces the instances of $priority with $position, to match the actual parameter name and avoid confusion.

Follow-up to [46197].

See #51344, #39776.

#13 @SergeyBiryukov
3 weeks ago

In 49140:

Tests: Correct the message in a sitemaps test for getting a URL list for a custom taxonomy that is not publicly queryable.

Follow-up to [48474].

See #51344, #50607.

This ticket was mentioned in PR #643 on WordPress/wordpress-develop by peterwilsoncc.


10 days ago

  • Keywords has-patch has-unit-tests added

#15 @peterwilsoncc
10 days ago

In 49268:

Tests: Use shared fixtures in XML-RPC new comment unit tests.

See #51344.

#16 @SergeyBiryukov
4 days ago

In 49327:

Tests: Rename some files and classes in phpunit/tests/post/ per the naming conventions.

https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780].

See #51344.

Note: See TracTickets for help on using tickets.