WordPress.org

Make WordPress Core

Opened 8 months ago

Closed 2 days ago

#42277 closed enhancement (fixed)

Remove useless tests from `Tests_Basic`

Reported by: Frank Klein Owned by: johnbillion
Milestone: 5.0 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-unit-tests
Focuses: Cc:

Description

The Tests_Basic class contains several tests, which do not seem to be testing anything useful:

  • test_globals() and test_globals_bar(): The bug in question has been fixed for a long time, plus issues with PHPUnit should be handled upstream.
  • test_setting_nonexistent_arrays(), test_magic_getter(), test_subclass_magic_getter(), test_call_method(), test_subclass_magic_getter(), test_call_method(), test_subclass_call_method(), test_subclass_isset(), and test_subclass_unset() all needlessly test basic PHP features.
  • _switch_order_helper() is unused, except in it's test_switch_order() test, and since Tests_Basic is a test class, it can be removed.

Some of these tests have been added for HHVM support, but are no longer needed after this support was removed as part of #40548.

Attachments (1)

42277.diff (3.8 KB) - added by Frank Klein 7 months ago.

Download all attachments as: .zip

Change History (9)

#1 @johnbillion
8 months ago

  • Keywords needs-unit-tests added
  • Version trunk deleted

@Frank Klein
7 months ago

#2 @johnbillion
6 months ago

  • Keywords has-unit-tests added; needs-unit-tests removed
  • Milestone changed from Awaiting Review to 5.0
  • Owner set to johnbillion
  • Status changed from new to reviewing

#3 @johnbillion
6 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 42381:

Build/Test tools: Remove unnecessary PHP functionality tests from the test suite.

Props Frank Klein
Fixes #42277

#4 @TimothyBlynJacobs
4 weeks ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Why were the basic object classes removed? See #37523

#5 @Frank Klein
4 days ago

@TimothyBlynJacobs They were removed because they do not actually test anything, besides normal PHP behaviour.

Is there a use case for the WordPress Core tests that was missed?

#6 @TimothyBlynJacobs
4 days ago

Because they are helpful objects when writing tests with the WP test lib. I don't see any issue with removing the unnecessary PHP functionality tests, but I don't see why the basic object classes themselves were removed.

#7 @Frank Klein
4 days ago

They were removed because Core does not need them anymore. In my view there's enough outstanding work on tests that we should not continue to invest resources into code that is no longer needed.

Consider including these classes in your own testing setup if you find them useful.

#8 @johnbillion
2 days ago

  • Resolution set to fixed
  • Status changed from reopened to closed

Yeah this is a real edge case and we have more pressing issues to deal with. I'd recommend implementing these classes in your own test suite.

Note: See TracTickets for help on using tickets.