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.

AccountTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testGet() 0 24 1
A testCurrencyAlteration() 0 59 1
1
<?php
2
3
namespace prgTW\BaseCRM\Tests\Service;
4
5
use prgTW\BaseCRM\BaseCrm;
6
use prgTW\BaseCRM\Client\GuzzleClient;
7
use prgTW\BaseCRM\Resource\Resource;
8
use prgTW\BaseCRM\Service\Enum\Currency;
9
use prgTW\BaseCRM\Tests\AbstractTest;
10
11
class AccountTest extends AbstractTest
12
{
13
	public function testGet()
14
	{
15
		$client = \Mockery::mock(GuzzleClient::class);
16
		$client
17
			->shouldReceive('request')
18
			->once()
19
			->with('GET', sprintf('%s/%s/account.json', Resource::ENDPOINT_SALES, Resource::PREFIX), $this->getQuery())
20
			->andReturn($this->getResponse(200, '
21
				{
22
					"account": {
23
						"id": 123,
24
						"name": "myaccount",
25
						"timezone": "UTC",
26
						"currency_name": "US Dollar"
27
					}
28
				}
29
			'));
30
		$baseCrm = new BaseCrm('', $client);
31
32
		$account = $baseCrm->getAccount();
33
		$this->assertEquals('myaccount', $account->name);
34
		$this->assertEquals('UTC', $account->timezone);
35
		$this->assertEquals(Currency::USD(), $account->currency);
36
	}
37
38
	public function testCurrencyAlteration()
39
	{
40
		$client = \Mockery::mock(GuzzleClient::class);
41
		$client
42
			->shouldReceive('request')
43
			->once()
44
			->with('GET', sprintf('%s/%s/account.json', Resource::ENDPOINT_SALES, Resource::PREFIX), $this->getQuery())
45
			->andReturn($this->getResponse(200, '
46
				{
47
					"account": {
48
						"id": 123,
49
						"name": "myaccount",
50
						"timezone": "UTC",
51
						"currency_name": "US Dollar"
52
					}
53
				}
54
			'));
55
		$baseCrm = new BaseCrm('', $client);
56
57
		$account = $baseCrm->getAccount();
58
59
		$this->assertEquals(123, $account->id);
60
		$this->assertEquals('myaccount', $account->name);
61
		$this->assertEquals('UTC', $account->timezone);
62
		$this->assertEquals(Currency::USD(), $account->currency);
63
64
		$client
65
			->shouldReceive('request')
66
			->once()
67
			->with('PUT', sprintf('%s/%s/account.json', Resource::ENDPOINT_SALES, Resource::PREFIX), $this->getQuery([
68
				'query' => [
69
					'account' => [
70
						'name'        => 'newname',
71
						'currency_id' => Currency::PLN,
72
						'timezone'    => 'new_timezone',
73
					]
74
				],
75
			]))
76
			->andReturn($this->getResponse(200, '
77
				{
78
					"account": {
79
						"id": 123,
80
						"name": "newname",
81
						"timezone": "new_timezone",
82
						"currency_name": "Polish złoty"
83
					}
84
				}
85
			'));
86
87
		$account->name = 'newname';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
88
		$account->timezone = 'new_timezone';
89
		$account->currency = Currency::PLN();
90
		$account->save();
91
92
		$this->assertEquals(123, $account->id);
93
		$this->assertEquals('newname', $account->name);
94
		$this->assertEquals('new_timezone', $account->timezone);
95
		$this->assertEquals(Currency::PLN(), $account->currency);
96
	}
97
}
98