Inheritance: extends WP_Image_Editor
 /**
  * Test wp_get_image_editor() where load returns false
  * @ticket 6821
  */
 public function test_get_editor_load_returns_false()
 {
     WP_Image_Editor_Mock::$load_return = new WP_Error();
     $editor = wp_get_image_editor(DIR_TESTDATA . '/images/canola.jpg');
     $this->assertInstanceOf('WP_Error', $editor);
     WP_Image_Editor_Mock::$load_return = true;
 }
 /**
  * @ticket 23325
  */
 public function test_wp_crop_image_error_on_saving()
 {
     WP_Image_Editor_Mock::$save_return = new WP_Error();
     add_filter('wp_image_editors', array($this, 'mock_image_editor'));
     $file = wp_crop_image(DIR_TESTDATA . '/images/canola.jpg', 0, 0, 100, 100, 100, 100);
     $this->assertInstanceOf('WP_Error', $file);
     remove_filter('wp_image_editors', array($this, 'mock_image_editor'));
     WP_Image_Editor_Mock::$save_return = array();
 }
Example #3
0
 /**
  * Test the "test" method returns false and the fallback editor is chosen
  * @ticket 6821
  */
 public function test_test_returns_false()
 {
     // $editor::test() returns true
     $this->editor->staticExpects($this->once())->method('test')->will($this->returnValue(false));
     // Set a fallback editor
     $className = preg_replace('/^WP_Image_Editor_/', '', get_class($this->editor));
     $func = create_function('', "return array('{$className}', 'Mock');");
     remove_filter('wp_editors', array($this, 'wp_editors'));
     remove_filter('image_editor_class', array($this, 'image_editor_class'));
     add_filter('wp_editors', $func);
     // Load an image
     WP_Image_Editor_Mock::$load_return = true;
     $editor = WP_Image_Editor::get_instance(DIR_TESTDATA . '/images/canola.jpg');
     // Everything should work
     $this->assertInstanceOf('WP_Image_Editor_Mock', $editor);
     // Unhook
     remove_filter('image_editor_class', '__return_null');
     remove_filter('wp_editors', $func);
 }