From 71064a51bbb3cf88d120d02592517dcd19d2af3e Mon Sep 17 00:00:00 2001 From: ksvirkou Date: Mon, 20 Dec 2021 17:14:47 +0300 Subject: [PATCH 1/6] update dependencies --- .travis.yml | 2 -- composer.json | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 28ba013b..7c305da3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,6 @@ sudo: false jobs: include: - - php: 7.2 - env: PHPUNIT_SUITE=All - php: 7.3 env: PHPUNIT_SUITE=Unit - php: 7.4 diff --git a/composer.json b/composer.json index 67570126..45da3ce0 100644 --- a/composer.json +++ b/composer.json @@ -12,14 +12,14 @@ } ], "require": { - "php": ">=7.2", + "php": ">=7.3", "ext-json": "*", - "guzzlehttp/guzzle": "~6.0 | ^7.0" + "guzzlehttp/guzzle": "^7.3" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.13", - "phpunit/phpunit": "~5.0", - "phpspec/phpspec": "^3.4" + "friendsofphp/php-cs-fixer": "^3.4", + "phpunit/phpunit": "^9.5", + "phpspec/phpspec": "^7.1" }, "autoload": { "psr-4": { From 683b7e7756416879464828f786ee886ed52704ad Mon Sep 17 00:00:00 2001 From: ksvirkou Date: Mon, 20 Dec 2021 17:36:52 +0300 Subject: [PATCH 2/6] update cs-fixer config and etc --- .gitignore | 4 ++-- .php_cs.dist => .php-cs-fixer.dist.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) rename .php_cs.dist => .php-cs-fixer.dist.php (82%) diff --git a/.gitignore b/.gitignore index 7d481c53..3e0a7385 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,5 @@ test.php .phpintel /nbproject -.php_cs -.php_cs.cache +.php_cs-fixer +.php-cs-fixer.cache diff --git a/.php_cs.dist b/.php-cs-fixer.dist.php similarity index 82% rename from .php_cs.dist rename to .php-cs-fixer.dist.php index dbb803cd..7d1a79e8 100644 --- a/.php_cs.dist +++ b/.php-cs-fixer.dist.php @@ -6,7 +6,8 @@ ->notPath('/cache/') ; -return PhpCsFixer\Config::create() +$config = new PhpCsFixer\Config(); +return $config ->setFinder($finder) ->setRules([ '@PSR2' => true, From 787e340a4cffdecb9bce627bd76c29edd6554e86 Mon Sep 17 00:00:00 2001 From: ksvirkou Date: Mon, 20 Dec 2021 18:05:39 +0300 Subject: [PATCH 3/6] cs fix --- src/Resources/CrmAssociations.php | 76 +++++++++---------- src/Utils/OAuth2.php | 2 +- src/helpers.php | 6 ++ tests/Integration/Resources/ContactsTest.php | 2 +- .../Resources/EcommerceBridgeTest.php | 2 +- tests/unit/Exception/HubspotExceptionTest.php | 2 +- 6 files changed, 48 insertions(+), 42 deletions(-) diff --git a/src/Resources/CrmAssociations.php b/src/Resources/CrmAssociations.php index 74bc681f..1a209394 100644 --- a/src/Resources/CrmAssociations.php +++ b/src/Resources/CrmAssociations.php @@ -9,44 +9,44 @@ */ class CrmAssociations extends Resource { - const CONTACT_TO_COMPANY = 1; - const COMPANY_TO_CONTACT = 2; - const DEAL_TO_CONTACT = 3; - const CONTACT_TO_DEAL = 4; - const DEAL_TO_COMPANY = 5; - const COMPANY_TO_DEAL = 6; - const COMPANY_TO_ENGAGEMENT = 7; - const ENGAGEMENT_TO_COMPANY = 8; - const CONTACT_TO_ENGAGEMENT = 9; - const ENGAGEMENT_TO_CONTACT = 10; - const DEAL_TO_ENGAGEMENT = 11; - const ENGAGEMENT_TO_DEAL = 12; - const PARENT_COMPANY_TO_CHILD_COMPANY = 13; - const CHILD_COMPANY_TO_PARENT_COMPANY = 14; - const CONTACT_TO_TICKET = 15; - const TICKET_TO_CONTACT = 16; - const TICKET_TO_ENGAGEMENT = 17; - const ENGAGEMENT_TO_TICKET = 18; - const DEAL_TO_LINE_ITEM = 19; - const LINE_ITEM_TO_DEAL = 20; - const COMPANY_TO_TICKET = 25; - const TICKET_TO_COMPANY = 26; - const DEAL_TO_TICKET = 27; - const TICKET_TO_DEAL = 28; - const ADVISOR_TO_COMPANY = 33; - const COMPANY_TO_ADVISOR = 34; - const BOARD_MEMBER_TO_COMPANY = 35; - const COMPANY_TO_BOARD_MEMBER = 36; - const CONTRACTOR_TO_COMPANY = 37; - const COMPANY_TO_CONTRACTOR = 38; - const MANAGER_TO_COMPANY = 39; - const COMPANY_TO_MANAGER = 40; - const BUSINESS_OWNER_TO_COMPANY = 41; - const COMPANY_TO_BUSINESS_OWNER = 42; - const PARTNER_TO_COMPANY = 43; - const COMPANY_TO_PARTNER = 44; - const RESELLER_TO_COMPANY = 45; - const COMPANY_TO_RESELLER = 46; + public const CONTACT_TO_COMPANY = 1; + public const COMPANY_TO_CONTACT = 2; + public const DEAL_TO_CONTACT = 3; + public const CONTACT_TO_DEAL = 4; + public const DEAL_TO_COMPANY = 5; + public const COMPANY_TO_DEAL = 6; + public const COMPANY_TO_ENGAGEMENT = 7; + public const ENGAGEMENT_TO_COMPANY = 8; + public const CONTACT_TO_ENGAGEMENT = 9; + public const ENGAGEMENT_TO_CONTACT = 10; + public const DEAL_TO_ENGAGEMENT = 11; + public const ENGAGEMENT_TO_DEAL = 12; + public const PARENT_COMPANY_TO_CHILD_COMPANY = 13; + public const CHILD_COMPANY_TO_PARENT_COMPANY = 14; + public const CONTACT_TO_TICKET = 15; + public const TICKET_TO_CONTACT = 16; + public const TICKET_TO_ENGAGEMENT = 17; + public const ENGAGEMENT_TO_TICKET = 18; + public const DEAL_TO_LINE_ITEM = 19; + public const LINE_ITEM_TO_DEAL = 20; + public const COMPANY_TO_TICKET = 25; + public const TICKET_TO_COMPANY = 26; + public const DEAL_TO_TICKET = 27; + public const TICKET_TO_DEAL = 28; + public const ADVISOR_TO_COMPANY = 33; + public const COMPANY_TO_ADVISOR = 34; + public const BOARD_MEMBER_TO_COMPANY = 35; + public const COMPANY_TO_BOARD_MEMBER = 36; + public const CONTRACTOR_TO_COMPANY = 37; + public const COMPANY_TO_CONTRACTOR = 38; + public const MANAGER_TO_COMPANY = 39; + public const COMPANY_TO_MANAGER = 40; + public const BUSINESS_OWNER_TO_COMPANY = 41; + public const COMPANY_TO_BUSINESS_OWNER = 42; + public const PARTNER_TO_COMPANY = 43; + public const COMPANY_TO_PARTNER = 44; + public const RESELLER_TO_COMPANY = 45; + public const COMPANY_TO_RESELLER = 46; /** * Get associations for a CRM object. diff --git a/src/Utils/OAuth2.php b/src/Utils/OAuth2.php index 85ee08a4..486700bf 100644 --- a/src/Utils/OAuth2.php +++ b/src/Utils/OAuth2.php @@ -4,7 +4,7 @@ class OAuth2 { - const AUTHORIZE_URL = 'https://app.hubspot.com/oauth/authorize'; + public const AUTHORIZE_URL = 'https://app.hubspot.com/oauth/authorize'; /** * Initiate an Integration with OAuth 2.0. diff --git a/src/helpers.php b/src/helpers.php index c549e374..5358bfc9 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -63,10 +63,13 @@ function url_encode($value, $encoding = PHP_QUERY_RFC3986) switch ($encoding) { case false: return $value; + case PHP_QUERY_RFC3986: return rawurlencode($value); + case PHP_QUERY_RFC1738: return urlencode($value); + default: throw new \InvalidArgumentException('Invalid type'); } @@ -86,10 +89,13 @@ function ms_timestamp($time) switch (true) { case $time instanceof \DateTime: return $time->getTimestamp() * 1000; + case is_numeric($time) && 10 === strlen((string) $time): return $time * 1000; + case is_string($time): return strtotime($time) * 1000; + default: return $time; } diff --git a/tests/Integration/Resources/ContactsTest.php b/tests/Integration/Resources/ContactsTest.php index 68278daa..b1794001 100644 --- a/tests/Integration/Resources/ContactsTest.php +++ b/tests/Integration/Resources/ContactsTest.php @@ -141,7 +141,7 @@ public function createOrUpdateBatchWithAuditId() ], ['auditId' => 'TEST_CHANGE_SOURCE']); $this->assertEquals(202, $response->getStatusCode()); - foreach ($this->resource->getBatchByEmails($emails)->getData() as $contact) { + foreach ($this->resource->getBatchByEmails($emails)->getData() as $contact) { $this->resource->delete($contact->vid); } } diff --git a/tests/Integration/Resources/EcommerceBridgeTest.php b/tests/Integration/Resources/EcommerceBridgeTest.php index d826738b..43d834e9 100644 --- a/tests/Integration/Resources/EcommerceBridgeTest.php +++ b/tests/Integration/Resources/EcommerceBridgeTest.php @@ -15,7 +15,7 @@ */ class EcommerceBridgeTest extends DefaultTestCase { - const STORE_ID = 'ecommercebridge-test-store'; + public const STORE_ID = 'ecommercebridge-test-store'; /** * @var EcommerceBridge diff --git a/tests/unit/Exception/HubspotExceptionTest.php b/tests/unit/Exception/HubspotExceptionTest.php index aacadcfb..54deeecd 100644 --- a/tests/unit/Exception/HubspotExceptionTest.php +++ b/tests/unit/Exception/HubspotExceptionTest.php @@ -20,7 +20,7 @@ */ class HubspotExceptionTest extends TestCase { - const EXAMPLE_TOKEN = '8907e60c-600d-4af8-a987-191c104a215c'; + public const EXAMPLE_TOKEN = '8907e60c-600d-4af8-a987-191c104a215c'; /** @test */ public function createExceptionFromGuzzleRequestException() From aec877d7210cf466f876601115b0d2c919b40c9e Mon Sep 17 00:00:00 2001 From: ksvirkou Date: Tue, 21 Dec 2021 10:57:44 +0300 Subject: [PATCH 4/6] update tests --- .gitignore | 2 ++ tests/Integration/Abstraction/BlogPostTestCase.php | 2 +- tests/Integration/Abstraction/ContactListsTestCase.php | 2 +- tests/Integration/Abstraction/CrmPipelinesTestCase.php | 2 +- tests/Integration/Abstraction/DefaultTestCase.php | 6 +++--- tests/Integration/Abstraction/EntityTestCase.php | 4 ++-- tests/Integration/Abstraction/HubDBRowTestCase.php | 2 +- tests/Integration/Abstraction/TimelineTestCase.php | 2 +- .../Integration/Abstraction/TimelineWithProprtyTestCase.php | 4 ++-- tests/Integration/Resources/BlogCommentsTest.php | 4 ++-- tests/Integration/Resources/CalendarEventsTest.php | 2 +- tests/Integration/Resources/CompaniesTest.php | 2 +- tests/Integration/Resources/ContactDinamicListsTest.php | 2 +- tests/Integration/Resources/EmailEventsTest.php | 4 ++-- tests/Integration/Resources/EmailSubscriptionTest.php | 4 ++-- tests/Integration/Resources/EngagementsTest.php | 4 ++-- tests/Integration/Resources/EventsTest.php | 4 ++-- tests/Integration/Resources/HubDBRowTest.php | 2 +- tests/Integration/Resources/IntegrationTest.php | 4 ++-- tests/Integration/Resources/KeywordsTest.php | 4 ++-- tests/Integration/Resources/LineItemsTest.php | 4 ++-- tests/Integration/Resources/ObjectPropertiesTest.php | 2 +- tests/Integration/Resources/ObjectPropertyGroupsTest.php | 2 +- tests/Integration/Resources/OwnersTest.php | 4 ++-- tests/unit/Support/QueryBuilderTest.php | 2 +- tests/unit/Utils/OAuth2Test.php | 2 +- tests/unit/Utils/WebhooksTest.php | 2 +- 27 files changed, 41 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index 3e0a7385..386b8975 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ test.php .php_cs-fixer .php-cs-fixer.cache + +.phpunit.result.cache diff --git a/tests/Integration/Abstraction/BlogPostTestCase.php b/tests/Integration/Abstraction/BlogPostTestCase.php index f39b3e5c..67b6cafb 100644 --- a/tests/Integration/Abstraction/BlogPostTestCase.php +++ b/tests/Integration/Abstraction/BlogPostTestCase.php @@ -14,7 +14,7 @@ abstract class BlogPostTestCase extends EntityTestCase protected $authorId; - public function setUp() + public function setUp(): void { $blogs = new Blogs(new Client(['key' => getenv($this->key)])); $this->blogId = $blogs->all(['limit' => 1])->objects[0]->id; diff --git a/tests/Integration/Abstraction/ContactListsTestCase.php b/tests/Integration/Abstraction/ContactListsTestCase.php index 212b0b1b..1949ddd3 100644 --- a/tests/Integration/Abstraction/ContactListsTestCase.php +++ b/tests/Integration/Abstraction/ContactListsTestCase.php @@ -22,7 +22,7 @@ abstract class ContactListsTestCase extends EntityTestCase */ protected $dynamic = true; - public function setUp() + public function setUp(): void { if (empty(getenv('HUBSPOT_TEST_PORTAL_ID'))) { throw new Exception('Invalid Portal Id (HUBSPOT_TEST_PORTAL_ID)'); diff --git a/tests/Integration/Abstraction/CrmPipelinesTestCase.php b/tests/Integration/Abstraction/CrmPipelinesTestCase.php index 010e05f2..6effe6b6 100644 --- a/tests/Integration/Abstraction/CrmPipelinesTestCase.php +++ b/tests/Integration/Abstraction/CrmPipelinesTestCase.php @@ -25,7 +25,7 @@ class CrmPipelinesTestCase extends EntityTestCase */ protected $resourceClass = CrmPipelines::class; - public function setUp() + public function setUp(): void { if (empty($this->resource)) { $this->resource = new $this->resourceClass($this->getClient(), $this->type); diff --git a/tests/Integration/Abstraction/DefaultTestCase.php b/tests/Integration/Abstraction/DefaultTestCase.php index b7d895a9..945f7379 100644 --- a/tests/Integration/Abstraction/DefaultTestCase.php +++ b/tests/Integration/Abstraction/DefaultTestCase.php @@ -2,14 +2,14 @@ namespace SevenShores\Hubspot\Tests\Integration\Abstraction; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use SevenShores\Hubspot\Http\Client; /** * @internal * @coversNothing */ -class DefaultTestCase extends PHPUnit_Framework_TestCase +class DefaultTestCase extends TestCase { /** * @var null|SevenShores\Hubspot\Resources\Resource @@ -26,7 +26,7 @@ class DefaultTestCase extends PHPUnit_Framework_TestCase */ protected $key = 'HUBSPOT_TEST_API_KEY'; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Integration/Abstraction/EntityTestCase.php b/tests/Integration/Abstraction/EntityTestCase.php index bb4765f9..007b876b 100644 --- a/tests/Integration/Abstraction/EntityTestCase.php +++ b/tests/Integration/Abstraction/EntityTestCase.php @@ -9,7 +9,7 @@ abstract class EntityTestCase extends DefaultTestCase */ protected $entity; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -17,7 +17,7 @@ public function setUp() sleep(1); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); if (!empty($this->entity)) { diff --git a/tests/Integration/Abstraction/HubDBRowTestCase.php b/tests/Integration/Abstraction/HubDBRowTestCase.php index cfc58bd7..ac21f027 100644 --- a/tests/Integration/Abstraction/HubDBRowTestCase.php +++ b/tests/Integration/Abstraction/HubDBRowTestCase.php @@ -22,7 +22,7 @@ abstract class HubDBRowTestCase extends EntityTestCase */ protected $portalId; - public function setUp() + public function setUp(): void { if (empty(getenv('HUBSPOT_TEST_PORTAL_ID'))) { throw new Exception('Invalid Portal Id (HUBSPOT_TEST_PORTAL_ID)'); diff --git a/tests/Integration/Abstraction/TimelineTestCase.php b/tests/Integration/Abstraction/TimelineTestCase.php index d8e16251..011ff9fd 100644 --- a/tests/Integration/Abstraction/TimelineTestCase.php +++ b/tests/Integration/Abstraction/TimelineTestCase.php @@ -27,7 +27,7 @@ abstract class TimelineTestCase extends EntityTestCase */ protected $appId; - public function setUp() + public function setUp(): void { if (empty(getenv('HUBSPOT_TEST_APP_ID'))) { throw new Exception('Invalid Application Id (HUBSPOT_TEST_APP_ID)'); diff --git a/tests/Integration/Abstraction/TimelineWithProprtyTestCase.php b/tests/Integration/Abstraction/TimelineWithProprtyTestCase.php index 5e3a327d..98fdef19 100644 --- a/tests/Integration/Abstraction/TimelineWithProprtyTestCase.php +++ b/tests/Integration/Abstraction/TimelineWithProprtyTestCase.php @@ -9,13 +9,13 @@ abstract class TimelineWithProprtyTestCase extends TimelineTestCase */ protected $property; - public function setUp() + public function setUp(): void { parent::setUp(); $this->property = $this->createProperty(); } - public function tearDown() + public function tearDown(): void { if (!empty($this->property)) { $this->deleteProperty(); diff --git a/tests/Integration/Resources/BlogCommentsTest.php b/tests/Integration/Resources/BlogCommentsTest.php index 479a0014..dfa81f34 100644 --- a/tests/Integration/Resources/BlogCommentsTest.php +++ b/tests/Integration/Resources/BlogCommentsTest.php @@ -33,14 +33,14 @@ class BlogCommentsTest extends BlogPostTestCase */ protected $post; - public function setUp() + public function setUp(): void { $this->blogPostsResource = new BlogPosts(new Client(['key' => getenv($this->key)])); parent::setUp(); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); if (!empty($this->post)) { diff --git a/tests/Integration/Resources/CalendarEventsTest.php b/tests/Integration/Resources/CalendarEventsTest.php index 9af08fcb..adc29a6d 100644 --- a/tests/Integration/Resources/CalendarEventsTest.php +++ b/tests/Integration/Resources/CalendarEventsTest.php @@ -33,7 +33,7 @@ class CalendarEventsTest extends EntityTestCase */ protected $owner; - public function setUp() + public function setUp(): void { $this->ownersResource = new Owners($this->getClient()); $response = $this->ownersResource->all(['email' => getenv('HUBSPOT_TEST_EMAIL')]); diff --git a/tests/Integration/Resources/CompaniesTest.php b/tests/Integration/Resources/CompaniesTest.php index 369d5235..e7c7873d 100644 --- a/tests/Integration/Resources/CompaniesTest.php +++ b/tests/Integration/Resources/CompaniesTest.php @@ -31,7 +31,7 @@ class CompaniesTest extends EntityTestCase */ protected $contactsResource; - public function setUp() + public function setUp(): void { $this->contactsResource = new Contacts($this->getClient()); parent::setUp(); diff --git a/tests/Integration/Resources/ContactDinamicListsTest.php b/tests/Integration/Resources/ContactDinamicListsTest.php index a1a7e460..11d971f4 100644 --- a/tests/Integration/Resources/ContactDinamicListsTest.php +++ b/tests/Integration/Resources/ContactDinamicListsTest.php @@ -21,7 +21,7 @@ class ContactDinamicListsTest extends ContactListsTestCase */ protected $contactsResource; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Integration/Resources/EmailEventsTest.php b/tests/Integration/Resources/EmailEventsTest.php index eec26bc0..5a81b5ea 100644 --- a/tests/Integration/Resources/EmailEventsTest.php +++ b/tests/Integration/Resources/EmailEventsTest.php @@ -9,11 +9,11 @@ * @internal * @coversNothing */ -class EmailEventsTest extends \PHPUnit_Framework_TestCase +class EmailEventsTest extends \PHPUnit\Framework\TestCase { protected $resource; - public function setUp() + public function setUp(): void { parent::setUp(); $this->resource = new EmailEvents(new Client(['key' => getenv('HUBSPOT_TEST_API_KEY')])); diff --git a/tests/Integration/Resources/EmailSubscriptionTest.php b/tests/Integration/Resources/EmailSubscriptionTest.php index 29de3573..7b412e7f 100644 --- a/tests/Integration/Resources/EmailSubscriptionTest.php +++ b/tests/Integration/Resources/EmailSubscriptionTest.php @@ -9,14 +9,14 @@ * @internal * @coversNothing */ -class EmailSubscriptionTest extends \PHPUnit_Framework_TestCase +class EmailSubscriptionTest extends \PHPUnit\Framework\TestCase { /** * @var Email */ protected $resource; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/Integration/Resources/EngagementsTest.php b/tests/Integration/Resources/EngagementsTest.php index 9d622400..c37b39a2 100644 --- a/tests/Integration/Resources/EngagementsTest.php +++ b/tests/Integration/Resources/EngagementsTest.php @@ -32,7 +32,7 @@ class EngagementsTest extends EntityTestCase */ protected $contact; - public function setUp() + public function setUp(): void { $this->contactsResource = new Contacts($this->getClient()); @@ -42,7 +42,7 @@ public function setUp() parent::setUp(); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); if (!empty($this->contact)) { diff --git a/tests/Integration/Resources/EventsTest.php b/tests/Integration/Resources/EventsTest.php index e4281917..745befd0 100644 --- a/tests/Integration/Resources/EventsTest.php +++ b/tests/Integration/Resources/EventsTest.php @@ -9,11 +9,11 @@ * @internal * @coversNothing */ -class EventsTest extends \PHPUnit_Framework_TestCase +class EventsTest extends \PHPUnit\Framework\TestCase { private $events; - public function setUp() + public function setUp(): void { parent::setUp(); $this->events = new Events(new Client(['key' => getenv('HUBSPOT_TEST_API_KEY')])); diff --git a/tests/Integration/Resources/HubDBRowTest.php b/tests/Integration/Resources/HubDBRowTest.php index 551b4cd6..bb76c17b 100644 --- a/tests/Integration/Resources/HubDBRowTest.php +++ b/tests/Integration/Resources/HubDBRowTest.php @@ -15,7 +15,7 @@ class HubDBRowTest extends HubDBRowTestCase */ protected $row; - public function setUp() + public function setUp(): void { parent::setUp(); $this->row = $this->createRow(); diff --git a/tests/Integration/Resources/IntegrationTest.php b/tests/Integration/Resources/IntegrationTest.php index a5539a94..c0f9da44 100644 --- a/tests/Integration/Resources/IntegrationTest.php +++ b/tests/Integration/Resources/IntegrationTest.php @@ -13,14 +13,14 @@ * @internal * @coversNothing */ -class IntegrationTest extends \PHPUnit_Framework_TestCase +class IntegrationTest extends \PHPUnit\Framework\TestCase { /** * @var Integration */ private $integration; - public function setUp() + public function setUp(): void { parent::setUp(); $this->integration = new Integration(new Client(['key' => getenv('HUBSPOT_TEST_API_KEY')])); diff --git a/tests/Integration/Resources/KeywordsTest.php b/tests/Integration/Resources/KeywordsTest.php index d432471a..3175cfc8 100644 --- a/tests/Integration/Resources/KeywordsTest.php +++ b/tests/Integration/Resources/KeywordsTest.php @@ -9,11 +9,11 @@ * @internal * @coversNothing */ -class KeywordsTest extends \PHPUnit_Framework_TestCase +class KeywordsTest extends \PHPUnit\Framework\TestCase { private $keywords; - public function setUp() + public function setUp(): void { parent::setUp(); $this->markTestSkipped(); // TODO: fix test diff --git a/tests/Integration/Resources/LineItemsTest.php b/tests/Integration/Resources/LineItemsTest.php index c34067fd..4d1e7727 100644 --- a/tests/Integration/Resources/LineItemsTest.php +++ b/tests/Integration/Resources/LineItemsTest.php @@ -35,14 +35,14 @@ class LineItemsTest extends EntityTestCase */ protected $product; - public function setUp() + public function setUp(): void { $this->product = $this->createProduct(); parent::setUp(); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); diff --git a/tests/Integration/Resources/ObjectPropertiesTest.php b/tests/Integration/Resources/ObjectPropertiesTest.php index db501877..350cb54b 100644 --- a/tests/Integration/Resources/ObjectPropertiesTest.php +++ b/tests/Integration/Resources/ObjectPropertiesTest.php @@ -16,7 +16,7 @@ class ObjectPropertiesTest extends PropertiesTestCase */ protected $groupName = 'productinformation'; - public function setUp() + public function setUp(): void { $this->resource = Factory::create(getenv('HUBSPOT_TEST_API_KEY'))->objectProperties('products'); sleep(1); diff --git a/tests/Integration/Resources/ObjectPropertyGroupsTest.php b/tests/Integration/Resources/ObjectPropertyGroupsTest.php index 629f6a3f..4d6bfa00 100644 --- a/tests/Integration/Resources/ObjectPropertyGroupsTest.php +++ b/tests/Integration/Resources/ObjectPropertyGroupsTest.php @@ -16,7 +16,7 @@ class ObjectPropertyGroupsTest extends PropertyGroupsTestCase */ protected $getGroup = true; - public function setUp() + public function setUp(): void { $this->resource = Factory::create(getenv('HUBSPOT_TEST_API_KEY'))->objectProperties('products'); sleep(1); diff --git a/tests/Integration/Resources/OwnersTest.php b/tests/Integration/Resources/OwnersTest.php index b5278604..4bad0a40 100644 --- a/tests/Integration/Resources/OwnersTest.php +++ b/tests/Integration/Resources/OwnersTest.php @@ -13,14 +13,14 @@ * @internal * @coversNothing */ -class OwnersTest extends \PHPUnit_Framework_TestCase +class OwnersTest extends \PHPUnit\Framework\TestCase { /** * @var Owners */ protected $owners; - public function setUp() + public function setUp(): void { parent::setUp(); $this->owners = new Owners(new Client(['key' => getenv('HUBSPOT_TEST_API_KEY')])); diff --git a/tests/unit/Support/QueryBuilderTest.php b/tests/unit/Support/QueryBuilderTest.php index 2182c1d3..36af5e8d 100644 --- a/tests/unit/Support/QueryBuilderTest.php +++ b/tests/unit/Support/QueryBuilderTest.php @@ -6,7 +6,7 @@ * @internal * @coversNothing */ -class QueryBuilderTest extends \PHPUnit_Framework_TestCase +class QueryBuilderTest extends \PHPUnit\Framework\TestCase { /** * @test diff --git a/tests/unit/Utils/OAuth2Test.php b/tests/unit/Utils/OAuth2Test.php index 059c784e..a314721d 100644 --- a/tests/unit/Utils/OAuth2Test.php +++ b/tests/unit/Utils/OAuth2Test.php @@ -8,7 +8,7 @@ * @internal * @coversNothing */ -class OAuth2Test extends \PHPUnit_Framework_TestCase +class OAuth2Test extends \PHPUnit\Framework\TestCase { /** @test */ public function buildAuthorizationUrl() diff --git a/tests/unit/Utils/WebhooksTest.php b/tests/unit/Utils/WebhooksTest.php index a68e163b..37659418 100644 --- a/tests/unit/Utils/WebhooksTest.php +++ b/tests/unit/Utils/WebhooksTest.php @@ -8,7 +8,7 @@ * @internal * @coversNothing */ -class WebhooksTest extends \PHPUnit_Framework_TestCase +class WebhooksTest extends \PHPUnit\Framework\TestCase { protected $secret = 'clientSecret'; protected $requestBody = 'SomeBody'; From 58f63007b9a2e4ab30b3f3b8b5b83fc35ed05b96 Mon Sep 17 00:00:00 2001 From: ksvirkou Date: Wed, 22 Dec 2021 16:32:43 +0300 Subject: [PATCH 5/6] update tests --- phpunit.xml | 42 ++++++++----------- tests/unit/Exception/HubspotExceptionTest.php | 10 ++--- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 1d9717e1..9ac4fc61 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,27 +1,19 @@ - - - - ./tests - - - ./tests/unit - - - ./tests/Integration - - - - - ./src/ - - + + + + ./src/ + + + + + ./tests + + + ./tests/unit + + + ./tests/Integration + + diff --git a/tests/unit/Exception/HubspotExceptionTest.php b/tests/unit/Exception/HubspotExceptionTest.php index 54deeecd..64a92fbe 100644 --- a/tests/unit/Exception/HubspotExceptionTest.php +++ b/tests/unit/Exception/HubspotExceptionTest.php @@ -9,7 +9,7 @@ use GuzzleHttp\Exception\ServerException; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; -use function GuzzleHttp\Psr7\stream_for; +use GuzzleHttp\Psr7\Utils; use PHPUnit\Framework\TestCase; use SevenShores\Hubspot\Exceptions\BadRequest; use SevenShores\Hubspot\Exceptions\HubspotException; @@ -44,14 +44,14 @@ public function createExceptionFromGuzzleClientException() new Response( 400, [], - stream_for('{"status":"error","message":"xyz"}') + Utils::streamFor('{"status":"error","message":"xyz"}') ) ); $hubspotException = BadRequest::create($e); $this->assertInstanceOf(BadRequest::class, $hubspotException); - $this->assertNotContains(static::EXAMPLE_TOKEN, $hubspotException->getMessage()); + $this->assertStringNotContainsString(static::EXAMPLE_TOKEN, $hubspotException->getMessage()); $this->assertSame($e->getResponse(), $hubspotException->getResponse()); $this->assertSame('Client error: `GET https://api.hubapi.com/deals/v1/deal/12345?access_token=***` resulted in a `400 Bad Request` response: {"status":"error","message":"xyz"} @@ -69,7 +69,7 @@ public function createExceptionFromGuzzleServerException() new Response( 502, [], - stream_for(' + Utils::streamFor(' ') ) ); @@ -77,7 +77,7 @@ public function createExceptionFromGuzzleServerException() $hubspotException = HubspotException::create($e); $this->assertInstanceOf(HubspotException::class, $hubspotException); - $this->assertNotContains(static::EXAMPLE_TOKEN, $hubspotException->getMessage()); + $this->assertStringNotContainsString(static::EXAMPLE_TOKEN, $hubspotException->getMessage()); $this->assertSame($e->getResponse(), $hubspotException->getResponse()); $this->assertSame('Server error: `GET https://api.hubapi.com/deals/v1/deal/12345?hapikey=***` resulted in a `502 Bad Gateway` response: From d1754b231325de12a0d3fd638126288f3af9c0bf Mon Sep 17 00:00:00 2001 From: ksvirkou Date: Wed, 5 Jan 2022 11:47:47 +0300 Subject: [PATCH 6/6] update change log --- CHANGELOG.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95eb415d..b3df2359 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,16 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [Unreleased](https://github.com/HubSpot/hubspot-php/compare/v3.2.1...HEAD) +## [Unreleased](https://github.com/HubSpot/hubspot-php/compare/v4.0.0...HEAD) + +## [4.0.0] + +### Changed +- Update Guzzle version (^7.3) +- Update Php version (>=7.3) +- Update Php cs fixer (^3.4) +- Update Phpunit (^9.5) +- Update Phpspec (^7.1) ## [3.2.1]