GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

TransportTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
c 2
b 0
f 0
lcom 0
cbo 7
dl 0
loc 67
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testChangingToken() 0 64 1
1
<?php
2
3
namespace prgTW\BaseCRM\Tests\Transport;
4
5
use prgTW\BaseCRM\BaseCrm;
6
use prgTW\BaseCRM\Client\GuzzleClient;
7
use prgTW\BaseCRM\Resource\Resource;
8
use prgTW\BaseCRM\Tests\AbstractTest;
9
use prgTW\BaseCRM\Transport\Transport;
10
11
class TransportTest extends AbstractTest
12
{
13
	public function testChangingToken()
14
	{
15
		$accountResponse = '
16
			{
17
				"account": {
18
					"id": 123,
19
					"name": "myaccount",
20
					"timezone": "UTC",
21
					"currency_name": "US Dollar"
22
				}
23
			}
24
		';
25
26
		$client = \Mockery::mock(GuzzleClient::class);
27
		$client
28
			->shouldReceive('request')
29
			->once()
30
			->with('GET', sprintf('%s/%s/account.json', Resource::ENDPOINT_SALES, Resource::PREFIX), [
31
				'headers' => [
32
					Transport::TOKEN_PIPEJUMP_NAME     => '',
33
					Transport::TOKEN_FUTUERSIMPLE_NAME => '',
34
				],
35
			])
36
			->andReturn($this->getResponse(200, $accountResponse));
37
		$baseCrm = new BaseCrm('', $client);
38
39
		$baseCrm->getAccount()->get();
40
41
		$client
42
			->shouldReceive('request')
43
			->once()
44
			->with('GET', sprintf('%s/%s/account.json', Resource::ENDPOINT_SALES, Resource::PREFIX), [
45
				'headers' => [
46
					Transport::TOKEN_PIPEJUMP_NAME     => 'astalavista',
47
					Transport::TOKEN_FUTUERSIMPLE_NAME => 'astalavista',
48
				],
49
			])
50
			->andReturn($this->getResponse(200, $accountResponse));
51
52
		$baseCrm->setToken('astalavista');
53
		$this->assertEquals('astalavista', $baseCrm->getToken());
54
		$account = $baseCrm->getAccount()->get();
55
56
		$client
57
			->shouldReceive('request')
58
			->once()
59
			->with('PUT', sprintf('%s/%s/account.json', Resource::ENDPOINT_SALES, Resource::PREFIX), [
60
				'headers' => [
61
					Transport::TOKEN_PIPEJUMP_NAME     => 'baby',
62
					Transport::TOKEN_FUTUERSIMPLE_NAME => 'baby',
63
				],
64
				'query' => [
65
					'account' => [
66
						'name' => 'new_name',
67
					],
68
				],
69
			])
70
			->andReturn($this->getResponse(200, $accountResponse));
71
72
		$account->name = 'new_name';
73
		$account->getTransport()->setToken('baby');
74
		$this->assertEquals('baby', $account->getTransport()->getToken());
75
		$account->save(['name']);
76
	}
77
}
78