1
|
|
|
<?php
|
2
|
|
|
|
3
|
|
|
namespace Radowoj\Yaah;
|
4
|
|
|
|
5
|
|
|
use PHPUnit\Framework\TestCase;
|
6
|
|
|
use Radowoj\Yaah\Config;
|
7
|
|
|
|
8
|
|
|
class ConfigTest extends TestCase
|
9
|
|
|
{
|
10
|
|
|
protected $defaultParams = [
|
11
|
|
|
'apiKey' => 'some api key',
|
12
|
|
|
'login' => 'someLogin',
|
13
|
|
|
'passwordHash' => 'passwordHash',
|
14
|
|
|
'isSandbox' => true,
|
15
|
|
|
'countryCode' => 1,
|
16
|
|
|
];
|
17
|
|
|
|
18
|
|
|
|
19
|
|
|
/**
|
20
|
|
|
* @expectedException InvalidArgumentException
|
21
|
|
|
* @expectedExceptionMessage apiKey is required in params array
|
22
|
|
|
*/
|
23
|
|
|
public function testApiKeyRequired()
|
24
|
|
|
{
|
25
|
|
|
$params = $this->defaultParams;
|
26
|
|
|
unset($params['apiKey']);
|
27
|
|
|
new Config($params);
|
28
|
|
|
}
|
29
|
|
|
|
30
|
|
|
|
31
|
|
|
/**
|
32
|
|
|
* @expectedException InvalidArgumentException
|
33
|
|
|
* @expectedExceptionMessage login is required in params array
|
34
|
|
|
*/
|
35
|
|
|
public function testLoginRequired()
|
36
|
|
|
{
|
37
|
|
|
$params = $this->defaultParams;
|
38
|
|
|
unset($params['login']);
|
39
|
|
|
new Config($params);
|
40
|
|
|
}
|
41
|
|
|
|
42
|
|
|
/**
|
43
|
|
|
* @expectedException InvalidArgumentException
|
44
|
|
|
* @expectedExceptionMessage passwordHash is required in params array
|
45
|
|
|
*/
|
46
|
|
|
public function testPasswordHashRequired()
|
47
|
|
|
{
|
48
|
|
|
$params = $this->defaultParams;
|
49
|
|
|
unset($params['passwordHash']);
|
50
|
|
|
new Config($params);
|
51
|
|
|
}
|
52
|
|
|
|
53
|
|
|
|
54
|
|
|
/**
|
55
|
|
|
* @expectedException InvalidArgumentException
|
56
|
|
|
* @expectedExceptionMessage isSandbox is required in params array
|
57
|
|
|
*/
|
58
|
|
|
public function testIsSandboxRequired()
|
59
|
|
|
{
|
60
|
|
|
$params = $this->defaultParams;
|
61
|
|
|
unset($params['isSandbox']);
|
62
|
|
|
new Config($params);
|
63
|
|
|
}
|
64
|
|
|
|
65
|
|
|
|
66
|
|
|
/**
|
67
|
|
|
* @expectedException InvalidArgumentException
|
68
|
|
|
* @expectedExceptionMessage countryCode is required in params array
|
69
|
|
|
*/
|
70
|
|
|
public function testCountryCodeRequired()
|
71
|
|
|
{
|
72
|
|
|
$params = $this->defaultParams;
|
73
|
|
|
unset($params['countryCode']);
|
74
|
|
|
new Config($params);
|
75
|
|
|
}
|
76
|
|
|
|
77
|
|
|
|
78
|
|
|
public function testGetters()
|
79
|
|
|
{
|
80
|
|
|
$params = $this->defaultParams;
|
81
|
|
|
$config = new Config($params);
|
82
|
|
|
$this->assertSame($params['apiKey'], $config->getApiKey());
|
83
|
|
|
$this->assertSame($params['login'], $config->getLogin());
|
84
|
|
|
$this->assertSame($params['passwordHash'], $config->getPasswordHash());
|
85
|
|
|
$this->assertSame($params['countryCode'], $config->getCountryCode());
|
86
|
|
|
$this->assertSame($params['isSandbox'], $config->getIsSandbox());
|
87
|
|
|
}
|
88
|
|
|
|
89
|
|
|
|
90
|
|
|
public function testPlaintextPassword()
|
91
|
|
|
{
|
92
|
|
|
$params = $this->defaultParams;
|
93
|
|
|
$config = new Config($params);
|
94
|
|
|
$config->setPasswordPlain('somePlaintextPassword');
|
95
|
|
|
$this->assertSame('somePlaintextPassword', $config->getPasswordPlain());
|
96
|
|
|
}
|
97
|
|
|
|
98
|
|
|
}
|
99
|
|
|
|