-
Notifications
You must be signed in to change notification settings - Fork 2
/
SearchTest.php
49 lines (36 loc) · 1.53 KB
/
SearchTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
beforeEach(function () {
getAPI();
});
test('Can search all records for SalesforcePhp', function () {
$api = getAPI();
$results = $api->search('SalesforcePhp');
expect($results['searchRecords'])->not()->toBeEmpty();
});
test('Can search just accounts for SalesforcePhp', function () {
$api = getAPI();
$results = $api->searchIn('SalesforcePhp', 'Account');
expect($results['searchRecords'])->not()->toBeEmpty();
});
test('Can search just accounts and supply additional fields to select', function () {
$api = getAPI();
$results = $api->searchIn('SalesforcePhp', 'Account', ['Name']);
expect($results['searchRecords'])->not()->toBeEmpty();
expect($results['searchRecords'][0])->toHaveKey('Name');
});
test('Can search using helper function searchObjectWhereProperties', function () {
$api = getAPI();
$results = $api->searchObjectWhereProperties('Account', ['name' => 'SalesforcePhp Test'], ['Id', 'Name']);
expect($results)->not()->toBeEmpty();
expect($results[0])->toHaveKey('Name', 'SalesforcePhp Test');
});
test('Can find a single record and return properties directly', function () {
$api = getAPI();
$result = $api->findRecord('Account', ['name' => 'SalesforcePhp Test'], ['Id', 'Name']);
expect($result)->toHaveKey('Name', 'SalesforcePhp Test');
});
test('Returns null if it fails to find a record', function () {
$api = getAPI();
$result = $api->findRecord('Account', ['name' => 'Not A Real Record'], ['Id', 'Name']);
expect($result)->toBeNull();
});