-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeywordEnhancerTest.php
More file actions
107 lines (94 loc) · 3.81 KB
/
KeywordEnhancerTest.php
File metadata and controls
107 lines (94 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
namespace PHPWatch\PHPCommitBuilder\Tests;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPWatch\PHPCommitBuilder\KeywordEnhancer;
use PHPUnit\Framework\TestCase;
class KeywordEnhancerTest extends TestCase {
public static function dataLinkToSecurityAnnouncements(): array {
return [
[
'eloadfont(). (CVE-2022-31630) (cmb)',
'eloadfont(). ([CVE-2022-31630](https://nvd.nist.gov/vuln/detail/CVE-2022-31630)) (cmb)',
],
[
'eloadfont(). (CVE-1987-31630) (cmb)',
'eloadfont(). (CVE-1987-31630) (cmb)',
],
[
'Fixed bug #81726: phar wrapper: DOS when using quine gzip file. (CVE-2022-31628). (cmb)',
'Fixed bug [#81726](https://bugs.php.net/bug.php?id=81726): phar wrapper: DOS when using quine gzip file. ([CVE-2022-31628](https://nvd.nist.gov/vuln/detail/CVE-2022-31628)). (cmb)',
],
];
}
public static function dataLinksToBugsPhp(): array {
return [
[
'Fixed bug #81739: OOB read due to',
'Fixed bug [#81739](https://bugs.php.net/bug.php?id=81739): OOB read due to',
],
[
'Fixed bug #45: OOB read due to',
'Fixed bug #45: OOB read due to',
],
[
'Fixed bug #5943: OOB read due to',
'Fixed bug #5943: OOB read due to',
],
[
'Fixed bug [GH-11453](https://github.com/php/php-src/issues/11453): OOB read due to',
'Fixed bug [GH-11453](https://github.com/php/php-src/issues/11453): OOB read due to',
],
[
'Fixed bug #11453: OOB read due to',
'Fixed bug [GH-11453](https://github.com/php/php-src/issues/11453): OOB read due to',
],
[
'Fixed bug #123456: OOB read due to',
'Fixed bug #123456: OOB read due to',
],
];
}
public static function dataLinkToGitHub(): array {
return [
[
'Fixed bug GH-1: OOB read due to',
'Fixed bug GH-1: OOB read due to',
],
[
'Fixed bug GH-123: OOB read due to',
'Fixed bug [GH-123](https://github.com/php/php-src/issues/123): OOB read due to',
],
];
}
public static function dataCodifyText(): array {
return [
['password_hash()', '`password_hash()`'],
['`password_hash()`', '`password_hash()`'],
[
'`password_hash()` and password_hash()',
'`password_hash()` and `password_hash()`',
],
];
}
public function testReturnsVerbatimOnEmptyStrings(): void {
self::assertSame('', KeywordEnhancer::enhance(''));
self::assertSame(' ', KeywordEnhancer::enhance(' '));
self::assertSame('test', KeywordEnhancer::enhance('test'));
}
#[DataProvider('dataLinksToBugsPhp')]
public function testLinksToBugsPhp(string $input, string $expected): void {
self::assertSame($expected, KeywordEnhancer::enhance($input));
}
#[DataProvider('dataLinkToGitHub')]
public function testLinkToGitHub(string $input, string $expected): void {
self::assertSame($expected, KeywordEnhancer::enhance($input));
}
#[DataProvider('dataLinkToSecurityAnnouncements')]
public function testLinkToSecurityAnnouncements(string $input, string $expected): void {
self::assertSame($expected, KeywordEnhancer::enhance($input));
}
#[DataProvider('dataCodifyText')]
public function testCodifyText(string $input, string $expected): void {
self::assertSame($expected, KeywordEnhancer::enhance($input));
}
}