From 810105a5e56b251d9fa59524530d362b704df0a8 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Fri, 19 Jul 2019 11:09:55 -0300 Subject: [PATCH] Use WP_UnitTestCase::assertWPError() instead of WC_Unit_Test_Case::assertIsWPError() See https://github.com/woocommerce/woocommerce/pull/24207 --- unit-tests/Tests/Version2/settings.php | 8 ++++---- unit-tests/Tests/Version3/functions.php | 6 +++--- unit-tests/Tests/Version3/settings.php | 8 ++++---- unit-tests/Tests/Version4/Settings.php | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/unit-tests/Tests/Version2/settings.php b/unit-tests/Tests/Version2/settings.php index ff6b36a..98d58c8 100644 --- a/unit-tests/Tests/Version2/settings.php +++ b/unit-tests/Tests/Version2/settings.php @@ -163,7 +163,7 @@ public function test_get_group() { // test route callback receiving an empty group id $result = $this->endpoint->get_group_settings( '' ); - $this->assertIsWPError( $result ); + $this->assertWPError( $result ); // test getting a group that does not exist $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v2/settings/not-real' ) ); @@ -344,7 +344,7 @@ public function test_get_setting_without_permission() { public function test_get_setting_empty_setting_id() { $result = $this->endpoint->get_setting( 'test', '' ); - $this->assertIsWPError( $result ); + $this->assertWPError( $result ); } /** @@ -355,7 +355,7 @@ public function test_get_setting_empty_setting_id() { public function test_get_setting_invalid_setting_id() { $result = $this->endpoint->get_setting( 'test', 'invalid' ); - $this->assertIsWPError( $result ); + $this->assertWPError( $result ); } /** @@ -379,7 +379,7 @@ public function test_get_setting_invalid_setting_type() { $result = $controller->get_setting( 'test', 'woocommerce_shop_page_display' ); - $this->assertIsWPError( $result ); + $this->assertWPError( $result ); } /** diff --git a/unit-tests/Tests/Version3/functions.php b/unit-tests/Tests/Version3/functions.php index 8707d3e..3f6f964 100644 --- a/unit-tests/Tests/Version3/functions.php +++ b/unit-tests/Tests/Version3/functions.php @@ -71,7 +71,7 @@ public function test_wc_rest_upload_image_from_url_should_return_error_when_unab $expected_error_message = 'Error getting remote image http://somedomain.com/nonexistent-image.png. Error: Not found.'; $result = wc_rest_upload_image_from_url( 'http://somedomain.com/nonexistent-image.png' ); - $this->assertIsWPError( $result ); + $this->assertWPError( $result ); $this->assertEquals( $expected_error_message, $result->get_error_message() ); } @@ -85,14 +85,14 @@ public function test_wc_rest_upload_image_from_url_should_return_error_when_inva $expected_error_message = 'Invalid image: File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.'; $result = wc_rest_upload_image_from_url( 'http://somedomain.com/invalid-image-1.png' ); - $this->assertIsWPError( $result ); + $this->assertWPError( $result ); $this->assertEquals( $expected_error_message, $result->get_error_message() ); // unsupported mime type. $expected_error_message = 'Invalid image: Sorry, this file type is not permitted for security reasons.'; $result = wc_rest_upload_image_from_url( 'http://somedomain.com/invalid-image-2.png' ); - $this->assertIsWPError( $result ); + $this->assertWPError( $result ); $this->assertEquals( $expected_error_message, $result->get_error_message() ); } diff --git a/unit-tests/Tests/Version3/settings.php b/unit-tests/Tests/Version3/settings.php index e77b69e..48d5934 100644 --- a/unit-tests/Tests/Version3/settings.php +++ b/unit-tests/Tests/Version3/settings.php @@ -164,7 +164,7 @@ public function test_get_group() { // test route callback receiving an empty group id $result = $this->endpoint->get_group_settings( '' ); - $this->assertIsWPError( $result ); + $this->assertWPError( $result ); // test getting a group that does not exist $response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/settings/not-real' ) ); @@ -345,7 +345,7 @@ public function test_get_setting_without_permission() { public function test_get_setting_empty_setting_id() { $result = $this->endpoint->get_setting( 'test', '' ); - $this->assertIsWPError( $result ); + $this->assertWPError( $result ); } /** @@ -356,7 +356,7 @@ public function test_get_setting_empty_setting_id() { public function test_get_setting_invalid_setting_id() { $result = $this->endpoint->get_setting( 'test', 'invalid' ); - $this->assertIsWPError( $result ); + $this->assertWPError( $result ); } /** @@ -380,7 +380,7 @@ public function test_get_setting_invalid_setting_type() { $result = $controller->get_setting( 'test', 'woocommerce_shop_page_display' ); - $this->assertIsWPError( $result ); + $this->assertWPError( $result ); } /** diff --git a/unit-tests/Tests/Version4/Settings.php b/unit-tests/Tests/Version4/Settings.php index 6bfd747..0f24349 100644 --- a/unit-tests/Tests/Version4/Settings.php +++ b/unit-tests/Tests/Version4/Settings.php @@ -390,7 +390,7 @@ public function test_get_setting_invalid_setting_type() { $result = $controller->get_setting( 'test', 'woocommerce_shop_page_display' ); - $this->assertIsWPError( $result ); + $this->assertWPError( $result ); } /**