MediaWiki
REL1_32
SlotDiffRendererTest.php
Go to the documentation of this file.
1
<?php
2
use Wikimedia\Assert\ParameterTypeException;
3
use Wikimedia\TestingAccessWrapper;
4
8
class
SlotDiffRendererTest
extends
\PHPUnit\Framework\TestCase {
9
13
public
function
testNormalizeContents
(
14
$oldContent, $newContent, $allowedClasses,
15
$expectedOldContent, $expectedNewContent, $expectedExceptionClass
16
) {
17
$slotDiffRenderer = $this->getMockBuilder( SlotDiffRenderer::class )
18
->getMock();
19
try
{
20
// __call needs help deciding which parameter to take by reference
21
call_user_func_array( [ TestingAccessWrapper::newFromObject( $slotDiffRenderer ),
22
'normalizeContents'
], [ &$oldContent, &$newContent, $allowedClasses ] );
23
$this->assertEquals( $expectedOldContent, $oldContent );
24
$this->assertEquals( $expectedNewContent, $newContent );
25
}
catch
( Exception
$e
) {
26
if
( !$expectedExceptionClass ) {
27
throw
$e
;
28
}
29
$this->assertInstanceOf( $expectedExceptionClass,
$e
);
30
}
31
}
32
33
public
function
provideNormalizeContents
() {
34
return
[
35
'both null'
=> [
null
,
null
,
null
,
null
,
null
, InvalidArgumentException::class ],
36
'left null'
=> [
37
null
,
new
WikitextContent
(
'abc'
),
null
,
38
new
WikitextContent
(
''
),
new
WikitextContent
(
'abc'
),
null
,
39
],
40
'right null'
=> [
41
new
WikitextContent
(
'def'
),
null
,
null
,
42
new
WikitextContent
(
'def'
),
new
WikitextContent
(
''
),
null
,
43
],
44
'type filter'
=> [
45
new
WikitextContent
(
'abc'
),
new
WikitextContent
(
'def'
), WikitextContent::class,
46
new
WikitextContent
(
'abc'
),
new
WikitextContent
(
'def'
),
null
,
47
],
48
'type filter (subclass)'
=> [
49
new
WikitextContent
(
'abc'
),
new
WikitextContent
(
'def'
), TextContent::class,
50
new
WikitextContent
(
'abc'
),
new
WikitextContent
(
'def'
),
null
,
51
],
52
'type filter (null)'
=> [
53
new
WikitextContent
(
'abc'
),
null
, TextContent::class,
54
new
WikitextContent
(
'abc'
),
new
WikitextContent
(
''
),
null
,
55
],
56
'type filter failure (left)'
=> [
57
new
TextContent
(
'abc'
),
new
WikitextContent
(
'def'
), WikitextContent::class,
58
null
,
null
, ParameterTypeException::class,
59
],
60
'type filter failure (right)'
=> [
61
new
WikitextContent
(
'abc'
),
new
TextContent
(
'def'
), WikitextContent::class,
62
null
,
null
, ParameterTypeException::class,
63
],
64
'type filter (array syntax)'
=> [
65
new
WikitextContent
(
'abc'
),
new
JsonContent
(
'def'
),
66
[ JsonContent::class, WikitextContent::class ],
67
new
WikitextContent
(
'abc'
),
new
JsonContent
(
'def'
),
null
,
68
],
69
'type filter failure (array syntax)'
=> [
70
new
WikitextContent
(
'abc'
),
new
CssContent
(
'def'
),
71
[ JsonContent::class, WikitextContent::class ],
72
null
,
null
, ParameterTypeException::class,
73
],
74
];
75
}
76
77
}
CssContent
Content object for CSS pages.
Definition
CssContent.php:33
JsonContent
Represents the content of a JSON content.
Definition
JsonContent.php:15
SlotDiffRendererTest
SlotDiffRenderer.
Definition
SlotDiffRendererTest.php:8
SlotDiffRendererTest\testNormalizeContents
testNormalizeContents( $oldContent, $newContent, $allowedClasses, $expectedOldContent, $expectedNewContent, $expectedExceptionClass)
provideNormalizeContents
Definition
SlotDiffRendererTest.php:13
SlotDiffRendererTest\provideNormalizeContents
provideNormalizeContents()
Definition
SlotDiffRendererTest.php:33
TextContent
Content object implementation for representing flat text.
Definition
TextContent.php:37
WikitextContent
Content object for wiki text pages.
Definition
WikitextContent.php:35
$e
returning false will NOT prevent logging $e
Definition
hooks.txt:2226
tests
phpunit
includes
diff
SlotDiffRendererTest.php
Generated on Mon Nov 25 2024 15:58:39 for MediaWiki by
1.10.0