mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Tests: Use assertSame() in wp_read_image_metadata() tests.
This ensures that not only the return values match the expected results, but also that their type is the same. Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable. Follow-up to [49/tests], [198/tests], [34374], [48937], [52269]. Props costdev. See #59655. git-svn-id: https://develop.svn.wordpress.org/trunk@57673 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c58cb01aaa
commit
bd78247617
@ -32,15 +32,15 @@ class Tests_Image_Meta extends WP_UnitTestCase {
|
||||
// Exif from a Nikon D70.
|
||||
$out = wp_read_image_metadata( DIR_TESTDATA . '/images/2004-07-22-DSC_0008.jpg' );
|
||||
|
||||
$this->assertEquals( 6.3, $out['aperture'], 'Aperture value not equivalent' );
|
||||
$this->assertSame( '6.3', $out['aperture'], 'Aperture value not equivalent' );
|
||||
$this->assertSame( '', $out['credit'], 'Credit value not the same' );
|
||||
$this->assertSame( 'NIKON D70', $out['camera'], 'Camera value not the same' );
|
||||
$this->assertSame( '', $out['caption'], 'Caption value not the same' );
|
||||
$this->assertEquals( strtotime( '2004-07-22 17:14:59' ), $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( (string) strtotime( '2004-07-22 17:14:59' ), $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( '', $out['copyright'], 'Copyright value not the same' );
|
||||
$this->assertEquals( 27, $out['focal_length'], 'Focal length value not equivalent' );
|
||||
$this->assertEquals( 400, $out['iso'], 'Iso value not equivalent' );
|
||||
$this->assertEquals( 1 / 40, $out['shutter_speed'], 'Shutter speed value not equivalent' );
|
||||
$this->assertSame( '27', $out['focal_length'], 'Focal length value not equivalent' );
|
||||
$this->assertSame( '400', $out['iso'], 'Iso value not equivalent' );
|
||||
$this->assertSame( (string) ( 1 / 40 ), $out['shutter_speed'], 'Shutter speed value not equivalent' );
|
||||
$this->assertSame( '', $out['title'], 'Title value not the same' );
|
||||
}
|
||||
|
||||
@ -52,11 +52,11 @@ class Tests_Image_Meta extends WP_UnitTestCase {
|
||||
$this->assertSame( '', $out['credit'], 'Credit value not the same' );
|
||||
$this->assertSame( 'NIKON D70', $out['camera'], 'Camera value not the same' );
|
||||
$this->assertSame( 'Copyright Alex Shiels', $out['caption'], 'Caption value not the same' );
|
||||
$this->assertEquals( strtotime( '2007-06-17 21:18:00' ), $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( (string) strtotime( '2007-06-17 21:18:00' ), $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( '', $out['copyright'], 'Copyright value not the same' );
|
||||
$this->assertEquals( 0, $out['focal_length'], 'Focal length value not equivalent' );
|
||||
$this->assertEquals( 0, $out['iso'], 'Iso value not equivalent' ); // Interesting - a Nikon bug?
|
||||
$this->assertEquals( 1 / 500, $out['shutter_speed'], 'Shutter speed value not equivalent' );
|
||||
$this->assertSame( '0', $out['focal_length'], 'Focal length value not equivalent' );
|
||||
$this->assertSame( '0', $out['iso'], 'Iso value not equivalent' ); // Interesting - a Nikon bug?
|
||||
$this->assertSame( (string) ( 1 / 500 ), $out['shutter_speed'], 'Shutter speed value not equivalent' );
|
||||
$this->assertSame( 'Copyright Alex Shiels', $out['title'], 'Title value not the same' );
|
||||
// $this->assertSame( array( 'Flowers' ), $out['keywords'] );
|
||||
}
|
||||
@ -65,15 +65,15 @@ class Tests_Image_Meta extends WP_UnitTestCase {
|
||||
// Exif from a Nikon D70 with IPTC data added later.
|
||||
$out = wp_read_image_metadata( DIR_TESTDATA . '/images/2004-07-22-DSC_0007.jpg' );
|
||||
|
||||
$this->assertEquals( 6.3, $out['aperture'], 'Aperture value not equivalent' );
|
||||
$this->assertSame( '6.3', $out['aperture'], 'Aperture value not equivalent' );
|
||||
$this->assertSame( 'IPTC Creator', $out['credit'], 'Credit value not the same' );
|
||||
$this->assertSame( 'NIKON D70', $out['camera'], 'Camera value not the same' );
|
||||
$this->assertSame( 'IPTC Caption', $out['caption'], 'Caption value not the same' );
|
||||
$this->assertEquals( strtotime( '2004-07-22 17:14:35' ), $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( (string) strtotime( '2004-07-22 17:14:35' ), $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( 'IPTC Copyright', $out['copyright'], 'Copyright value not the same' );
|
||||
$this->assertEquals( 18, $out['focal_length'], 'Focal length value not equivalent' );
|
||||
$this->assertEquals( 200, $out['iso'], 'Iso value not equivalent' );
|
||||
$this->assertEquals( 1 / 25, $out['shutter_speed'], 'Shutter speed value not equivalent' );
|
||||
$this->assertSame( '18', $out['focal_length'], 'Focal length value not equivalent' );
|
||||
$this->assertSame( '200', $out['iso'], 'Iso value not equivalent' );
|
||||
$this->assertSame( (string) ( 1 / 25 ), $out['shutter_speed'], 'Shutter speed value not equivalent' );
|
||||
$this->assertSame( 'IPTC Headline', $out['title'], 'Title value not the same' );
|
||||
}
|
||||
|
||||
@ -81,15 +81,15 @@ class Tests_Image_Meta extends WP_UnitTestCase {
|
||||
// Exif from a Fuji FinePix S5600 (thanks Mark).
|
||||
$out = wp_read_image_metadata( DIR_TESTDATA . '/images/a2-small.jpg' );
|
||||
|
||||
$this->assertEquals( 4.5, $out['aperture'], 'Aperture value not equivalent' );
|
||||
$this->assertSame( '4.5', $out['aperture'], 'Aperture value not equivalent' );
|
||||
$this->assertSame( '', $out['credit'], 'Credit value not the same' );
|
||||
$this->assertSame( 'FinePix S5600', $out['camera'], 'Camera value not the same' );
|
||||
$this->assertSame( '', $out['caption'], 'Caption value not the same' );
|
||||
$this->assertEquals( strtotime( '2007-09-03 10:17:03' ), $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( (string) strtotime( '2007-09-03 10:17:03' ), $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( '', $out['copyright'], 'Copyright value not the same' );
|
||||
$this->assertEquals( 6.3, $out['focal_length'], 'Focal length value not equivalent' );
|
||||
$this->assertEquals( 64, $out['iso'], 'Iso value not equivalent' );
|
||||
$this->assertEquals( 1 / 320, $out['shutter_speed'], 'Shutter speed value not equivalent' );
|
||||
$this->assertSame( '6.3', $out['focal_length'], 'Focal length value not equivalent' );
|
||||
$this->assertSame( '64', $out['iso'], 'Iso value not equivalent' );
|
||||
$this->assertSame( (string) ( 1 / 320 ), $out['shutter_speed'], 'Shutter speed value not equivalent' );
|
||||
$this->assertSame( '', $out['title'], 'Title value not the same' );
|
||||
}
|
||||
|
||||
@ -101,15 +101,15 @@ class Tests_Image_Meta extends WP_UnitTestCase {
|
||||
// This triggers a warning mesage when reading the Exif block.
|
||||
$out = wp_read_image_metadata( DIR_TESTDATA . '/images/waffles.jpg' );
|
||||
|
||||
$this->assertEquals( 0, $out['aperture'], 'Aperture value not equivalent' );
|
||||
$this->assertSame( '0', $out['aperture'], 'Aperture value not equivalent' );
|
||||
$this->assertSame( '', $out['credit'], 'Credit value not the same' );
|
||||
$this->assertSame( '', $out['camera'], 'Camera value not the same' );
|
||||
$this->assertSame( '', $out['caption'], 'Caption value not the same' );
|
||||
$this->assertEquals( 0, $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( '0', $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( '', $out['copyright'], 'Copyright value not the same' );
|
||||
$this->assertEquals( 0, $out['focal_length'], 'Focal length value not equivalent' );
|
||||
$this->assertEquals( 0, $out['iso'], 'Iso value not equivalent' );
|
||||
$this->assertEquals( 0, $out['shutter_speed'], 'Shutter speed value not equivalent' );
|
||||
$this->assertSame( '0', $out['focal_length'], 'Focal length value not equivalent' );
|
||||
$this->assertSame( '0', $out['iso'], 'Iso value not equivalent' );
|
||||
$this->assertSame( '0', $out['shutter_speed'], 'Shutter speed value not equivalent' );
|
||||
$this->assertSame( '', $out['title'], 'Title value not the same' );
|
||||
}
|
||||
|
||||
@ -117,15 +117,15 @@ class Tests_Image_Meta extends WP_UnitTestCase {
|
||||
// No Exif data in this image (from burningwell.org).
|
||||
$out = wp_read_image_metadata( DIR_TESTDATA . '/images/canola.jpg' );
|
||||
|
||||
$this->assertEquals( 0, $out['aperture'], 'Aperture value not equivalent' );
|
||||
$this->assertSame( '0', $out['aperture'], 'Aperture value not equivalent' );
|
||||
$this->assertSame( '', $out['credit'], 'Credit value not the same' );
|
||||
$this->assertSame( '', $out['camera'], 'Camera value not the same' );
|
||||
$this->assertSame( '', $out['caption'], 'Caption value not the same' );
|
||||
$this->assertEquals( 0, $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( '0', $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( '', $out['copyright'], 'Copyright value not the same' );
|
||||
$this->assertEquals( 0, $out['focal_length'], 'Focal length value not equivalent' );
|
||||
$this->assertEquals( 0, $out['iso'], 'Iso value not equivalent' );
|
||||
$this->assertEquals( 0, $out['shutter_speed'], 'Shutter speed value not equivalent' );
|
||||
$this->assertSame( '0', $out['focal_length'], 'Focal length value not equivalent' );
|
||||
$this->assertSame( '0', $out['iso'], 'Iso value not equivalent' );
|
||||
$this->assertSame( '0', $out['shutter_speed'], 'Shutter speed value not equivalent' );
|
||||
$this->assertSame( '', $out['title'], 'Title value not the same' );
|
||||
}
|
||||
|
||||
@ -158,13 +158,13 @@ class Tests_Image_Meta extends WP_UnitTestCase {
|
||||
$this->assertSame( 'Photoshop Author', $out['credit'], 'Credit value not the same' );
|
||||
$this->assertSame( 'DMC-LX2', $out['camera'], 'Camera value not the same' );
|
||||
$this->assertSame( 'Photoshop Description', $out['caption'], 'Caption value not the same' );
|
||||
$this->assertEquals( 1306315327, $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( '1306315327', $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( 'Photoshop Copyrright Notice', $out['copyright'], 'Copyright value not the same' );
|
||||
$this->assertSame( '6.3', $out['focal_length'], 'Focal length value not the same' );
|
||||
$this->assertSame( '100', $out['iso'], 'Iso value not the same' );
|
||||
$this->assertSame( '0.0025', $out['shutter_speed'], 'Shutter speed value not the same' );
|
||||
$this->assertSame( 'Photoshop Document Ttitle', $out['title'], 'Title value not the same' );
|
||||
$this->assertEquals( 1, $out['orientation'], 'Orientation value not equivalent' );
|
||||
$this->assertSame( '1', $out['orientation'], 'Orientation value not equivalent' );
|
||||
$this->assertSame( array( 'beach', 'baywatch', 'LA', 'sunset' ), $out['keywords'], 'Keywords not the same' );
|
||||
}
|
||||
|
||||
@ -246,15 +246,15 @@ class Tests_Image_Meta extends WP_UnitTestCase {
|
||||
// Unexpected Exif data: FNumber is "0/0", aperture should be 0.
|
||||
$out = wp_read_image_metadata( DIR_TESTDATA . '/images/sugarloaf-mountain.jpg' );
|
||||
|
||||
$this->assertEquals( 0, $out['aperture'], 'Aperture value not equivalent' );
|
||||
$this->assertSame( '0', $out['aperture'], 'Aperture value not equivalent' );
|
||||
$this->assertSame( '', $out['credit'], 'Credit value not the same' );
|
||||
$this->assertSame( 'X-T1', $out['camera'], 'Camera value not the same' );
|
||||
$this->assertSame( '', $out['caption'], 'Caption value not the same' );
|
||||
$this->assertEquals( 0, $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( '0', $out['created_timestamp'], 'Timestamp value not equivalent' );
|
||||
$this->assertSame( '', $out['copyright'], 'Copyright value not the same' );
|
||||
$this->assertEquals( 50, $out['focal_length'], 'Focal length value not equivalent' );
|
||||
$this->assertEquals( 200, $out['iso'], 'Iso value not equivalent' );
|
||||
$this->assertEquals( 2, $out['shutter_speed'], 'Shutter speed value not equivalent' );
|
||||
$this->assertSame( '50', $out['focal_length'], 'Focal length value not equivalent' );
|
||||
$this->assertSame( '200', $out['iso'], 'Iso value not equivalent' );
|
||||
$this->assertSame( '2', $out['shutter_speed'], 'Shutter speed value not equivalent' );
|
||||
$this->assertSame( 'Sugarloaf Panorama', $out['title'], 'Title value not the same' );
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user