Skip to content

Commit

Permalink
Merge pull request #374 from HubSpot/v4
Browse files Browse the repository at this point in the history
merge v4 to master
  • Loading branch information
ksvirkou-hubspot authored Jan 5, 2022
2 parents 496d226 + d1754b2 commit f1963fd
Show file tree
Hide file tree
Showing 38 changed files with 130 additions and 122 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ test.php
.phpintel
/nbproject

.php_cs
.php_cs.cache
.php_cs-fixer
.php-cs-fixer.cache

.phpunit.result.cache
3 changes: 2 additions & 1 deletion .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
->notPath('/cache/')
;

return PhpCsFixer\Config::create()
$config = new PhpCsFixer\Config();
return $config
->setFinder($finder)
->setRules([
'@PSR2' => true,
Expand Down
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
42 changes: 17 additions & 25 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="./vendor/autoload.php">
<testsuites>
<testsuite name="All">
<directory>./tests</directory>
</testsuite>
<testsuite name="Unit">
<directory>./tests/unit</directory>
</testsuite>
<testsuite name="Integration">
<directory>./tests/Integration</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="./vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">./src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="All">
<directory>./tests</directory>
</testsuite>
<testsuite name="Unit">
<directory>./tests/unit</directory>
</testsuite>
<testsuite name="Integration">
<directory>./tests/Integration</directory>
</testsuite>
</testsuites>
</phpunit>
76 changes: 38 additions & 38 deletions src/Resources/CrmAssociations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/OAuth2.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Abstraction/BlogPostTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Abstraction/ContactListsTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)');
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Abstraction/CrmPipelinesTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/Abstraction/DefaultTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Abstraction/EntityTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ abstract class EntityTestCase extends DefaultTestCase
*/
protected $entity;

public function setUp()
public function setUp(): void
{
parent::setUp();

$this->entity = $this->createEntity();
sleep(1);
}

public function tearDown()
public function tearDown(): void
{
parent::tearDown();
if (!empty($this->entity)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Abstraction/HubDBRowTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)');
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Abstraction/TimelineTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)');
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Abstraction/TimelineWithProprtyTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Resources/BlogCommentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Resources/CalendarEventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')]);
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Resources/CompaniesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Resources/ContactDinamicListsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ContactDinamicListsTest extends ContactListsTestCase
*/
protected $contactsResource;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Resources/ContactsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Resources/EcommerceBridgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
class EcommerceBridgeTest extends DefaultTestCase
{
const STORE_ID = 'ecommercebridge-test-store';
public const STORE_ID = 'ecommercebridge-test-store';

/**
* @var EcommerceBridge
Expand Down
Loading

0 comments on commit f1963fd

Please sign in to comment.