[Wp-unit-tests] [WordPress Unit Tests] #29: Update WPTestAttachments

WordPress Unit Tests noreply at wordpress.org
Mon Mar 26 22:19:37 UTC 2012


#29: Update WPTestAttachments
--------------------------+--------------------------------
 Reporter:  kurtpayne     |      Owner:
     Type:  defect        |     Status:  new
 Priority:  major         |  Milestone:  Fix existing Tests
Component:  Capabilities  |    Version:
 Keywords:  attachments   |
--------------------------+--------------------------------
 There are several problems with the WPTestUserCapabilities unit test.
 Let's update the test.

 In `test_insert_image_no_thumb`
 {{{
 // the thumb url should point to the thumbnail intermediate
 $this->assertEquals( $thumb['url'], wp_get_attachment_thumb_url($id) );
 }}}

 `$thumb` is never declared.  This assertion will always fail.

 Also in `test_insert_image_no_thumb`
 {{{
 // image_downsize() should return the correct images and sizes
 $this->assertFalse( image_downsize($id, 'thumbnail') );
 ...
 }}}

 The comment and the assertion are out of sync.  `image_downsize` should
 not return false unless the attachment id is not found, or the output is
 hijacked by the `image_downsize` filter, or `$img_url` var is empty
 because of another failure (which is not under test here).

 In several places:
 {{{
 $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
 $upload = wp_upload_bits($filename, 'image/jpeg', $contents);
 $this->assertEquals( 'a2-small-150x150.jpg', $thumb['file'] );
 }}}

 `wp_upload_bits` expects a file name, not a file path.  The assertion
 fails because `$thumb[file]` contains `wp-testdataimagesa2-small-
 150x150.jpg`.

 In several places:
 {{{
 $this->assertTrue( is_file($thumb['path']) );
 }}}

 The path here is relative to the !WordPress upload location.  `is_file()`
 should be passed the full file path.

 In `test_insert_image_medium`:
 {{{
 $downsize = image_downsize($id, 'full');
 $this->assertEquals( '2007-06-17dsc_4173.jpg', basename($downsize[0]) );
 $this->assertEquals( 500, $downsize[1] );
 $this->assertEquals( 752, $downsize[2] );
 }}}

 The file is 680 x 1024 and `image_downsize` will not constrain the size
 when asked for the full image.

 In `test_insert_image_delete`:
 {{{
 $filename = ( DIR_TESTDATA.'/images/2007-06-17DSC_4173.JPG' );
 ...
 $this->assertEquals( '2007-06-17dsc_4173-150x150.jpg', $thumb['file'] );
 }}}

 The case difference between "DSC" and "dsc" causes the assertion to fail.

-- 
Ticket URL: <http://unit-tests.trac.wordpress.org/ticket/29>
WordPress Unit Tests <http://unit-tests.trac.wordpress.org>
My example project


More information about the wp-unit-tests mailing list