[wp-trac] [WordPress Trac] #26823: wp_get_image_editor->multi_resize()
WordPress Trac
noreply at wordpress.org
Fri Feb 7 22:10:17 UTC 2014
#26823: wp_get_image_editor->multi_resize()
--------------------------+------------------
Reporter: pbearne | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.9
Component: Media | Version: 3.5
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
--------------------------+------------------
Comment (by pbearne):
Replying to [comment:33 wonderboymusic]:
> [attachment:26823.diff 26823.diff] rehabilitates the whitespace. The
files needs to be `unlink()`'d t the end of each test. Need opposing
assertions in the tests - meaning, you need to assert more things than
just one `assertEquals()` in each test.
I am still getting my head around unit tests (So I am not much above a
copy and past kid) and using this to learn.
Can point / provide an example?
and I will re-code
I see that I should be deleting the created images in each test but had
not worked out how.
{{{
/**
* Test resizing an multi resizong image, and then load the image
to check size
*
*/
public function test_multi_resize_check_is_resized() {
$file = DIR_TESTDATA . '/images/waffles.jpg';
$expected_output_file = DIR_TESTDATA . '/images/waffles-
50x33.jpg' ;
@unlink( $expected_output_file );
$gd_image_editor = new WP_Image_Editor_Imagick( $file );
$gd_image_editor->load();
$sizes_array = array(
array ('width' => 50, 'height' =>
50 )
);
$resized = $gd_image_editor->multi_resize( $sizes_array );
$this->assertTrue(file_exists( $expected_output_file ),
'File created');
$gd_image_output = new WP_Image_Editor_Imagick(
$expected_output_file );
$gd_image_output->load();
$this->assertEquals( array( 'width' => 50, 'height' => 33
), $gd_image_output->get_size() );
@unlink( $expected_output_file );
}
}}}
Should I be testing the file create each time or is the one time OK?
What else would nice to test here I am trying not to test the function
this calls?
Many Thanks
Paul
--
Ticket URL: <https://core.trac.wordpress.org/ticket/26823#comment:35>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list