From 3cbb68c3af3c4cc0c486be400d5b7ca82b0e75d8 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 11 Nov 2013 17:51:29 +0000 Subject: [PATCH] Avoid `Out of range value for column 'post_parent'` error in `Tests_Ajax_MediaEdit::_make_attachment()` by setting the default parent id to `0` instead of `-1` git-svn-id: https://develop.svn.wordpress.org/trunk@26088 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/ajax/MediaEdit.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/tests/ajax/MediaEdit.php b/tests/phpunit/tests/ajax/MediaEdit.php index a17e724718..5115d9c3eb 100644 --- a/tests/phpunit/tests/ajax/MediaEdit.php +++ b/tests/phpunit/tests/ajax/MediaEdit.php @@ -19,7 +19,7 @@ class Tests_Ajax_MediaEdit extends WP_Ajax_UnitTestCase { * @var array */ protected $_ids = array(); - + /** * Set up the test fixture. */ @@ -39,14 +39,14 @@ class Tests_Ajax_MediaEdit extends WP_Ajax_UnitTestCase { $uploads = wp_upload_dir(); foreach ( scandir( $uploads['basedir'] ) as $file ) _rmdir( $uploads['basedir'] . '/' . $file ); - + parent::tearDown(); } - + /** * Function snagged from ./tests/post/attachments.php */ - function _make_attachment($upload, $parent_post_id = -1) { + function _make_attachment($upload, $parent_post_id = 0) { $type = ''; if ( !empty($upload['type']) ) { $type = $upload['type']; @@ -82,19 +82,19 @@ class Tests_Ajax_MediaEdit extends WP_Ajax_UnitTestCase { $upload = wp_upload_bits(basename($filename), null, $contents); $id = $this->_make_attachment($upload); - + $_REQUEST['action'] = 'image-editor'; $_REQUEST['context'] = 'edit-attachment'; $_REQUEST['postid'] = $id; $_REQUEST['target'] = 'thumbnail'; $_REQUEST['do'] = 'save'; $_REQUEST['history'] = '[{"c":{"x":5,"y":8,"w":289,"h":322}}]'; - + $media_meta = wp_get_attachment_metadata($id); $this->assertArrayHasKey('sizes', $media_meta, 'attachment should have size data'); $this->assertArrayHasKey('medium', $media_meta['sizes'], 'attachment should have data for medium size'); $ret = wp_save_image($id); - + $media_meta = wp_get_attachment_metadata($id); $this->assertArrayHasKey('sizes', $media_meta, 'cropped attachment should have size data'); $this->assertArrayHasKey('medium', $media_meta['sizes'], 'cropped attachment should have data for medium size');