Skip to content

Instantly share code, notes, and snippets.

@kurtpayne
Created September 12, 2012 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurtpayne/3710660 to your computer and use it in GitHub Desktop.
Save kurtpayne/3710660 to your computer and use it in GitHub Desktop.
6821 image_resize unit test
Index: tests/image/resize.php
===================================================================
--- tests/image/resize.php (revision 1017)
+++ tests/image/resize.php (working copy)
@@ -123,4 +123,23 @@
unlink($image);
}
+ /**
+ * Try resizing a non-existent image
+ * @ticket 6821
+ */
+ public function test_resize_non_existent_image() {
+ $image = image_resize( DIR_TESTDATA.'/images/test-non-existent-image.jpg', 25, 25 );
+ $this->assertInstanceOf( 'WP_Error', $image );
+ $this->assertEquals( 'error_loading_image', $image->get_error_code() );
+ }
+
+ /**
+ * Try resizing a php file (bad image)
+ * @ticket 6821
+ */
+ public function test_resize_bad_image() {
+ $image = image_resize( DIR_TESTDATA.'/images/test-image.psd', 25, 25 );
+ $this->assertInstanceOf( 'WP_Error', $image );
+ $this->assertEquals( 'invalid_image', $image->get_error_code() );
+ }
}
@getsource
Copy link

Test on line 24 is invalid for Imagick because Imagick supports reading from PSD.
Note from Marko: "Are you surprised? I am."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment