[wp-trac] [WordPress Trac] #42736: Adjust two media test methods
WordPress Trac
noreply at wordpress.org
Tue Nov 28 17:44:42 UTC 2017
#42736: Adjust two media test methods
------------------------------+-----------------------------
Reporter: birgire | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Build/Test Tools | Version: 4.9
Severity: normal | Keywords:
Focuses: |
------------------------------+-----------------------------
When I ran
{{{
phpunit --group media
}}}
on the latest wordpress-develop install with:
{{{
define( 'WP_TESTS_DOMAIN', 'test.dev' );
}}}
I noticed two things related to the changeset in [41964]:
The first one is that the assertion in
{{{test_media_handle_upload_uses_post_parent_for_directory_date()}}}
assumes the {{{example.org}}} test domain:
{{{
There was 1 failure:
1)
Tests_Media::test_media_handle_upload_uses_post_parent_for_directory_date
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'http://example.org/wp-content/uploads/2010/01/test-image-iptc.jpg'
+'http://test.dev/wp-content/uploads/2010/01/test-image-iptc.jpg'
/full/path/to/tests/phpunit/tests/media.php:2285
}}}
The second thing is in
{{{Tests_Media::test_media_handle_upload_ignores_page_parent_for_directory_date()}}}
where we have:
{{{
$uploads_dir = wp_upload_dir( current_time( 'mysql' ) );
$expected = $uploads_dir['url'] . 'test-image-iptc.jpg';
}}}
This generates {{{$expected}}} as:
http://test.dev/wp-content/uploads/2017/11test-image-iptc.jpg
but the actual {{{$url}}} generated within the method is:
http://test.dev/wp-content/uploads/2017/11/test-image-iptc.jpg
So it satisfies:
{{{
$this->assertNotEquals( $expected, $url );
}}}
but it looks like a {{{/}}} is missing from {{{$expected}}} and we should
add it and then assert if:
{{{
$this->assertSame( $expected, $url );
}}}
making sure it's placed in the current month's upload directory, not the
{{{2010/01}}} upload directory, because without the patched {{{page}}}
post type exclusion, the actual {{{$url}}} would become:
http://test.dev/wp-content/uploads/2010/01/test-image-iptc.jpg
I hope I'm understanding it correctly ;-)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42736>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list