Skip to content

Commit

Permalink
Merge pull request #123 from griffithben/fix/v2-setting-assignee-conf…
Browse files Browse the repository at this point in the history
…usion

Refactor method names to reflect functionality for assigning convos
  • Loading branch information
bkuhl authored Apr 9, 2019
2 parents 20f4165 + 144e6f1 commit ebd04be
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"scripts": {
"analyse": "vendor/bin/phpstan analyse src tests --level=5",
"fix": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
"sniff": "vendor/bin/php-cs-fixer fix --allow-risky=yes --dry-run --stop-on-violation",
"sniff": "vendor/bin/php-cs-fixer fix --allow-risky=yes --dry-run --stop-on-violation --verbose",
"phpunit": "vendor/bin/phpunit",
"phpunit:clover": "vendor/bin/phpunit --coverage-clover build/logs/clover.xml",
"test": ["@sniff", "@analyse", "@phpunit"],
Expand Down
1 change: 1 addition & 0 deletions src/Conversations/Conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ public function isAssigned(): bool
public function setAssignee(?User $assignee): Conversation
{
$this->assignee = $assignee;
$this->setAssignTo($assignee->getId());

return $this;
}
Expand Down
22 changes: 19 additions & 3 deletions tests/Conversations/ConversationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function testExtract()
$conversation->setId(12);
$conversation->setNumber(3526);
$conversation->setThreadCount(2);
$conversation->setAssignTo(2942);
$conversation->setAssignTo(9865);
$conversation->withAutoRepliesEnabled();
$conversation->setType('email');
$conversation->setImported(true);
Expand Down Expand Up @@ -239,7 +239,7 @@ public function testExtract()
'threadCount' => 2,
'autoReply' => true,
'type' => 'email',
'assignTo' => 2942,
'assignTo' => 9865,
'imported' => true,
'folderId' => 132,
'status' => 'closed',
Expand Down Expand Up @@ -335,6 +335,20 @@ public function testExtractNewEntity()
], $conversation->extract());
}

/**
* See https://github.com/helpscout/helpscout-api-php/issues/111.
*/
public function testSettingAssigneeAlsoSetsAssignToId()
{
$convo = new Conversation();

$assignee = new User();
$assignee->setId(41);
$convo->setAssignee($assignee);

$this->assertSame($assignee->getId(), $convo->getAssignTo());
}

public function testChatConvo()
{
$convo = new ChatConversation();
Expand Down Expand Up @@ -376,7 +390,9 @@ public function testStatusMethods()
$this->assertNull($convo->getAssignee());
$this->assertFalse($convo->isAssigned());

$convo->assignTo(new User());
$user = new User();
$user->setId(1);
$convo->assignTo($user);
$this->assertTrue($convo->isAssigned());

$convo->publish();
Expand Down

0 comments on commit ebd04be

Please sign in to comment.