| | 245 | |
| | 246 | public function test_wp_crop_image_file() { |
| | 247 | $file = wp_crop_image( DIR_TESTDATA . '/images/canola.jpg', |
| | 248 | 0, 0, 100, 100, 100, 100 ); |
| | 249 | $this->assertNotInstanceOf( 'WP_Error', $file ); |
| | 250 | $this->assertFileExists( $file ); |
| | 251 | $image = WP_Image_Editor::get_instance( $file ); |
| | 252 | $size = $image->get_size(); |
| | 253 | $this->assertEquals( 100, $size['height'] ); |
| | 254 | $this->assertEquals( 100, $size['width'] ); |
| | 255 | } |
| | 256 | |
| | 257 | public function test_wp_crop_image_url() { |
| | 258 | $file = wp_crop_image( 'http://asdftestblog1.files.wordpress.com/2008/04/canola.jpg', |
| | 259 | 0, 0, 100, 100, 100, 100, false, |
| | 260 | DIR_TESTDATA . '/images/' . rand_str() . '.jpg' ); |
| | 261 | $this->assertNotInstanceOf( 'WP_Error', $file ); |
| | 262 | $this->assertFileExists( $file ); |
| | 263 | $image = WP_Image_Editor::get_instance( $file ); |
| | 264 | $size = $image->get_size(); |
| | 265 | $this->assertEquals( 100, $size['height'] ); |
| | 266 | $this->assertEquals( 100, $size['width'] ); |
| | 267 | } |
| | 268 | |
| | 269 | public function test_wp_crop_image_file_not_exist() { |
| | 270 | $file = wp_crop_image( DIR_TESTDATA . '/images/canoladoesnotexist.jpg', |
| | 271 | 0, 0, 100, 100, 100, 100 ); |
| | 272 | $this->assertInstanceOf( 'WP_Error', $file ); |
| | 273 | } |
| | 274 | |
| | 275 | public function test_wp_crop_image_url_not_exist() { |
| | 276 | $file = wp_crop_image( 'http://asdftestblog1.files.wordpress.com/2008/04/canoladoesnotexist.jpg', |
| | 277 | 0, 0, 100, 100, 100, 100 ); |
| | 278 | $this->assertInstanceOf( 'WP_Error', $file ); |
| | 279 | } |