|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Dasao\SentryLoggerTest\Log; |
|
4
|
|
|
|
|
5
|
|
|
use Dasao\SentryLogger\Log\SentryLoggerConfig; |
|
6
|
|
|
use PHPUnit\Framework\TestCase; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class SentryLoggerConfigTest |
|
10
|
|
|
* |
|
11
|
|
|
* PHP Version 7 |
|
12
|
|
|
* |
|
13
|
|
|
* @category PHP |
|
14
|
|
|
* @package Dasao\SentryLoggerTest\Log |
|
15
|
|
|
* @author Dasao <[email protected]> |
|
16
|
|
|
* @copyright 2014-2017 Dasao |
|
17
|
|
|
* @license Proprietary http://www.das-ao.com |
|
18
|
|
|
*/ |
|
19
|
|
|
class SentryLoggerConfigTest extends TestCase |
|
20
|
|
|
{ |
|
21
|
|
|
/** @var SentryLoggerConfig */ |
|
22
|
|
|
protected $sentryLoggerConfig; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @return void |
|
26
|
|
|
*/ |
|
27
|
|
|
public function setUp() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->sentryLoggerConfig = new SentryLoggerConfig(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @return void |
|
34
|
|
|
*/ |
|
35
|
|
|
public function testOptions() |
|
36
|
|
|
{ |
|
37
|
|
|
$expectedOptions = [ |
|
38
|
|
|
'key' => 'value', |
|
39
|
|
|
]; |
|
40
|
|
|
|
|
41
|
|
|
$this->sentryLoggerConfig->setOptions($expectedOptions); |
|
42
|
|
|
$actualOptions = $this->sentryLoggerConfig->getOptions(); |
|
43
|
|
|
|
|
44
|
|
|
$this->assertEquals($expectedOptions, $actualOptions); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @return void |
|
49
|
|
|
*/ |
|
50
|
|
|
public function testDsn() |
|
51
|
|
|
{ |
|
52
|
|
|
$expectedDsn = 'https://key:[email protected]/123'; |
|
53
|
|
|
|
|
54
|
|
|
$this->sentryLoggerConfig->setDsn($expectedDsn); |
|
55
|
|
|
$actualDsn = $this->sentryLoggerConfig->getDsn(); |
|
56
|
|
|
|
|
57
|
|
|
$this->assertEquals($expectedDsn, $actualDsn); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Test the exchange array method. |
|
62
|
|
|
* |
|
63
|
|
|
* @return void |
|
64
|
|
|
*/ |
|
65
|
|
|
public function testExchangeArray() |
|
66
|
|
|
{ |
|
67
|
|
|
$expectedDsn = 'https://key:[email protected]/123'; |
|
68
|
|
|
$expectedOptions = ['testkey' => 'testvalue']; |
|
69
|
|
|
|
|
70
|
|
|
$exchangeData = [ |
|
71
|
|
|
'dsn' => $expectedDsn, |
|
72
|
|
|
'options' => $expectedOptions, |
|
73
|
|
|
]; |
|
74
|
|
|
|
|
75
|
|
|
$this->sentryLoggerConfig->exchangeArray($exchangeData); |
|
76
|
|
|
$actualDsn = $this->sentryLoggerConfig->getDsn(); |
|
77
|
|
|
$actualOptions = $this->sentryLoggerConfig->getOptions(); |
|
78
|
|
|
|
|
79
|
|
|
$this->assertEquals($expectedDsn, $actualDsn); |
|
80
|
|
|
$this->assertEquals($expectedOptions, $actualOptions); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @return void |
|
85
|
|
|
*/ |
|
86
|
|
|
public function testWithEmptyDsn() |
|
87
|
|
|
{ |
|
88
|
|
|
$expectedDsn = ''; |
|
89
|
|
|
|
|
90
|
|
|
$this->sentryLoggerConfig->setDsn($expectedDsn); |
|
91
|
|
|
$actualDsn = $this->sentryLoggerConfig->getDsn(); |
|
92
|
|
|
|
|
93
|
|
|
$this->assertTrue($actualDsn ? false : true); |
|
94
|
|
|
} |
|
95
|
|
|
} |