Skip to content

Commit 4d1efd3

Browse files
committed
Test all PHP versions; fix API Key env
1 parent 6f725e0 commit 4d1efd3

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
fail-fast: false
2525
matrix:
26-
php-versions: [ '8.0' ]
26+
php-versions: [ '8.0', '8.1', '8.2', '8.3', '8.4' ]
2727

2828
# Steps to install, configure and run tests
2929
steps:

tests/ConvertKitAPIKeyTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function setUp(): void
3131

3232
// Setup API instances.
3333
$this->api = new ConvertKit_API(
34-
apiKey: $_ENV['CONVERTKIT_API_KEY']
34+
apiKey: $_ENV['CONVERTKIT_V4_API_KEY']
3535
);
3636

3737
// Wait a second to avoid hitting a 429 rate limit.
@@ -49,7 +49,7 @@ public function testDebugEnabled()
4949
{
5050
// Setup API with debugging enabled.
5151
$api = new ConvertKit_API(
52-
apiKey: $_ENV['CONVERTKIT_API_KEY'],
52+
apiKey: $_ENV['CONVERTKIT_V4_API_KEY'],
5353
debug: true
5454
);
5555

@@ -75,7 +75,7 @@ public function testDebugEnabledWithCustomLogFile()
7575

7676
// Setup API with debugging enabled.
7777
$api = new ConvertKit_API(
78-
apiKey: $_ENV['CONVERTKIT_API_KEY'],
78+
apiKey: $_ENV['CONVERTKIT_V4_API_KEY'],
7979
debug: true,
8080
debugLogFileLocation: $this->logFile
8181
);
@@ -101,21 +101,21 @@ public function testDebugCredentialsAndEmailsAreMasked()
101101
{
102102
// Setup API with debugging enabled.
103103
$api = new ConvertKit_API(
104-
apiKey: $_ENV['CONVERTKIT_API_KEY'],
104+
apiKey: $_ENV['CONVERTKIT_V4_API_KEY'],
105105
debug: true
106106
);
107107

108108
// Create log entries with API Key and Email Address, as if an API method
109109
// were to log this sensitive data.
110-
$this->callPrivateMethod($api, 'create_log', ['API Key: ' . $_ENV['CONVERTKIT_API_KEY']]);
110+
$this->callPrivateMethod($api, 'create_log', ['API Key: ' . $_ENV['CONVERTKIT_V4_API_KEY']]);
111111
$this->callPrivateMethod($api, 'create_log', ['Email: ' . $_ENV['CONVERTKIT_API_SUBSCRIBER_EMAIL']]);
112112

113113
// Confirm that the log includes the masked API Key and Email Address.
114114
$this->assertStringContainsString(
115115
str_repeat(
116116
'*',
117-
(strlen($_ENV['CONVERTKIT_API_KEY']) - 4)
118-
) . substr($_ENV['CONVERTKIT_API_KEY'], -4),
117+
(strlen($_ENV['CONVERTKIT_V4_API_KEY']) - 4)
118+
) . substr($_ENV['CONVERTKIT_V4_API_KEY'], -4),
119119
$this->getLogFileContents()
120120
);
121121
$this->assertStringContainsString(
@@ -124,7 +124,7 @@ public function testDebugCredentialsAndEmailsAreMasked()
124124
);
125125

126126
// Confirm that the log does not include the unmasked API Key or Email Address.
127-
$this->assertStringNotContainsString($_ENV['CONVERTKIT_API_KEY'], $this->getLogFileContents());
127+
$this->assertStringNotContainsString($_ENV['CONVERTKIT_V4_API_KEY'], $this->getLogFileContents());
128128
$this->assertStringNotContainsString($_ENV['CONVERTKIT_API_SUBSCRIBER_EMAIL'], $this->getLogFileContents());
129129
}
130130

@@ -158,7 +158,7 @@ public function testRequestHeadersMethod()
158158
$this->assertEquals($headers['Accept'], 'application/json');
159159
$this->assertEquals($headers['Content-Type'], 'application/json; charset=utf-8');
160160
$this->assertEquals($headers['User-Agent'], 'ConvertKitPHPSDK/' . $this->api::VERSION . ';PHP/' . phpversion());
161-
$this->assertEquals($headers['X-Kit-Api-Key'], $_ENV['CONVERTKIT_API_KEY']);
161+
$this->assertEquals($headers['X-Kit-Api-Key'], $_ENV['CONVERTKIT_V4_API_KEY']);
162162
}
163163

164164
/**
@@ -181,7 +181,7 @@ public function testRequestHeadersMethodWithType()
181181
$this->assertEquals($headers['Accept'], 'text/html');
182182
$this->assertEquals($headers['Content-Type'], 'text/html; charset=utf-8');
183183
$this->assertEquals($headers['User-Agent'], 'ConvertKitPHPSDK/' . $this->api::VERSION . ';PHP/' . phpversion());
184-
$this->assertEquals($headers['X-Kit-Api-Key'], $_ENV['CONVERTKIT_API_KEY']);
184+
$this->assertEquals($headers['X-Kit-Api-Key'], $_ENV['CONVERTKIT_V4_API_KEY']);
185185
}
186186

187187
/**

0 commit comments

Comments
 (0)