-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathActivityApiTest.php
More file actions
71 lines (57 loc) · 2.04 KB
/
Copy pathActivityApiTest.php
File metadata and controls
71 lines (57 loc) · 2.04 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use Pipedrive\versions\v1\Api\ActivitiesApi;
use Pipedrive\versions\v1\Configuration;
use Pipedrive\Tests\Unit\TestCase;
uses(TestCase::class)->group('unit');
test('list activities', function () {
$config = new Configuration();
$mock = $this->httpMock();
$mock->append(
new Response(200, [], json_encode([
'data' => [
[
'id' => 1,
'busy_flag' => true,
],
],
])),
);
$handlerStack = HandlerStack::create($mock);
$apiInstance = new ActivitiesApi(
new Client(['handler' => $handlerStack]),
$config
);
$result = $apiInstance->getActivities()->getData();
expect($result[0]->getBusyFlag())->toBe(true);
})->skip('ActivitiesApi class not found');
test('set correct activity busy_flag type', function (array $dataset) {
$config = new Configuration();
$mock = $this->httpMock();
$mock->append(
new Response(200, [], json_encode([
'data' => [
[
'id' => 1,
'busy_flag' => $dataset['busy_flag'],
],
],
])),
);
$handlerStack = HandlerStack::create($mock);
$apiInstance = new ActivitiesApi(
new Client(['handler' => $handlerStack]),
$config
);
$result = $apiInstance->getActivities()->getData();
expect($mock->getLastRequest()->getUri())->toEqual('https://api.pipedrive.com/v1/activities')
->and($result[0]->getBusyFlag())->toBe($dataset['expected']);
})->with([
'boolean (false)' => fn() => ['busy_flag' => false, 'expected' => false],
'boolean (true)' => fn() => ['busy_flag' => true, 'expected' => true],
'number (0)' => fn() => ['busy_flag' => 0, 'expected' => false],
'number (1)' => fn() => ['busy_flag' => 1, 'expected' => true],
'null' => fn() => ['busy_flag' => null, 'expected' => null],
])->skip('ActivitiesApi class not found');