WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#36016 closed task (blessed) (fixed)

Fix or remove useless PHPUnit tests

Reported by: boonebgorges Owned by:
Milestone: 4.5 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords:
Focuses: Cc:

Description

Running `phpunit --report-useless-tests tells us that a number of our tests are not asserting anything. Let's fix.

Change History (12)

#1 @boonebgorges
2 years ago

In 36778:

Make sure an assertion takes place in 'visited' test for get_category_parents().

See #36016.

#2 @boonebgorges
2 years ago

In 36779:

Put an assertion in test_nonexistent_array() test.

The point of the test is to demonstrate that PHP doesn't throw a notice when
calling unset() on an undefined array key. To placate PHPUnit's useless test
detection, we add a redundant assertion.

Introduced in [25240].

See #36016.

#3 @boonebgorges
2 years ago

In 36782:

Remove test related to deprecated Customizer export_preview_data() method.

The method was gutted and deprecated in [36586], so there's no reason to keep
the test.

See #36016.

#4 @boonebgorges
2 years ago

In 36784:

More specific test for a bad callback in WP_Customize_Partial test.

The 'render_callback' passed to WP_Customize_Partial must either echo or
return a result - not both. When it's detected that the callback echoes and
returns a value, the return value takes precedence. This is now reflected in
the corresponding unit test.

Introduced in [36586].

See #27355. See #36016.

#5 @boonebgorges
2 years ago

In 36785:

Tests: setExpectedDeprecated and setExpectedIncorrectUsage tests should make assertions.

Introduced in [31306].

See #36016.

#6 @boonebgorges
2 years ago

In 36786:

Tests: Make sure that test_wp_mail_break_it() makes an assertion.

Let's make what is possibly the oddest test in WordPress even a bit odder.

See https://core.trac.wordpress.org/ticket/28909#comment:47 for backstory on
the test.

See #36016.

#7 @boonebgorges
2 years ago

In 36787:

Remove tests related to wp_*_post_meta() functions.

These tests functions were introduced as part of the attempt to straighten out
metadata slashing. See [23416]. The functions were later pulled out [23554],
but the tests were not removed at the same time. Since that point, they've
done nothing, so they can safely be removed.

See #21767. See #36016.

#8 @boonebgorges
2 years ago

In 36788:

mbstring.func_overload test should be skipped properly.

This avoids PHPUnit notices related to "risky" tests.

See #36016.

#9 @boonebgorges
2 years ago

In 36789:

Remove erroneous return in date_query test.

Introduced in [34989].

See #36016.

#10 @boonebgorges
2 years ago

In 36790:

Ensure that user __unset() tests make assertions.

See #36016.

#11 @boonebgorges
2 years ago

In 36791:

Use markTestSkipped() to skip a multisite-only test.

See #36016.

#12 @boonebgorges
2 years ago

  • Milestone changed from Future Release to 4.5
  • Resolution set to fixed
  • Status changed from new to closed

Nothing more to see here. Carry on.

Note: See TracTickets for help on using tickets.