| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\Feed\FeedUtils; |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
class FeedUtilsTest extends MediaWikiUnitTestCase { |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
public function testApplyDiffStyle( $html, $expected ) { |
| 14 |
$this->assertSame( $expected, FeedUtils::applyDiffStyle( $html ) ); |
| 15 |
} |
| 16 |
|
| 17 |
public static function provideElements() { |
| 18 |
return [ |
| 19 |
[ |
| 20 |
'<td class="diff">Test</td>', |
| 21 |
'<td style="background-color: #fff; color: #202122;">Test</td>' |
| 22 |
], |
| 23 |
[ |
| 24 |
'<td colspan="2" class="diff-otitle">← Previous revision</td>', |
| 25 |
'<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">' . |
| 26 |
'← Previous revision</td>' |
| 27 |
], |
| 28 |
[ |
| 29 |
'<td colspan="2" class="diff-ntitle">Test</td>', |
| 30 |
'<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">' . |
| 31 |
'Test</td>' |
| 32 |
], |
| 33 |
[ |
| 34 |
'<td class="diff-addedline">Test</td>', |
| 35 |
'<td style="color: #202122; font-size: 88%; border-style: solid; ' . |
| 36 |
'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; ' . |
| 37 |
'vertical-align: top; white-space: pre-wrap;">Test</td>' |
| 38 |
], |
| 39 |
|
| 40 |
[ |
| 41 |
'<td class="extraclass diff-deletedline">Test</td>', |
| 42 |
'<td style="color: #202122; font-size: 88%; border-style: solid; ' . |
| 43 |
'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; ' . |
| 44 |
'vertical-align: top; white-space: pre-wrap;">Test</td>' |
| 45 |
], |
| 46 |
|
| 47 |
[ |
| 48 |
'<td class="diffchange diff-context extra">Test</td>', |
| 49 |
'<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; ' |
| 50 |
. 'border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; ' |
| 51 |
. 'border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;">Test</td>' |
| 52 |
], |
| 53 |
|
| 54 |
[ |
| 55 |
'<td class="diffchange diffchange-inline">Test</td>', |
| 56 |
'<td style="font-weight: bold; text-decoration: none;">Test</td>' |
| 57 |
], |
| 58 |
[ |
| 59 |
'<td class="not-a-diff">Test</td>', |
| 60 |
'<td class="not-a-diff">Test</td>', |
| 61 |
], |
| 62 |
[ |
| 63 |
'<td class="reallynodiff">Test</td>', |
| 64 |
'<td class="reallynodiff">Test</td>', |
| 65 |
], |
| 66 |
[ |
| 67 |
'<td class="unrelated" id="diff">Test</td>', |
| 68 |
'<td class="unrelated" id="diff">Test</td>', |
| 69 |
], |
| 70 |
[ |
| 71 |
'<td class="unrelated reallynodiff">diff <span class="x">x</span></td>', |
| 72 |
'<td class="unrelated reallynodiff">diff <span class="x">x</span></td>', |
| 73 |
], |
| 74 |
[ |
| 75 |
'<<class="diff">>', |
| 76 |
'<<class="diff">>', |
| 77 |
], |
| 78 |
[ |
| 79 |
'<b>class="a" < class="diff"</b>', |
| 80 |
'<b>class="a" < class="diff"</b>', |
| 81 |
], |
| 82 |
|
| 83 |
[ |
| 84 |
'<td colspan="2" class="diff-ntitle"><span>Title</span><td class="diff-addedline">' . |
| 85 |
'Test</td></td><td class="extraclass diff-deletedline">Test</td>< class="diff"></>' . |
| 86 |
'class="diff"', |
| 87 |
'<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">' . |
| 88 |
'<span>Title</span><td style="color: #202122; font-size: 88%; border-style: solid; ' . |
| 89 |
'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; ' . |
| 90 |
'vertical-align: top; white-space: pre-wrap;">Test</td></td><td ' . |
| 91 |
'style="color: #202122; font-size: 88%; border-style: solid; ' . |
| 92 |
'border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; ' . |
| 93 |
'vertical-align: top; white-space: pre-wrap;">Test</td>< class="diff"></>class="diff"' |
| 94 |
] |
| 95 |
]; |
| 96 |
} |
| 97 |
|
| 98 |
} |