WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#32984 closed defect (bug) (fixed)

Several PHPUnit tests cannot be run individually

Reported by: isaacchapman Owned by: boonebgorges
Milestone: 4.3 Priority: normal
Severity: normal Version: 4.3
Component: Build/Test Tools Keywords: has-patch
Focuses: Cc:

Description

Several PHPUnit tests cannot be run individually as they reference classes from other files that may not be loaded. For example:

$phpunit tests/phpunit/tests/filesystem/find_folder.php
PHP Fatal error:  Class 'WP_Filesystem_UnitTestCase' not found in tests/phpunit/tests/filesystem/find_folder.php on line 7

Attachments (2)

make-wp-tests-independent.diff (2.2 KB) - added by isaacchapman 6 years ago.
require_once commands to allow independent test execution
make-wp-tests-independent-svn.diff (2.3 KB) - added by isaacchapman 6 years ago.
svn diff of updated changeset

Download all attachments as: .zip

Change History (7)

@isaacchapman
6 years ago

require_once commands to allow independent test execution

#1 @boonebgorges
6 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

Good catch. We should still support PHP 5.2.x in our tests, so let's use dirname( __FILE__ ) instead of __DIR__. Also, no need for DIRECTORY_SEPARATOR in this context.

@isaacchapman
6 years ago

svn diff of updated changeset

#2 follow-up: @isaacchapman
6 years ago

I've attached make-wp-tests-independent-svn.diff to satisfy the PHP 5.2 concern. This is a SVN diff as opposed to the prior GIT diff, if that is of any importance.

#3 in reply to: ↑ 2 @netweb
6 years ago

  • Keywords has-patch added; needs-patch removed

Replying to isaacchapman:

I've attached make-wp-tests-independent-svn.diff to satisfy the PHP 5.2 concern. This is a SVN diff as opposed to the prior GIT diff, if that is of any importance.

Thanks for the patch, if you take a closer look at the Git patch it has a/ and b/ prefixes for the file paths, that's the only difference, as such if you generate patches using git diff --no-prefix those a/b prefixes will not be there and for all intensive purposes it is then the equivalent of the SVN patch and we're happy to accept patches in SVN or Git.

#4 @boonebgorges
6 years ago

  • Milestone changed from Future Release to 4.3

#5 @boonebgorges
6 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 33250:

Require dependencies when appropriate in some unit test files.

Previously, attempting to run certain test files in isolation would resultin
fatal errors, as the parent classes had not been loaded.

Props isaacchapman.
Fixes #32984.

Note: See TracTickets for help on using tickets.