Skip to content

Commit

Permalink
chore!: drop support for EOL PHP versions and add support for PHP 8 (#…
Browse files Browse the repository at this point in the history
…1090)

Also upgraded phpunit.
  • Loading branch information
childish-sambino authored May 2, 2022
1 parent 52021bd commit 218e96d
Show file tree
Hide file tree
Showing 38 changed files with 280 additions and 287 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
timeout-minutes: 20
strategy:
matrix:
php: [ 5.6, 7.0, 7.1, 7.2, 7.3, 7.4 ]
php: [ '7.3', '7.4', '8.0', '8.1' ]
env:
DOCKER_LOGIN: ${{ secrets.DOCKER_USERNAME && secrets.DOCKER_AUTH_TOKEN }}
steps:
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/[email protected]
with:
php-version: '7.4'
php-version: '8.1'
id: php

- name: Build Release Artifacts
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Please note that we utilize the [Gitflow Workflow](https://www.atlassian.com/git

##### Prerequisites #####

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

##### Initial setup: #####

Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ ci-install: clean
test:
vendor/bin/phpunit test/unit --filter test*
vendor/bin/phpcs lib/*/*

ifeq ($(shell expr $(php_version) \>= 7.1), 1)
composer require --dev phpstan/phpstan
vendor/bin/phpstan analyse --no-progress --level 1 lib test
endif

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

bundle: ci-install
zip -r sendgrid-php.zip . -x \*.git\* \*composer.json\* \*scripts\* \*test\* \*.travis.yml\* \*prism\*
zip -r sendgrid-php.zip . -x \*.git\* \*composer.json\* \*scripts\* \*test\* \*prism\*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ We appreciate your continued support, thank you!

## Prerequisites

- PHP version 5.6, 7.0, 7.1, 7.2, 7.3, or 7.4
- PHP version 7.3, 7.4, 8.0, or 8.1
- 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).
- For SMS messages, you will need a free [Twilio account](https://www.twilio.com/try-twilio?source=sendgrid-php).

Expand Down
8 changes: 8 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Upgrade Guide

_MAJOR version bumps will have upgrade notes posted here._

[2022-05-04] 7.x.x to 8.x.x
---------------------------

### CHANGED - Drop support for PHP versions 5.6, 7.0, 7.1, and 7.2 which are EOL.
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"grid"
],
"require": {
"php": ">=5.6",
"php": ">=7.3",
"sendgrid/php-http-client": "~3.10",
"starkbank/ecdsa": "0.*",
"ext-curl": "*",
Expand All @@ -22,9 +22,10 @@
"ext-openssl": "*"
},
"require-dev": {
"phpunit/phpunit": "^5.7.9 || ^6.4.3",
"phpunit/phpunit": "^9",
"squizlabs/php_codesniffer": "3.*",
"swaggest/json-diff": "^3.4"
"swaggest/json-diff": "^3.4",
"phpstan/phpstan": "^1.5"
},
"replace": {
"sendgrid/sendgrid-php": "*"
Expand Down
6 changes: 3 additions & 3 deletions test/BaseTestClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* This file contains the base class for testing the request object
* generation for a /mail/send API call
*/

namespace SendGrid\Tests;

use PHPUnit\Framework\TestCase;
use SendGrid;
use Swaggest\JsonDiff\Exception;
use Swaggest\JsonDiff\JsonDiff;
use Swaggest\JsonDiff\JsonPatch;

Expand All @@ -27,9 +27,9 @@ class BaseTestClass extends TestCase
/**
* This method is run before the classes are initialised
*
* @return null
* @return void
*/
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
self::$apiKey = 'SENDGRID_API_KEY';
self::$sg = new SendGrid(self::$apiKey);
Expand Down
11 changes: 7 additions & 4 deletions test/integration/Helpers/Stats/StatsTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace SendGrid\Tests\Integration\Helpers\Stats;

use SendGrid\Tests\BaseTestClass;
use SendGrid\Stats\Stats;
use SendGrid\Tests\BaseTestClass;

class StatsTest extends BaseTestClass
{
Expand All @@ -21,7 +22,8 @@ public function testGetValues(
$expectedSubuser,
$expectedSum,
$expectedSubuserMonthly
) {
)
{
$userStats = new Stats($expectedGlobal['start_date'], $expectedGlobal['end_date'], $expectedGlobal['aggregated_by']);
$this->assertEquals($expectedGlobal, $userStats->getGlobal());
$this->assertEquals($expectedCategory, $userStats->getCategory($expectedCategory['categories']));
Expand All @@ -48,15 +50,16 @@ public function testGetValues(
* @param array $expectedSum
* @param array $expectedSubuserMonthly
* @dataProvider invalidValues
* @expectedException \Exception
*/
public function testGetValuesFail(
$expectedGlobal,
$expectedCategory,
$expectedSubuser,
$expectedSum,
$expectedSubuserMonthly
) {
)
{
$this->expectException(\Exception::class);
$this->testGetValues(
$expectedGlobal,
$expectedCategory,
Expand Down
18 changes: 9 additions & 9 deletions test/unit/AsmTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
/**
* This file tests Asm.
*/

namespace SendGrid\Tests\Unit;

use PHPUnit\Framework\TestCase;
use SendGrid\Mail\Asm;
use SendGrid\Mail\GroupId;
use SendGrid\Mail\GroupsToDisplay;
use SendGrid\Mail\TypeException;

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

/**
* @expectedException \SendGrid\Mail\TypeException
* @expectedExceptionMessage "$groups_to_display" must be an instance of SendGrid\Mail\GroupsToDisplay or an array.
*/
public function testSetGroupToDisplayOnInvalidValue()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$groups_to_display" must be an instance of SendGrid\\\Mail\\\GroupsToDisplay or an array/');

$asm = new Asm(123456, [1, 2, 3, 4]);
$asm->setGroupsToDisplay('invalid_array');
}

/**
* @expectedException \SendGrid\Mail\TypeException
* @expectedExceptionMessage "$group_id" must be an instance of SendGrid\Mail\GroupId or an integer.
*/
public function testSetGroupIdOnInvalidGroupId()
{
$asm = new Asm(123456, [1,2,3,4]);
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$group_id" must be an instance of SendGrid\\\Mail\\\GroupId or an integer/');

$asm = new Asm(123456, [1, 2, 3, 4]);
$asm->setGroupId('invalid_group_id');
}
}
11 changes: 6 additions & 5 deletions test/unit/BatchIdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
/**
* This file tests BatchId.
*/

namespace SendGrid\Tests\Unit;

use PHPUnit\Framework\TestCase;
use SendGrid\Mail\BatchId;
use SendGrid\Mail\TypeException;

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

/**
* @expectedException \SendGrid\Mail\TypeException
* @expectedExceptionMessage "$batch_id" must be a string.
*/
public function testSetBatchIdOnInvalidBatchId()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$batch_id" must be a string/');

$batch_id = new BatchId();
$batch_id->setBatchId(['invalid_batch_id']);
$batch_id->setBatchId(123);
}

public function testJsonSerialize()
Expand Down
25 changes: 12 additions & 13 deletions test/unit/BccSettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
/**
* This file tests BccSettings.
*/

namespace SendGrid\Tests\Unit;

use PHPUnit\Framework\TestCase;
use SendGrid\Mail\BccSettings;
use SendGrid\Mail\TypeException;

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

/**
* @expectedException \SendGrid\Mail\TypeException
* @expectedExceptionMessage "$email" must be a valid email address.
*/
public function testSetEmailOnInvalidEmailFormat()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$email" must be a valid email address/');

$bccSettings = new BccSettings();
$bccSettings->setEmail('invalid_email_address');
}

/**
* @expectedException \SendGrid\Mail\TypeException
* @expectedExceptionMessage "$email" must be a string.
*/
public function testSetEmailOnInvalidType()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$email" must be a string/');

$bccSettings = new BccSettings();
$bccSettings->setEmail(['invalid_type']);
$bccSettings->setEmail(123);
}

public function testSetEnable()
Expand All @@ -59,12 +59,11 @@ public function testSetEnable()
$this->assertTrue($bccSettings->getEnable());
}

/**
* @expectedException \SendGrid\Mail\TypeException
* @expectedExceptionMessage "$enable" must be a boolean.
*/
public function testSetEnableOnInvalidType()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$enable" must be a boolean/');

$bccSettings = new BccSettings();
$bccSettings->setEnable('invalid_bool_type');
}
Expand Down
9 changes: 5 additions & 4 deletions test/unit/BypassBounceManagementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
/**
* This file tests BypassBounceManagement.
*/

namespace SendGrid\Tests\Unit;

use PHPUnit\Framework\TestCase;
use SendGrid\Mail\BypassBounceManagement;
use SendGrid\Mail\TypeException;

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

/**
* @expectedException \SendGrid\Mail\TypeException
* @expectedExceptionMessage "$enable" must be a boolean.
*/
public function testSetEnableOnInvalidType()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$enable" must be a boolean/');

$bypassBounceManagement = new BypassBounceManagement();
$bypassBounceManagement->setEnable('invalid_bool_type');
}
Expand Down
9 changes: 5 additions & 4 deletions test/unit/BypassListManagementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
/**
* This file tests BypassListManagement.
*/

namespace SendGrid\Tests\Unit;

use PHPUnit\Framework\TestCase;
use SendGrid\Mail\BypassListManagement;
use SendGrid\Mail\TypeException;

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

/**
* @expectedException \SendGrid\Mail\TypeException
* @expectedExceptionMessage "$enable" must be a boolean.
*/
public function testSetEnableOnInvalidType()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$enable" must be a boolean/');

$bypassListManagement = new BypassListManagement();
$bypassListManagement->setEnable('invalid_bool_type');
}
Expand Down
9 changes: 5 additions & 4 deletions test/unit/BypassSpamManagementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
/**
* This file tests BypassSpamManagement.
*/

namespace SendGrid\Tests\Unit;

use PHPUnit\Framework\TestCase;
use SendGrid\Mail\BypassSpamManagement;
use SendGrid\Mail\TypeException;

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

/**
* @expectedException \SendGrid\Mail\TypeException
* @expectedExceptionMessage "$enable" must be a boolean.
*/
public function testSetEnableOnInvalidType()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$enable" must be a boolean/');

$bypassSpamManagement = new BypassSpamManagement();
$bypassSpamManagement->setEnable('invalid_bool_type');
}
Expand Down
Loading

0 comments on commit 218e96d

Please sign in to comment.