Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use WP_UnitTestCase::assertWPError() instead of WC_Unit_Test_Case::assertIsWPError() #6

Merged
merged 1 commit into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions unit-tests/Tests/Version2/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
Expand Down Expand Up @@ -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 );
}

/**
Expand All @@ -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 );
}

/**
Expand All @@ -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 );
}

/**
Expand Down
6 changes: 3 additions & 3 deletions unit-tests/Tests/Version3/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
}

Expand All @@ -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() );
}

Expand Down
8 changes: 4 additions & 4 deletions unit-tests/Tests/Version3/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
Expand Down Expand Up @@ -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 );
}

/**
Expand All @@ -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 );
}

/**
Expand All @@ -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 );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion unit-tests/Tests/Version4/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand Down