@@ 14-67 (lines=54) @@ | ||
11 | use Yproximite\Api\Message\CallTracking\CallTrackingPostMessage; |
|
12 | use Yproximite\Api\Message\CallTracking\CallTrackingPatchMessage; |
|
13 | ||
14 | class CallTrackingServiceSpec extends ObjectBehavior |
|
15 | { |
|
16 | function it_is_initializable() |
|
17 | { |
|
18 | $this->shouldHaveType(CallTrackingService::class); |
|
19 | } |
|
20 | ||
21 | function let(Client $client, ModelFactory $factory) |
|
22 | { |
|
23 | $this->beConstructedWith($client, $factory); |
|
24 | } |
|
25 | ||
26 | function it_should_post_call_tracking( |
|
27 | Client $client, |
|
28 | ModelFactory $factory, |
|
29 | CallTrackingPostMessage $message, |
|
30 | CallTracking $callTracking |
|
31 | ) { |
|
32 | $message->getSiteId()->willReturn(1); |
|
33 | $message->build()->willReturn([]); |
|
34 | ||
35 | $method = 'POST'; |
|
36 | $path = 'sites/1/call_trackings'; |
|
37 | $data = ['api_call_tracking' => []]; |
|
38 | ||
39 | $client->sendRequest($method, $path, $data)->willReturn([]); |
|
40 | $client->sendRequest($method, $path, $data)->shouldBeCalled(); |
|
41 | ||
42 | $factory->create(CallTracking::class, [])->willReturn($callTracking); |
|
43 | ||
44 | $this->postCallTracking($message); |
|
45 | } |
|
46 | ||
47 | function it_should_patch_call_tracking( |
|
48 | Client $client, |
|
49 | ModelFactory $factory, |
|
50 | CallTrackingPatchMessage $message, |
|
51 | CallTracking $callTracking |
|
52 | ) { |
|
53 | $message->getSiteId()->willReturn(1); |
|
54 | $message->build()->willReturn([]); |
|
55 | ||
56 | $method = 'PATCH'; |
|
57 | $path = 'sites/1/call_trackings/update'; |
|
58 | $data = ['api_call_tracking_edit' => []]; |
|
59 | ||
60 | $client->sendRequest($method, $path, $data)->willReturn([]); |
|
61 | $client->sendRequest($method, $path, $data)->shouldBeCalled(); |
|
62 | ||
63 | $factory->create(CallTracking::class, [])->willReturn($callTracking); |
|
64 | ||
65 | $this->patchCallTracking($message); |
|
66 | } |
|
67 | } |
|
68 |
@@ 14-66 (lines=53) @@ | ||
11 | use Yproximite\Api\Message\Company\CompanyPostMessage; |
|
12 | use Yproximite\Api\Message\Company\CompanyPatchMessage; |
|
13 | ||
14 | class CompanyServiceSpec extends ObjectBehavior |
|
15 | { |
|
16 | function it_is_initializable() |
|
17 | { |
|
18 | $this->shouldHaveType(CompanyService::class); |
|
19 | } |
|
20 | ||
21 | function let(Client $client, ModelFactory $factory) |
|
22 | { |
|
23 | $this->beConstructedWith($client, $factory); |
|
24 | } |
|
25 | ||
26 | function it_should_post_company( |
|
27 | Client $client, |
|
28 | ModelFactory $factory, |
|
29 | CompanyPostMessage $message, |
|
30 | Company $company |
|
31 | ) { |
|
32 | $message->build()->willReturn([]); |
|
33 | ||
34 | $method = 'POST'; |
|
35 | $path = 'companies'; |
|
36 | $data = ['api_company' => []]; |
|
37 | ||
38 | $client->sendRequest($method, $path, $data)->willReturn([]); |
|
39 | $client->sendRequest($method, $path, $data)->shouldBeCalled(); |
|
40 | ||
41 | $factory->create(Company::class, [])->willReturn($company); |
|
42 | ||
43 | $this->postCompany($message); |
|
44 | } |
|
45 | ||
46 | function it_should_patch_company( |
|
47 | Client $client, |
|
48 | ModelFactory $factory, |
|
49 | CompanyPatchMessage $message, |
|
50 | Company $company |
|
51 | ) { |
|
52 | $message->getId()->willReturn(2); |
|
53 | $message->build()->willReturn([]); |
|
54 | ||
55 | $method = 'PATCH'; |
|
56 | $path = 'companies/2'; |
|
57 | $data = ['api_company' => []]; |
|
58 | ||
59 | $client->sendRequest($method, $path, $data)->willReturn([]); |
|
60 | $client->sendRequest($method, $path, $data)->shouldBeCalled(); |
|
61 | ||
62 | $factory->create(Company::class, [])->willReturn($company); |
|
63 | ||
64 | $this->patchCompany($message); |
|
65 | } |
|
66 | } |
|
67 |
@@ 14-68 (lines=55) @@ | ||
11 | use Yproximite\Api\Message\TeamWorker\TeamWorkerPostMessage; |
|
12 | use Yproximite\Api\Message\TeamWorker\TeamWorkerPatchMessage; |
|
13 | ||
14 | class TeamWorkerServiceSpec extends ObjectBehavior |
|
15 | { |
|
16 | function it_is_initializable() |
|
17 | { |
|
18 | $this->shouldHaveType(TeamWorkerService::class); |
|
19 | } |
|
20 | ||
21 | function let(Client $client, ModelFactory $factory) |
|
22 | { |
|
23 | $this->beConstructedWith($client, $factory); |
|
24 | } |
|
25 | ||
26 | function it_should_post_team_worker( |
|
27 | Client $client, |
|
28 | ModelFactory $factory, |
|
29 | TeamWorkerPostMessage $message, |
|
30 | TeamWorker $teamWorker |
|
31 | ) { |
|
32 | $message->getSiteId()->willReturn(1); |
|
33 | $message->build()->willReturn([]); |
|
34 | ||
35 | $method = 'POST'; |
|
36 | $path = 'sites/1/team_workers'; |
|
37 | $data = ['api_team_worker' => []]; |
|
38 | ||
39 | $client->sendRequest($method, $path, $data)->willReturn([]); |
|
40 | $client->sendRequest($method, $path, $data)->shouldBeCalled(); |
|
41 | ||
42 | $factory->create(TeamWorker::class, [])->willReturn($teamWorker); |
|
43 | ||
44 | $this->postTeamWorker($message); |
|
45 | } |
|
46 | ||
47 | function it_should_patch_team_worker( |
|
48 | Client $client, |
|
49 | ModelFactory $factory, |
|
50 | TeamWorkerPatchMessage $message, |
|
51 | TeamWorker $teamWorker |
|
52 | ) { |
|
53 | $message->getId()->willReturn(2); |
|
54 | $message->getSiteId()->willReturn(1); |
|
55 | $message->build()->willReturn([]); |
|
56 | ||
57 | $method = 'PATCH'; |
|
58 | $path = 'sites/1/team_workers/2'; |
|
59 | $data = ['api_team_worker' => []]; |
|
60 | ||
61 | $client->sendRequest($method, $path, $data)->willReturn([]); |
|
62 | $client->sendRequest($method, $path, $data)->shouldBeCalled(); |
|
63 | ||
64 | $factory->create(TeamWorker::class, [])->willReturn($teamWorker); |
|
65 | ||
66 | $this->patchTeamWorker($message); |
|
67 | } |
|
68 | } |
|
69 |
@@ 14-68 (lines=55) @@ | ||
11 | use Yproximite\Api\Message\User\UserPostMessage; |
|
12 | use Yproximite\Api\Message\User\UserPatchMessage; |
|
13 | ||
14 | class UserServiceSpec extends ObjectBehavior |
|
15 | { |
|
16 | function it_is_initializable() |
|
17 | { |
|
18 | $this->shouldHaveType(UserService::class); |
|
19 | } |
|
20 | ||
21 | function let(Client $client, ModelFactory $factory) |
|
22 | { |
|
23 | $this->beConstructedWith($client, $factory); |
|
24 | } |
|
25 | ||
26 | function it_should_post_user( |
|
27 | Client $client, |
|
28 | ModelFactory $factory, |
|
29 | UserPostMessage $message, |
|
30 | User $user |
|
31 | ) { |
|
32 | $message->getCompanyId()->willReturn(1); |
|
33 | $message->build()->willReturn([]); |
|
34 | ||
35 | $method = 'POST'; |
|
36 | $path = 'companies/1/users'; |
|
37 | $data = ['api_user' => []]; |
|
38 | ||
39 | $client->sendRequest($method, $path, $data)->willReturn([]); |
|
40 | $client->sendRequest($method, $path, $data)->shouldBeCalled(); |
|
41 | ||
42 | $factory->create(User::class, [])->willReturn($user); |
|
43 | ||
44 | $this->postUser($message); |
|
45 | } |
|
46 | ||
47 | function it_should_patch_user( |
|
48 | Client $client, |
|
49 | ModelFactory $factory, |
|
50 | UserPatchMessage $message, |
|
51 | User $user |
|
52 | ) { |
|
53 | $message->getId()->willReturn(2); |
|
54 | $message->getCompanyId()->willReturn(1); |
|
55 | $message->build()->willReturn([]); |
|
56 | ||
57 | $method = 'PATCH'; |
|
58 | $path = 'companies/1/users/2'; |
|
59 | $data = ['api_user' => []]; |
|
60 | ||
61 | $client->sendRequest($method, $path, $data)->willReturn([]); |
|
62 | $client->sendRequest($method, $path, $data)->shouldBeCalled(); |
|
63 | ||
64 | $factory->create(User::class, [])->willReturn($user); |
|
65 | ||
66 | $this->patchUser($message); |
|
67 | } |
|
68 | } |
|
69 |