Skip to content

Commit

Permalink
see #607: Add addional string to error message. Change tests expected…
Browse files Browse the repository at this point in the history
… responses
  • Loading branch information
stoyan0v committed Sep 7, 2017
1 parent c81200b commit eeb5f8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/includes/class-wordlift-autocomplete-adapter.php
Expand Up @@ -90,7 +90,7 @@ public function wl_autocomplete() {
// There is an error, so send error message.
wp_send_json_error( array(
/* translators: Placeholders: %s - the error message that will be returned. */
'message' => sprintf( esc_html__( '%s', 'wordlift' ), $error_message ),
'message' => sprintf( esc_html__( 'Error: %s', 'wordlift' ), $error_message ),
) );
}
}
Expand Down
12 changes: 6 additions & 6 deletions tests/test-ajax-autocomplete.php
Expand Up @@ -44,7 +44,7 @@ public function test_autocomplete_without_nonce() {
$this->assertFalse( $response->success );
$this->assertObjectHasAttribute( 'data', $response );
$this->assertObjectHasAttribute( 'message', $response->data );
$this->assertEquals( 'Nonce field doens\'t match', $response->data->message );
$this->assertEquals( 'Nonce field doens\'t match.', $response->data->message );
}

public function test_autocomplete_with_wrong_nonce() {
Expand All @@ -62,7 +62,7 @@ public function test_autocomplete_with_wrong_nonce() {
$this->assertFalse( $response->success );
$this->assertObjectHasAttribute( 'data', $response );
$this->assertObjectHasAttribute( 'message', $response->data );
$this->assertEquals( 'Nonce field doens\'t match', $response->data->message );
$this->assertEquals( 'Nonce field doens\'t match.', $response->data->message );
}

public function test_autocomplete_with_nonce_without_query_param() {
Expand All @@ -80,7 +80,7 @@ public function test_autocomplete_with_nonce_without_query_param() {
$this->assertFalse( $response->success );
$this->assertObjectHasAttribute( 'data', $response );
$this->assertObjectHasAttribute( 'message', $response->data );
$this->assertEquals( 'The query param is empty!', $response->data->message );
$this->assertEquals( 'The query param is empty.', $response->data->message );
}

public function test_autocomplete_with_nonce_with_empty_query_param() {
Expand All @@ -99,7 +99,7 @@ public function test_autocomplete_with_nonce_with_empty_query_param() {
$this->assertFalse( $response->success );
$this->assertObjectHasAttribute( 'data', $response );
$this->assertObjectHasAttribute( 'message', $response->data );
$this->assertEquals( 'The query param is empty!', $response->data->message );
$this->assertEquals( 'The query param is empty.', $response->data->message );
}

public function test_autocomplete_error_status_code() {
Expand All @@ -120,7 +120,7 @@ public function test_autocomplete_error_status_code() {
$this->assertFalse( $response->success );
$this->assertObjectHasAttribute( 'data', $response );
$this->assertObjectHasAttribute( 'message', $response->data );
$this->assertEquals( 'Something went wrong.', $response->data->message );
$this->assertEquals( 'Error: Something went wrong.', $response->data->message );
}

public function test_autocomplete_wp_error() {
Expand All @@ -141,7 +141,7 @@ public function test_autocomplete_wp_error() {
$this->assertFalse( $response->success );
$this->assertObjectHasAttribute( 'data', $response );
$this->assertObjectHasAttribute( 'message', $response->data );
$this->assertEquals( 'WP Error!', $response->data->message );
$this->assertEquals( 'Error: WP Error!', $response->data->message );
}


Expand Down

0 comments on commit eeb5f8d

Please sign in to comment.