|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Test\TestCase\View\Helper; |
|
4
|
|
|
|
|
5
|
|
|
use App\View\Helper\ReportsHelper; |
|
6
|
|
|
use Cake\TestSuite\TestCase; |
|
7
|
|
|
use Cake\View\View; |
|
8
|
|
|
|
|
9
|
|
|
class ReportsHelperTest extends TestCase |
|
10
|
|
|
{ |
|
11
|
|
|
public function setUp(): void |
|
12
|
|
|
{ |
|
13
|
|
|
parent::setUp(); |
|
14
|
|
|
$View = new View(); |
|
15
|
|
|
$this->Reports = new ReportsHelper($View); |
|
|
|
|
|
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Provider for testLinkToReport |
|
20
|
|
|
* |
|
21
|
|
|
* @return array array data for testLinkToReport |
|
22
|
|
|
*/ |
|
23
|
|
|
public function providerForTestLinkToReport(): array |
|
24
|
|
|
{ |
|
25
|
|
|
return [ |
|
26
|
|
|
[ |
|
27
|
|
|
[ |
|
28
|
|
|
'id' => 116273, |
|
29
|
|
|
'error_message' => 'TypeError: url is undefined', |
|
30
|
|
|
'error_name' => null, |
|
31
|
|
|
'pma_version' => '4.7.1', |
|
32
|
|
|
'status' => 'new', |
|
33
|
|
|
'location' => 'index.js', |
|
34
|
|
|
'linenumber' => 154, |
|
35
|
|
|
'sourceforge_bug_id' => null, |
|
36
|
|
|
'related_to' => 12567, |
|
37
|
|
|
'exception_type' => 'js', |
|
38
|
|
|
], |
|
39
|
|
|
'<a href="/reports/view/116273">#116273</a>', |
|
40
|
|
|
], |
|
41
|
|
|
[ |
|
42
|
|
|
[ |
|
43
|
|
|
'id' => 1879, |
|
44
|
|
|
'error_message' => 'TypeError: url is undefined', |
|
45
|
|
|
'error_name' => null, |
|
46
|
|
|
'pma_version' => '4.1.6', |
|
47
|
|
|
'status' => 'new', |
|
48
|
|
|
'location' => 'common.js', |
|
49
|
|
|
'linenumber' => 154, |
|
50
|
|
|
'sourceforge_bug_id' => null, |
|
51
|
|
|
'related_to' => null, |
|
52
|
|
|
'exception_type' => 'php', |
|
53
|
|
|
], |
|
54
|
|
|
'<a href="/reports/view/1879">#1879</a>', |
|
55
|
|
|
], |
|
56
|
|
|
]; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @dataProvider providerForTestLinkToReport |
|
61
|
|
|
* @param array $report The report |
|
62
|
|
|
* @param string $expected The expected |
|
63
|
|
|
*/ |
|
64
|
|
|
public function testLinkToReport(array $report, string $expected): void |
|
65
|
|
|
{ |
|
66
|
|
|
$link = $this->Reports->linkToReport($report); |
|
67
|
|
|
|
|
68
|
|
|
$this->assertEquals( |
|
69
|
|
|
$expected, |
|
70
|
|
|
$link |
|
71
|
|
|
); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Provider for testCreateReportsLinks |
|
76
|
|
|
* |
|
77
|
|
|
* @return array array data to testCreateReportsLinks |
|
78
|
|
|
*/ |
|
79
|
|
|
public function providerForTestCreateReportsLinks(): array |
|
80
|
|
|
{ |
|
81
|
|
|
return [ |
|
82
|
|
|
[ |
|
83
|
|
|
[ |
|
84
|
|
|
[ |
|
85
|
|
|
'id' => 116273, |
|
86
|
|
|
'error_message' => 'TypeError: url is undefined', |
|
87
|
|
|
'error_name' => null, |
|
88
|
|
|
'pma_version' => '4.7.1', |
|
89
|
|
|
'status' => 'new', |
|
90
|
|
|
'location' => 'index.js', |
|
91
|
|
|
'linenumber' => 154, |
|
92
|
|
|
'sourceforge_bug_id' => null, |
|
93
|
|
|
'related_to' => 12567, |
|
94
|
|
|
'exception_type' => 'js', |
|
95
|
|
|
], |
|
96
|
|
|
[ |
|
97
|
|
|
'id' => 1879, |
|
98
|
|
|
'error_message' => 'TypeError: url is undefined', |
|
99
|
|
|
'error_name' => null, |
|
100
|
|
|
'pma_version' => '4.1.6', |
|
101
|
|
|
'status' => 'new', |
|
102
|
|
|
'location' => 'common.js', |
|
103
|
|
|
'linenumber' => 154, |
|
104
|
|
|
'sourceforge_bug_id' => null, |
|
105
|
|
|
'related_to' => null, |
|
106
|
|
|
'exception_type' => 'php', |
|
107
|
|
|
], |
|
108
|
|
|
], |
|
109
|
|
|
'<a href="/reports/view/116273">#116273</a>, ' |
|
110
|
|
|
. '<a href="/reports/view/1879">#1879</a>', |
|
111
|
|
|
], |
|
112
|
|
|
]; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @dataProvider providerForTestCreateReportsLinks |
|
117
|
|
|
* @param array $reports The reports |
|
118
|
|
|
* @param string $expected The expected reports |
|
119
|
|
|
*/ |
|
120
|
|
|
public function testCreateReportsLinks(array $reports, string $expected): void |
|
121
|
|
|
{ |
|
122
|
|
|
$links_str = $this->Reports->createReportsLinks($reports); |
|
123
|
|
|
|
|
124
|
|
|
$this->assertEquals( |
|
125
|
|
|
$expected, |
|
126
|
|
|
$links_str |
|
127
|
|
|
); |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|