From 3eaf233f94a0c6df5b409ded7ed1b9651f1556e2 Mon Sep 17 00:00:00 2001 From: Rene Reimann Date: Fri, 22 Jan 2016 12:33:24 +0100 Subject: [PATCH] #41 attachment_unittest - fix test image --- inc/Import/Service/WpPostImporter.php | 1 - .../Import/Service/WpAttachementImporterTest.php | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/inc/Import/Service/WpPostImporter.php b/inc/Import/Service/WpPostImporter.php index 91693fc..e889045 100644 --- a/inc/Import/Service/WpPostImporter.php +++ b/inc/Import/Service/WpPostImporter.php @@ -326,7 +326,6 @@ public function import_attachment( $attachment_id, Type\ImportPostInterface $imp ); - // Generate the metadata for the attachment, and update the database record. $attachment_metadata = wp_generate_attachment_metadata( $attachment_id, $upload['file'] ); wp_update_attachment_metadata( $attachment_id, $attachment_metadata ); diff --git a/tests/phpunit/Unit/Import/Service/WpAttachementImporterTest.php b/tests/phpunit/Unit/Import/Service/WpAttachementImporterTest.php index 25384a5..e118b03 100644 --- a/tests/phpunit/Unit/Import/Service/WpAttachementImporterTest.php +++ b/tests/phpunit/Unit/Import/Service/WpAttachementImporterTest.php @@ -140,12 +140,13 @@ public function test_import_post() { } - Brain\Monkey\Functions::expect( 'wp_insert_post' ) + Brain\Monkey\Functions::expect( 'wp_insert_attachment' ) ->atLeast() ->once() ->with( $post, - TRUE + $postdata[ 'origin_attachment_url' ], + $new_parent_id ) ->andReturn( $post_id ); @@ -238,6 +239,8 @@ public function test_import_post() { ->willReturn( $request_testdata ); + Brain\Monkey\Functions::expect( 'wp_update_post' )->times( 1 ); + Brain\Monkey\Functions::expect( 'wp_generate_attachment_metadata' ) ->atLeast() ->once() @@ -247,8 +250,9 @@ public function test_import_post() { ) ); - Brain\Monkey\Functions::expect( 'wp_update_attachment_metadata' )->times( 1 ); - + Brain\Monkey\Functions::expect( 'wp_update_attachment_metadata' ) + ->atLeast() + ->once(); $testee->import_post( $post_mock );