Skip to content

Commit

Permalink
Merge pull request #78 from ConvertKit/fix-invalid-api-credentials-test
Browse files Browse the repository at this point in the history
Tests: Fix Invalid API Credentials
  • Loading branch information
n7studios authored Sep 4, 2024
2 parents 7736b19 + cfade16 commit 7278076
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
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

0 comments on commit 7278076

Please sign in to comment.