Merge "Add ext-dom to composer.json"
[lhc/web/wiklou.git] / tests / phpunit / includes / diff / UnsupportedSlotDiffRendererTest.php
1 <?php
2
3 /**
4 * @covers UnsupportedSlotDiffRenderer
5 */
6 class UnsupportedSlotDiffRendererTest extends MediaWikiTestCase {
7
8 public function provideDiff() {
9 $oldContent = new TextContent( 'Kittens' );
10 $newContent = new TextContent( 'Goats' );
11 $badContent = new UnknownContent( 'Dragons', 'xyzzy' );
12
13 yield [ '(unsupported-content-diff)', $oldContent, null ];
14 yield [ '(unsupported-content-diff)', null, $newContent ];
15 yield [ '(unsupported-content-diff)', $oldContent, $newContent ];
16 yield [ '(unsupported-content-diff2)', $badContent, $newContent ];
17 yield [ '(unsupported-content-diff2)', $oldContent, $badContent ];
18 yield [ '(unsupported-content-diff)', null, $badContent ];
19 yield [ '(unsupported-content-diff)', $badContent, null ];
20 }
21
22 /**
23 * @dataProvider provideDiff
24 */
25 public function testDiff( $expected, $oldContent, $newContent ) {
26 $this->mergeMwGlobalArrayValue(
27 'wgContentHandlers',
28 [ 'xyzzy' => 'UnknownContentHandler' ]
29 );
30
31 $localizer = $this->getMock( MessageLocalizer::class );
32
33 $localizer->method( 'msg' )
34 ->willReturnCallback( function ( $key, ...$params ) {
35 return new RawMessage( "($key)", $params );
36 } );
37
38 $sdr = new UnsupportedSlotDiffRenderer( $localizer );
39 $this->assertContains( $expected, $sdr->getDiff( $oldContent, $newContent ) );
40 }
41
42 }