@@ -13,7 +13,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase
1313 function test_resize_jpg () {
1414 $ image = $ this ->resize_helper ( DIR_TESTDATA .'/images/test-image.jpg ' , 25 , 25 );
1515
16- $ this ->assertEquals ( 'test-image-25x25.jpg ' , basename ($ image ) );
16+ $ this ->assertEquals ( 'test-image-25x25.jpg ' , basename ( $ image ) );
1717 list ($ w , $ h , $ type ) = getimagesize ($ image );
1818 $ this ->assertEquals ( 25 , $ w );
1919 $ this ->assertEquals ( 25 , $ h );
@@ -25,7 +25,12 @@ function test_resize_jpg() {
2525 function test_resize_png () {
2626 $ image = $ this ->resize_helper ( DIR_TESTDATA .'/images/test-image.png ' , 25 , 25 );
2727
28- $ this ->assertEquals ( 'test-image-25x25.png ' , basename ($ image ) );
28+ if ( ! is_string ( $ image ) ) { // WP_Error, stop GLib-GObject-CRITICAL assertion
29+ $ this ->markTestSkipped ( sprintf ( 'No PNG support in the editor engine %s on this system ' , $ this ->editor_engine ) );
30+ return ;
31+ }
32+
33+ $ this ->assertEquals ( 'test-image-25x25.png ' , basename ( $ image ) );
2934 list ($ w , $ h , $ type ) = getimagesize ($ image );
3035 $ this ->assertEquals ( 25 , $ w );
3136 $ this ->assertEquals ( 25 , $ h );
@@ -37,7 +42,12 @@ function test_resize_png() {
3742 function test_resize_gif () {
3843 $ image = $ this ->resize_helper ( DIR_TESTDATA .'/images/test-image.gif ' , 25 , 25 );
3944
40- $ this ->assertEquals ( 'test-image-25x25.gif ' , basename ($ image ) );
45+ if ( ! is_string ( $ image ) ) { // WP_Error, stop GLib-GObject-CRITICAL assertion
46+ $ this ->markTestSkipped ( sprintf ( 'No GIF support in the editor engine %s on this system ' , $ this ->editor_engine ) );
47+ return ;
48+ }
49+
50+ $ this ->assertEquals ( 'test-image-25x25.gif ' , basename ( $ image ) );
4151 list ($ w , $ h , $ type ) = getimagesize ($ image );
4252 $ this ->assertEquals ( 25 , $ w );
4353 $ this ->assertEquals ( 25 , $ h );
@@ -57,9 +67,9 @@ function test_resize_larger() {
5767 function test_resize_thumb_128x96 () {
5868 $ image = $ this ->resize_helper ( DIR_TESTDATA .'/images/2007-06-17DSC_4173.JPG ' , 128 , 96 );
5969
60- $ this ->assertEquals ( '2007-06-17DSC_4173-63x96 .jpg ' , basename ($ image ) );
70+ $ this ->assertEquals ( '2007-06-17DSC_4173-64x96 .jpg ' , basename ( $ image ) );
6171 list ($ w , $ h , $ type ) = getimagesize ($ image );
62- $ this ->assertEquals ( 63 , $ w );
72+ $ this ->assertEquals ( 64 , $ w );
6373 $ this ->assertEquals ( 96 , $ h );
6474 $ this ->assertEquals ( IMAGETYPE_JPEG , $ type );
6575
@@ -69,10 +79,10 @@ function test_resize_thumb_128x96() {
6979 function test_resize_thumb_128x0 () {
7080 $ image = $ this ->resize_helper ( DIR_TESTDATA .'/images/2007-06-17DSC_4173.JPG ' , 128 , 0 );
7181
72- $ this ->assertEquals ( '2007-06-17DSC_4173-128x192 .jpg ' , basename ($ image ) );
82+ $ this ->assertEquals ( '2007-06-17DSC_4173-128x193 .jpg ' , basename ( $ image ) );
7383 list ($ w , $ h , $ type ) = getimagesize ($ image );
7484 $ this ->assertEquals ( 128 , $ w );
75- $ this ->assertEquals ( 192 , $ h );
85+ $ this ->assertEquals ( 193 , $ h );
7686 $ this ->assertEquals ( IMAGETYPE_JPEG , $ type );
7787
7888 unlink ( $ image );
@@ -81,9 +91,9 @@ function test_resize_thumb_128x0() {
8191 function test_resize_thumb_0x96 () {
8292 $ image = $ this ->resize_helper ( DIR_TESTDATA .'/images/2007-06-17DSC_4173.JPG ' , 0 , 96 );
8393
84- $ this ->assertEquals ( '2007-06-17DSC_4173-63x96 .jpg ' , basename ($ image ) );
94+ $ this ->assertEquals ( '2007-06-17DSC_4173-64x96 .jpg ' , basename ( $ image ) );
8595 list ($ w , $ h , $ type ) = getimagesize ($ image );
86- $ this ->assertEquals ( 63 , $ w );
96+ $ this ->assertEquals ( 64 , $ w );
8797 $ this ->assertEquals ( 96 , $ h );
8898 $ this ->assertEquals ( IMAGETYPE_JPEG , $ type );
8999
@@ -93,7 +103,7 @@ function test_resize_thumb_0x96() {
93103 function test_resize_thumb_150x150_crop () {
94104 $ image = $ this ->resize_helper ( DIR_TESTDATA .'/images/2007-06-17DSC_4173.JPG ' , 150 , 150 , true );
95105
96- $ this ->assertEquals ( '2007-06-17DSC_4173-150x150.jpg ' , basename ($ image ) );
106+ $ this ->assertEquals ( '2007-06-17DSC_4173-150x150.jpg ' , basename ( $ image ) );
97107 list ($ w , $ h , $ type ) = getimagesize ($ image );
98108 $ this ->assertEquals ( 150 , $ w );
99109 $ this ->assertEquals ( 150 , $ h );
@@ -105,7 +115,7 @@ function test_resize_thumb_150x150_crop() {
105115 function test_resize_thumb_150x100_crop () {
106116 $ image = $ this ->resize_helper ( DIR_TESTDATA .'/images/2007-06-17DSC_4173.JPG ' , 150 , 100 , true );
107117
108- $ this ->assertEquals ( '2007-06-17DSC_4173-150x100.jpg ' , basename ($ image ) );
118+ $ this ->assertEquals ( '2007-06-17DSC_4173-150x100.jpg ' , basename ( $ image ) );
109119 list ($ w , $ h , $ type ) = getimagesize ($ image );
110120 $ this ->assertEquals ( 150 , $ w );
111121 $ this ->assertEquals ( 100 , $ h );
@@ -117,7 +127,7 @@ function test_resize_thumb_150x100_crop() {
117127 function test_resize_thumb_50x150_crop () {
118128 $ image = $ this ->resize_helper ( DIR_TESTDATA .'/images/2007-06-17DSC_4173.JPG ' , 50 , 150 , true );
119129
120- $ this ->assertEquals ( '2007-06-17DSC_4173-50x150.jpg ' , basename ($ image ) );
130+ $ this ->assertEquals ( '2007-06-17DSC_4173-50x150.jpg ' , basename ( $ image ) );
121131 list ($ w , $ h , $ type ) = getimagesize ($ image );
122132 $ this ->assertEquals ( 50 , $ w );
123133 $ this ->assertEquals ( 150 , $ h );
@@ -142,6 +152,12 @@ public function test_resize_non_existent_image() {
142152 * @ticket 6821
143153 */
144154 public function test_resize_bad_image () {
155+
156+ if ( $ this ->editor_engine == 'WP_Image_Editor_Imagick ' ) {
157+ $ this ->markTestSkipped ( sprintf ( 'Avoid GLib-GObject-CRITICAL assertion in %s ' , $ this ->editor_engine ) );
158+ return ;
159+ }
160+
145161 $ image = $ this ->resize_helper ( DIR_TESTDATA .'/export/crazy-cdata.xml ' , 25 , 25 );
146162 $ this ->assertInstanceOf ( 'WP_Error ' , $ image );
147163 $ this ->assertEquals ( 'invalid_image ' , $ image ->get_error_code () );
0 commit comments