Skip to content

Commit 218e96d

Browse files
author
childish-sambino
authored
chore!: drop support for EOL PHP versions and add support for PHP 8 (#1090)
Also upgraded phpunit.
1 parent 52021bd commit 218e96d

38 files changed

+280
-287
lines changed

.github/workflows/test-and-deploy.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
timeout-minutes: 20
1818
strategy:
1919
matrix:
20-
php: [ 5.6, 7.0, 7.1, 7.2, 7.3, 7.4 ]
20+
php: [ '7.3', '7.4', '8.0', '8.1' ]
2121
env:
2222
DOCKER_LOGIN: ${{ secrets.DOCKER_USERNAME && secrets.DOCKER_AUTH_TOKEN }}
2323
steps:
@@ -46,7 +46,7 @@ jobs:
4646
- name: Setup PHP
4747
uses: shivammathur/[email protected]
4848
with:
49-
php-version: '7.4'
49+
php-version: '8.1'
5050
id: php
5151

5252
- name: Build Release Artifacts

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Please note that we utilize the [Gitflow Workflow](https://www.atlassian.com/git
5757

5858
##### Prerequisites #####
5959

60-
- PHP 5.6, 7.0, 7.1, 7.2, 7.3 or 7.4
60+
- PHP version 7.3, 7.4, 8.0, or 8.1
6161

6262
##### Initial setup: #####
6363

Makefile

+1-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ ci-install: clean
2222
test:
2323
vendor/bin/phpunit test/unit --filter test*
2424
vendor/bin/phpcs lib/*/*
25-
26-
ifeq ($(shell expr $(php_version) \>= 7.1), 1)
27-
composer require --dev phpstan/phpstan
2825
vendor/bin/phpstan analyse --no-progress --level 1 lib test
29-
endif
3026

3127
test-integ: test
3228
vendor/bin/phpunit test --filter test*
@@ -38,4 +34,4 @@ test-docker:
3834
dependencies=highest version=$(version) bash ./prism.sh
3935

4036
bundle: ci-install
41-
zip -r sendgrid-php.zip . -x \*.git\* \*composer.json\* \*scripts\* \*test\* \*.travis.yml\* \*prism\*
37+
zip -r sendgrid-php.zip . -x \*.git\* \*composer.json\* \*scripts\* \*test\* \*prism\*

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ We appreciate your continued support, thank you!
3939

4040
## Prerequisites
4141

42-
- PHP version 5.6, 7.0, 7.1, 7.2, 7.3, or 7.4
42+
- PHP version 7.3, 7.4, 8.0, or 8.1
4343
- The Twilio SendGrid service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-php) to send up to 40,000 emails for the first 30 days, then send 100 emails/day free forever or check out [our pricing](https://sendgrid.com/pricing?source=sendgrid-php).
4444
- For SMS messages, you will need a free [Twilio account](https://www.twilio.com/try-twilio?source=sendgrid-php).
4545

UPGRADE.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Upgrade Guide
2+
3+
_MAJOR version bumps will have upgrade notes posted here._
4+
5+
[2022-05-04] 7.x.x to 8.x.x
6+
---------------------------
7+
8+
### CHANGED - Drop support for PHP versions 5.6, 7.0, 7.1, and 7.2 which are EOL.

composer.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"grid"
1414
],
1515
"require": {
16-
"php": ">=5.6",
16+
"php": ">=7.3",
1717
"sendgrid/php-http-client": "~3.10",
1818
"starkbank/ecdsa": "0.*",
1919
"ext-curl": "*",
@@ -22,9 +22,10 @@
2222
"ext-openssl": "*"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "^5.7.9 || ^6.4.3",
25+
"phpunit/phpunit": "^9",
2626
"squizlabs/php_codesniffer": "3.*",
27-
"swaggest/json-diff": "^3.4"
27+
"swaggest/json-diff": "^3.4",
28+
"phpstan/phpstan": "^1.5"
2829
},
2930
"replace": {
3031
"sendgrid/sendgrid-php": "*"

test/BaseTestClass.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
* This file contains the base class for testing the request object
44
* generation for a /mail/send API call
55
*/
6+
67
namespace SendGrid\Tests;
78

89
use PHPUnit\Framework\TestCase;
910
use SendGrid;
10-
use Swaggest\JsonDiff\Exception;
1111
use Swaggest\JsonDiff\JsonDiff;
1212
use Swaggest\JsonDiff\JsonPatch;
1313

@@ -27,9 +27,9 @@ class BaseTestClass extends TestCase
2727
/**
2828
* This method is run before the classes are initialised
2929
*
30-
* @return null
30+
* @return void
3131
*/
32-
public static function setUpBeforeClass()
32+
public static function setUpBeforeClass(): void
3333
{
3434
self::$apiKey = 'SENDGRID_API_KEY';
3535
self::$sg = new SendGrid(self::$apiKey);

test/integration/Helpers/Stats/StatsTest.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
2+
23
namespace SendGrid\Tests\Integration\Helpers\Stats;
34

4-
use SendGrid\Tests\BaseTestClass;
55
use SendGrid\Stats\Stats;
6+
use SendGrid\Tests\BaseTestClass;
67

78
class StatsTest extends BaseTestClass
89
{
@@ -21,7 +22,8 @@ public function testGetValues(
2122
$expectedSubuser,
2223
$expectedSum,
2324
$expectedSubuserMonthly
24-
) {
25+
)
26+
{
2527
$userStats = new Stats($expectedGlobal['start_date'], $expectedGlobal['end_date'], $expectedGlobal['aggregated_by']);
2628
$this->assertEquals($expectedGlobal, $userStats->getGlobal());
2729
$this->assertEquals($expectedCategory, $userStats->getCategory($expectedCategory['categories']));
@@ -48,15 +50,16 @@ public function testGetValues(
4850
* @param array $expectedSum
4951
* @param array $expectedSubuserMonthly
5052
* @dataProvider invalidValues
51-
* @expectedException \Exception
5253
*/
5354
public function testGetValuesFail(
5455
$expectedGlobal,
5556
$expectedCategory,
5657
$expectedSubuser,
5758
$expectedSum,
5859
$expectedSubuserMonthly
59-
) {
60+
)
61+
{
62+
$this->expectException(\Exception::class);
6063
$this->testGetValues(
6164
$expectedGlobal,
6265
$expectedCategory,

test/unit/AsmTest.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
/**
33
* This file tests Asm.
44
*/
5+
56
namespace SendGrid\Tests\Unit;
67

78
use PHPUnit\Framework\TestCase;
89
use SendGrid\Mail\Asm;
910
use SendGrid\Mail\GroupId;
1011
use SendGrid\Mail\GroupsToDisplay;
12+
use SendGrid\Mail\TypeException;
1113

1214
/**
1315
* This file tests Asm.
@@ -39,23 +41,21 @@ public function testSetGroupsToDisplay()
3941
$this->assertSame([1, 2, 3, 4], $asm->getGroupsToDisplay());
4042
}
4143

42-
/**
43-
* @expectedException \SendGrid\Mail\TypeException
44-
* @expectedExceptionMessage "$groups_to_display" must be an instance of SendGrid\Mail\GroupsToDisplay or an array.
45-
*/
4644
public function testSetGroupToDisplayOnInvalidValue()
4745
{
46+
$this->expectException(TypeException::class);
47+
$this->expectExceptionMessageMatches('/"\$groups_to_display" must be an instance of SendGrid\\\Mail\\\GroupsToDisplay or an array/');
48+
4849
$asm = new Asm(123456, [1, 2, 3, 4]);
4950
$asm->setGroupsToDisplay('invalid_array');
5051
}
5152

52-
/**
53-
* @expectedException \SendGrid\Mail\TypeException
54-
* @expectedExceptionMessage "$group_id" must be an instance of SendGrid\Mail\GroupId or an integer.
55-
*/
5653
public function testSetGroupIdOnInvalidGroupId()
5754
{
58-
$asm = new Asm(123456, [1,2,3,4]);
55+
$this->expectException(TypeException::class);
56+
$this->expectExceptionMessageMatches('/"\$group_id" must be an instance of SendGrid\\\Mail\\\GroupId or an integer/');
57+
58+
$asm = new Asm(123456, [1, 2, 3, 4]);
5959
$asm->setGroupId('invalid_group_id');
6060
}
6161
}

test/unit/BatchIdTest.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
/**
33
* This file tests BatchId.
44
*/
5+
56
namespace SendGrid\Tests\Unit;
67

78
use PHPUnit\Framework\TestCase;
89
use SendGrid\Mail\BatchId;
10+
use SendGrid\Mail\TypeException;
911

1012
/**
1113
* This file tests BatchId.
@@ -30,14 +32,13 @@ public function testSetBatchId()
3032
$this->assertSame('this_is_batch_id', $batchId->getBatchId());
3133
}
3234

33-
/**
34-
* @expectedException \SendGrid\Mail\TypeException
35-
* @expectedExceptionMessage "$batch_id" must be a string.
36-
*/
3735
public function testSetBatchIdOnInvalidBatchId()
3836
{
37+
$this->expectException(TypeException::class);
38+
$this->expectExceptionMessageMatches('/"\$batch_id" must be a string/');
39+
3940
$batch_id = new BatchId();
40-
$batch_id->setBatchId(['invalid_batch_id']);
41+
$batch_id->setBatchId(123);
4142
}
4243

4344
public function testJsonSerialize()

test/unit/BccSettingsTest.php

+12-13
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
/**
33
* This file tests BccSettings.
44
*/
5+
56
namespace SendGrid\Tests\Unit;
67

78
use PHPUnit\Framework\TestCase;
89
use SendGrid\Mail\BccSettings;
10+
use SendGrid\Mail\TypeException;
911

1012
/**
1113
* This file tests BccSettings.
@@ -31,24 +33,22 @@ public function testSetEmail()
3133
$this->assertSame('[email protected]', $bccSettings->getEmail());
3234
}
3335

34-
/**
35-
* @expectedException \SendGrid\Mail\TypeException
36-
* @expectedExceptionMessage "$email" must be a valid email address.
37-
*/
3836
public function testSetEmailOnInvalidEmailFormat()
3937
{
38+
$this->expectException(TypeException::class);
39+
$this->expectExceptionMessageMatches('/"\$email" must be a valid email address/');
40+
4041
$bccSettings = new BccSettings();
4142
$bccSettings->setEmail('invalid_email_address');
4243
}
4344

44-
/**
45-
* @expectedException \SendGrid\Mail\TypeException
46-
* @expectedExceptionMessage "$email" must be a string.
47-
*/
4845
public function testSetEmailOnInvalidType()
4946
{
47+
$this->expectException(TypeException::class);
48+
$this->expectExceptionMessageMatches('/"\$email" must be a string/');
49+
5050
$bccSettings = new BccSettings();
51-
$bccSettings->setEmail(['invalid_type']);
51+
$bccSettings->setEmail(123);
5252
}
5353

5454
public function testSetEnable()
@@ -59,12 +59,11 @@ public function testSetEnable()
5959
$this->assertTrue($bccSettings->getEnable());
6060
}
6161

62-
/**
63-
* @expectedException \SendGrid\Mail\TypeException
64-
* @expectedExceptionMessage "$enable" must be a boolean.
65-
*/
6662
public function testSetEnableOnInvalidType()
6763
{
64+
$this->expectException(TypeException::class);
65+
$this->expectExceptionMessageMatches('/"\$enable" must be a boolean/');
66+
6867
$bccSettings = new BccSettings();
6968
$bccSettings->setEnable('invalid_bool_type');
7069
}

test/unit/BypassBounceManagementTest.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
/**
33
* This file tests BypassBounceManagement.
44
*/
5+
56
namespace SendGrid\Tests\Unit;
67

78
use PHPUnit\Framework\TestCase;
89
use SendGrid\Mail\BypassBounceManagement;
10+
use SendGrid\Mail\TypeException;
911

1012
/**
1113
* This file tests BypassBounceManagement.
@@ -30,12 +32,11 @@ public function testSetEnable()
3032
$this->assertTrue($bypassBounceManagement->getEnable());
3133
}
3234

33-
/**
34-
* @expectedException \SendGrid\Mail\TypeException
35-
* @expectedExceptionMessage "$enable" must be a boolean.
36-
*/
3735
public function testSetEnableOnInvalidType()
3836
{
37+
$this->expectException(TypeException::class);
38+
$this->expectExceptionMessageMatches('/"\$enable" must be a boolean/');
39+
3940
$bypassBounceManagement = new BypassBounceManagement();
4041
$bypassBounceManagement->setEnable('invalid_bool_type');
4142
}

test/unit/BypassListManagementTest.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
/**
33
* This file tests BypassListManagement.
44
*/
5+
56
namespace SendGrid\Tests\Unit;
67

78
use PHPUnit\Framework\TestCase;
89
use SendGrid\Mail\BypassListManagement;
10+
use SendGrid\Mail\TypeException;
911

1012
/**
1113
* This file tests BypassListManagement.
@@ -30,12 +32,11 @@ public function testSetEnable()
3032
$this->assertTrue($bypassListManagement->getEnable());
3133
}
3234

33-
/**
34-
* @expectedException \SendGrid\Mail\TypeException
35-
* @expectedExceptionMessage "$enable" must be a boolean.
36-
*/
3735
public function testSetEnableOnInvalidType()
3836
{
37+
$this->expectException(TypeException::class);
38+
$this->expectExceptionMessageMatches('/"\$enable" must be a boolean/');
39+
3940
$bypassListManagement = new BypassListManagement();
4041
$bypassListManagement->setEnable('invalid_bool_type');
4142
}

test/unit/BypassSpamManagementTest.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
/**
33
* This file tests BypassSpamManagement.
44
*/
5+
56
namespace SendGrid\Tests\Unit;
67

78
use PHPUnit\Framework\TestCase;
89
use SendGrid\Mail\BypassSpamManagement;
10+
use SendGrid\Mail\TypeException;
911

1012
/**
1113
* This file tests BypassSpamManagement.
@@ -30,12 +32,11 @@ public function testSetEnable()
3032
$this->assertTrue($bypassSpamManagement->getEnable());
3133
}
3234

33-
/**
34-
* @expectedException \SendGrid\Mail\TypeException
35-
* @expectedExceptionMessage "$enable" must be a boolean.
36-
*/
3735
public function testSetEnableOnInvalidType()
3836
{
37+
$this->expectException(TypeException::class);
38+
$this->expectExceptionMessageMatches('/"\$enable" must be a boolean/');
39+
3940
$bypassSpamManagement = new BypassSpamManagement();
4041
$bypassSpamManagement->setEnable('invalid_bool_type');
4142
}

0 commit comments

Comments
 (0)