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

Tests: Fix Invalid API Credentials #78

Merged
merged 3 commits into from
Sep 4, 2024
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
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ jobs:

# Defines the WordPress and PHP Versions matrix to run tests on.
strategy:
fail-fast: false
matrix:
wp-versions: [ '6.6-RC3' ] #[ 'latest', '6.1.1' ]
wp-versions: [ 'latest' ] #[ 'latest', '6.1.1' ]
php-versions: [ '7.4', '8.0', '8.1', '8.2', '8.3' ] #[ '7.4', '8.0', '8.1', '8.2' ]

# Steps to install, configure and run tests
Expand Down
16 changes: 15 additions & 1 deletion tests/wpunit/APITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,14 +491,28 @@ public function testRefreshTokenWithInvalidToken()
$this->assertEquals($result->get_error_code(), 'convertkit_api_error');
}

/**
* Test that supplying no API credentials to the API class returns a WP_Error.
*
* @since 2.0.2
*/
public function testNoAPICredentials()
{
$api = new ConvertKit_API_V4( $_ENV['CONVERTKIT_OAUTH_CLIENT_ID'], $_ENV['CONVERTKIT_OAUTH_REDIRECT_URI'] );
$result = $api->get_account();
$this->assertInstanceOf(WP_Error::class, $result);
$this->assertEquals($result->get_error_code(), $this->errorCode);
$this->assertEquals($result->get_error_message(), 'Authentication Failed');
}

/**
* Test that supplying invalid API credentials to the API class returns a WP_Error.
*
* @since 1.0.0
*/
public function testInvalidAPICredentials()
{
$api = new ConvertKit_API_V4( $_ENV['CONVERTKIT_OAUTH_CLIENT_ID'], $_ENV['CONVERTKIT_OAUTH_REDIRECT_URI'] );
$api = new ConvertKit_API_V4( $_ENV['CONVERTKIT_OAUTH_CLIENT_ID'], $_ENV['CONVERTKIT_OAUTH_REDIRECT_URI'], 'fakeAccessToken', 'fakeRefreshToken' );
$result = $api->get_account();
$this->assertInstanceOf(WP_Error::class, $result);
$this->assertEquals($result->get_error_code(), $this->errorCode);
Expand Down
Loading