Opened 9 years ago
Closed 9 years ago
#42124 closed defect (bug) (fixed)
Unit test errors with PHPUnit 6.4.0
| Reported by: | joemcgill | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | high | Milestone: | 4.9 |
| Component: | Build/Test Tools | Version: | |
| Severity: | normal | Keywords: | has-patch 2nd-opinion |
| Cc: | Focuses: |
Description
Change in PHPUnit 6.4.0, resulted in our tests to start failing. Specifically,
1) Tests_Image_Functions::test_load_directory TypeError: get_resource_type() expects parameter 1 to be resource, string given /home/travis/build/WordPress/wordpress-develop/tests/phpunit/tests/image/functions.php:269
This test uses assertNotInternalType() to ensure wp_load_image() and wp_get_image_editor() wouldn't load a link to a resource (see #17814). Under the hood, PHPUnit uses get_resource_type() in this assertion, which will produce an error that was previously not surfaced.
Attachments (1)
Change History (7)
#2
@
9 years ago
This patch seems right.
assertNotInternalType() claims to accept a PHP Resource variable type, so the resource string would not be sufficient; it would need to be an actual resource type variable. If this was working before PHPUnit 6.4.0, it probably should not have been.
WordPress uses Resource variables in quite a few places (where server & database connections are used) but also generally shields us from needing to do very much with them until we hit API bedrock. @joemcgill you're probably familiar with them with your recent trip down MimeType boulevard.
#4
@
9 years ago
For future reference, I've reported this issue upstream to PHPUnit here:
https://github.com/sebastianbergmann/phpunit/issues/2792
#5
@
9 years ago
- Resolution fixed
- Status closed → reopened
This will be fixed in PHPUnit 6.4.1. (see commit). We may want to consider reverting [41784] as the previous approach was more accurate. Alternately, we could use assertNotSame( 'resource', gettype( $editor ) ) in both assertions.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
42124.diff Updates the failing test so we check for the expected variable type, rather than testing that we're not returning a resource type.