Skip to content

Commit

Permalink
Revert "Require PHP 7.3 and upgrade PHPUnit 8"
Browse files Browse the repository at this point in the history
  • Loading branch information
bkuhl authored Jan 2, 2020
1 parent fd8c9d7 commit ec642c3
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 77 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ 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.3",
"php": "^7.1",
"ql/uri-template": "^1.1",
"webmozart/assert": "^1.2",
"guzzlehttp/guzzle": "^6.3"
},
"require-dev": {
"phpunit/phpunit": "^8.4",
"phpunit/phpunit": "^7.0",
"phpstan/phpstan": "^0.10.1",
"friendsofphp/php-cs-fixer": "^2.3",
"mockery/mockery": "^1.1"
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ parameters:
# Ignore type errors for passing a Mock
- '#.*MockObject given.*#'
- '#.*MockInterface given.*#'
- '#.*does not accept PHPUnit\\Framework\\MockObject\\MockObject.*#'
9 changes: 7 additions & 2 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(): void
public function setUp()
{
$this->history = [];
$this->mockHandler = new MockHandler();
Expand Down Expand Up @@ -76,7 +76,12 @@ protected function stubResponse(Response $response): void
$this->mockHandler->append($response);
}

protected function getResponse(int $status = 200, string $body = '', array $headers = []): Response
/**
* @param int $status
* @param string $body
* @param array $headers
*/
protected function getResponse($status = 200, $body = '', $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(): void
public function setUp()
{
$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(): void
public function setUp()
{
parent::setUp();

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

$extractedConversation = $conversation->extract();

$firstLevelValues = [
$this->assertArraySubset([
'id' => 12,
'number' => 3526,
'threadCount' => 2,
Expand All @@ -264,77 +262,49 @@ public function testExtract()
'subject' => 'Help',
'preview' => 'Preview',
'mailboxId' => 13,
'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(
[
'assignee' => [
'id' => 9865,
'firstName' => 'Mr',
'lastName' => 'Robot',
],
$extractedConversation['assignee']
);

$this->assertEquals(
[
'createdBy' => [
'id' => 12,
'type' => 'customer',
],
$extractedConversation['createdBy']
);

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

$this->assertEquals(
['[email protected]'],
$extractedConversation['cc']
);

$this->assertEquals(
['[email protected]'],
$extractedConversation['bcc']
);

$this->assertEquals(152, $extractedConversation['customer']['id']);
$this->assertEquals(
'[email protected]',
$extractedConversation['customer']['email']
);

$this->assertEquals(
[
'cc' => [
'[email protected]',
],
'bcc' => [
'[email protected]',
],
'customer' => [
'id' => 152,
'email' => '[email protected]',
],
'customerWaitingSince' => [
'time' => '2012-07-24T20:18:33Z',
'friendly' => '20 hours ago',
'latestReplyFrom' => 'customer',
],
$extractedConversation['customerWaitingSince']
);

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

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

public function testExtractsThreads()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
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 MockObject */
/** @var \PHPUnit_Framework_MockObject_MockObject|Filesystem */
private $filesystem;

public function setUp(): void
public function setUp()
{
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(): void
protected function tearDown()
{
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(): void
protected function tearDown()
{
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(): void
protected function tearDown()
{
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(): void
public function setUp()
{
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(): void
public function setUp()
{
$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(): void
public function setUp()
{
$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(): void
public function setUp()
{
$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->assertStringContainsStringIgnoringCase('Support', $extracted['tags'][0]);
$this->assertContains('Support', $extracted['tags'][0]);
}
}

0 comments on commit ec642c3

Please sign in to comment.