Skip to content

Commit

Permalink
Merge pull request #214 from helpscout/require-php-73
Browse files Browse the repository at this point in the history
Require PHP 7.3 and upgrade PHPUnit 8
  • Loading branch information
bkuhl committed Jan 2, 2020
2 parents e98660c + f5be1d2 commit fd8c9d7
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 54 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ env:
language: php

php:
- 7.1
- 7.2
- 7.3

before_script:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
}
],
"require": {
"php": "^7.1",
"php": "^7.3",
"ql/uri-template": "^1.1",
"webmozart/assert": "^1.2",
"guzzlehttp/guzzle": "^6.3"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"phpunit/phpunit": "^8.4",
"phpstan/phpstan": "^0.10.1",
"friendsofphp/php-cs-fixer": "^2.3",
"mockery/mockery": "^1.1"
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ parameters:
# Ignore type errors for passing a Mock
- '#.*MockObject given.*#'
- '#.*MockInterface given.*#'
- '#.*does not accept PHPUnit\\Framework\\MockObject\\MockObject.*#'
9 changes: 2 additions & 7 deletions tests/ApiClientIntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class ApiClientIntegrationTestCase extends TestCase
*/
protected $client;

public function setUp()
public function setUp(): void
{
$this->history = [];
$this->mockHandler = new MockHandler();
Expand Down Expand Up @@ -76,12 +76,7 @@ protected function stubResponse(Response $response): void
$this->mockHandler->append($response);
}

/**
* @param int $status
* @param string $body
* @param array $headers
*/
protected function getResponse($status = 200, $body = '', $headers = []): Response
protected function getResponse(int $status = 200, string $body = '', array $headers = []): Response
{
return new Response($status, $headers, $body);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ApiClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ApiClientTest extends TestCase
*/
private $guzzle;

public function setUp()
public function setUp(): void
{
$this->authenticator = Mockery::mock(Authenticator::class);
$this->guzzle = Mockery::mock(Client::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/Authentication/AuthenticationIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AuthenticationIntegrationTest extends ApiClientIntegrationTestCase
{
protected $guzzle;

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

Expand Down
90 changes: 60 additions & 30 deletions tests/Conversations/ConversationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ public function testExtract()
);
$conversation->setCustomerWaitingSince($customerWaitingSince);

$this->assertArraySubset([
$extractedConversation = $conversation->extract();

$firstLevelValues = [
'id' => 12,
'number' => 3526,
'threadCount' => 2,
Expand All @@ -262,49 +264,77 @@ public function testExtract()
'subject' => 'Help',
'preview' => 'Preview',
'mailboxId' => 13,
'assignee' => [
'createdAt' => '2017-04-21T14:39:56Z',
'closedAt' => '2017-04-21T12:23:06Z',
'closedBy' => 14,
'userUpdatedAt' => '2017-04-21T03:12:06Z',
];

$this->assertEquals(
$firstLevelValues,
array_intersect_assoc($extractedConversation, $firstLevelValues)
);

$this->assertEquals(
[
'id' => 9865,
'firstName' => 'Mr',
'lastName' => 'Robot',
],
'createdBy' => [
$extractedConversation['assignee']
);

$this->assertEquals(
[
'id' => 12,
'type' => 'customer',
],
'createdAt' => '2017-04-21T14:39:56Z',
'closedAt' => '2017-04-21T12:23:06Z',
'closedBy' => 14,
'userUpdatedAt' => '2017-04-21T03:12:06Z',
'source' => [
$extractedConversation['createdBy']
);

$this->assertEquals(
[
'type' => 'email',
'via' => 'customer',
],
'cc' => [
'bear@normal.com',
],
'bcc' => [
'bear@secret.com',
],
'customer' => [
'id' => 152,
'email' => 'mycustomer@domain.com',
],
'customerWaitingSince' => [
$extractedConversation['source']
);

$this->assertEquals(
['bear@normal.com'],
$extractedConversation['cc']
);

$this->assertEquals(
['bear@secret.com'],
$extractedConversation['bcc']
);

$this->assertEquals(152, $extractedConversation['customer']['id']);
$this->assertEquals(
'mycustomer@domain.com',
$extractedConversation['customer']['email']
);

$this->assertEquals(
[
'time' => '2012-07-24T20:18:33Z',
'friendly' => '20 hours ago',
'latestReplyFrom' => 'customer',
],
'tags' => [
'Productive',
],
'fields' => [
[
'id' => 936,
'name' => 'Account Type',
'value' => 'Administrator',
],
],
], $conversation->extract());
$extractedConversation['customerWaitingSince']
);

$this->assertEquals(['Productive'], $extractedConversation['tags']);

$this->assertEquals(
[[
'id' => 936,
'name' => 'Account Type',
'value' => 'Administrator',
]],
$extractedConversation['fields']
);
}

public function testExtractsThreads()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
use HelpScout\Api\Conversations\Threads\Attachments\AttachmentFactory;
use HelpScout\Api\Exception\RuntimeException;
use HelpScout\Api\Support\Filesystem;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class AttachmentFactoryTest extends TestCase
{
/** @var AttachmentFactory */
private $factory;

/** @var \PHPUnit_Framework_MockObject_MockObject|Filesystem */
/** @var MockObject */
private $filesystem;

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

Expand Down
2 changes: 1 addition & 1 deletion tests/Conversations/Threads/Support/HasCustomerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class HasCustomerTest extends TestCase
{
use HasCustomer;

protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class HasPartiesToBeNotifiedTest extends TestCase
{
use HasPartiesToBeNotified;

protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();

Expand Down
2 changes: 1 addition & 1 deletion tests/Conversations/Threads/Support/HasUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class HasUserTest extends TestCase
{
use HasUser;

protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();

Expand Down
2 changes: 1 addition & 1 deletion tests/Conversations/Threads/ThreadFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ThreadFactoryTest extends TestCase
/** @var ThreadFactory */
private $factory;

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

Expand Down
2 changes: 1 addition & 1 deletion tests/Entity/PagedCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PagedCollectionTest extends TestCase
*/
private $collection;

public function setUp()
public function setUp(): void
{
$this->loadedCollection = Mockery::mock(PagedCollection::class);
$this->pageLoader = new PageLoaderStub($this->loadedCollection);
Expand Down
2 changes: 1 addition & 1 deletion tests/Http/AuthenticatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AuthenticatorTest extends TestCase
/** @var MockInterface|Mockery\LegacyMockInterface */
public $client;

public function setUp()
public function setUp(): void
{
$this->client = Mockery::mock(Client::class);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Http/RestClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RestClientTest extends TestCase
public $methodsClient;
public $authenticator;

public function setUp()
public function setUp(): void
{
$this->methodsClient = \Mockery::mock(Client::class);
$this->authenticator = \Mockery::mock(Authenticator::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/Tags/TagsCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public function testExtractsTags()

$extracted = $tagsCollection->extract();
$this->assertArrayHasKey('tags', $extracted);
$this->assertContains('Support', $extracted['tags'][0]);
$this->assertStringContainsStringIgnoringCase('Support', $extracted['tags'][0]);
}
}

0 comments on commit fd8c9d7

Please sign in to comment.