Skip to content

Commit 6621a36

Browse files
author
Attila Dröszler
committed
use constants
1 parent e7f42f3 commit 6621a36

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/Suite/Api/Contact/Contact.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Contact
1010
{
1111
const FIELD_ID = 'id';
1212
const FIELD_EMAIL = 3;
13+
const FIELD_UID = 'uid';
1314

1415
/* @var Client */
1516
private $apiClient;

test/unit/Suite/Api/Contact/ContactTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ public function getData_Perfect_Perfect()
3131
];
3232

3333
$postData = [
34-
'keyId' => 'id',
34+
'keyId' => Contact::FIELD_ID,
3535
'keyValues' => [1, 2],
36-
'fields' => [3]
36+
'fields' => [Contact::FIELD_EMAIL]
3737
];
3838

3939
$this->apiClient->expects($this->once())->method('post')
4040
->with($this->endPoints->getData($this->customerId), $postData)
4141
->will($this->apiSuccess($contacts));
4242

43-
$responseData = $this->contact->getList($this->customerId, 'id', [1, 2], [3]);
43+
$responseData = $this->contact->getList($this->customerId, Contact::FIELD_ID, [1, 2], [Contact::FIELD_EMAIL]);
4444
$this->assertEquals($contacts, $responseData);
4545
}
4646

@@ -52,7 +52,7 @@ public function getData_ContactNotFound_EmptyArrayReturned()
5252
$this->apiClient->expects($this->once())->method('post')
5353
->will($this->apiSuccess([]));
5454

55-
$responseData = $this->contact->getList($this->customerId, 'id', [1, 2], [3]);
55+
$responseData = $this->contact->getList($this->customerId, Contact::FIELD_ID, [], [Contact::FIELD_EMAIL]);
5656
$this->assertEquals([], $responseData);
5757
}
5858

@@ -64,7 +64,7 @@ public function get_ApiFailure_ExceptionThrown()
6464
$this->expectApiFailure('post');
6565

6666
try {
67-
$this->contact->getList($this->customerId, 'id', [1, 2], [3]);
67+
$this->contact->getList($this->customerId, Contact::FIELD_ID, [], [Contact::FIELD_EMAIL]);
6868
} catch (RequestFailed $e) {
6969
return;
7070
}
@@ -88,9 +88,9 @@ private function apiSuccess(array $data = [])
8888
private function createContact(string $email, int $id)
8989
{
9090
return [
91-
'3'=> $email,
92-
'id' => $id,
93-
'uid'=> 'testuid'
91+
Contact::FIELD_EMAIL => $email,
92+
Contact::FIELD_ID => $id,
93+
Contact::FIELD_UID => 'testuid'
9494
];
9595
}
9696
}

0 commit comments

Comments
 (0)