From ec80b04489ac31a06afbf6ecf42a3234afe1d708 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 3 Sep 2024 10:33:26 +0800 Subject: [PATCH 1/3] Run tests against latest WordPress version --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 373be62..39442b8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,7 +45,7 @@ jobs: # Defines the WordPress and PHP Versions matrix to run tests on. strategy: 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 From caa886d1ff620b942ab0bb205b2c53f151864184 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 3 Sep 2024 10:33:41 +0800 Subject: [PATCH 2/3] Add tests for no API credentials; fix test when invalid API credentials supplied --- tests/wpunit/APITest.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/wpunit/APITest.php b/tests/wpunit/APITest.php index f14af87..dcc85ca 100644 --- a/tests/wpunit/APITest.php +++ b/tests/wpunit/APITest.php @@ -491,6 +491,20 @@ 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. * @@ -498,7 +512,7 @@ public function testRefreshTokenWithInvalidToken() */ 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); From cfade16b353307370ee2769ed6db043aab717a6d Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Tue, 3 Sep 2024 11:03:04 +0800 Subject: [PATCH 3/3] =?UTF-8?q?Don=E2=80=99t=20fail-fast=20if=20other=20jo?= =?UTF-8?q?bs=20fail.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 39442b8..ded4e07 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -44,6 +44,7 @@ jobs: # Defines the WordPress and PHP Versions matrix to run tests on. strategy: + fail-fast: false matrix: 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' ]