Do not output invalid links for deleted names on Special:Contributions
[lhc/web/wiklou.git] / tests / phpunit / includes / rcfeed / RCFeedIntegrationTest.php
1 <?php
2
3 class RCFeedIntegrationTest extends MediaWikiTestCase {
4 protected function setUp() {
5 parent::setUp();
6 $this->setMwGlobals( [
7 'wgCanonicalServer' => 'https://example.org',
8 'wgServerName' => 'example.org',
9 'wgScriptPath' => '/w',
10 'wgDBname' => 'example',
11 'wgDBprefix' => '',
12 'wgRCFeeds' => [],
13 'wgRCEngines' => [],
14 ] );
15 }
16
17 /**
18 * @covers RecentChange::notifyRCFeeds
19 * @covers RecentChange::getEngine
20 * @covers RCFeed::factory
21 * @covers FormattedRCFeed::__construct
22 * @covers FormattedRCFeed::notify
23 * @covers JSONRCFeedFormatter::formatArray
24 * @covers MachineReadableRCFeedFormatter::getLine
25 */
26 public function testNotify() {
27 $feed = $this->getMockBuilder( 'RCFeedEngine' )
28 ->setConstructorArgs( [ [ 'formatter' => 'JSONRCFeedFormatter' ] ] )
29 ->setMethods( [ 'send' ] )
30 ->getMock();
31
32 $feed->method( 'send' )
33 ->willReturn( true );
34
35 $feed->expects( $this->once() )
36 ->method( 'send' )
37 ->with( $this->anything(), $this->callback( function ( $line ) {
38 $this->assertJsonStringEqualsJsonString(
39 json_encode( [
40 'id' => null,
41 'type' => 'log',
42 'namespace' => 0,
43 'title' => 'Example',
44 'comment' => '',
45 'timestamp' => 1301644800,
46 'user' => 'UTSysop',
47 'bot' => false,
48 'log_id' => 0,
49 'log_type' => 'move',
50 'log_action' => 'move',
51 'log_params' => [
52 'color' => 'green',
53 'nr' => 42,
54 'pet' => 'cat',
55 ],
56 'log_action_comment' => '',
57 'server_url' => 'https://example.org',
58 'server_name' => 'example.org',
59 'server_script_path' => '/w',
60 'wiki' => 'example',
61 ] ),
62 $line
63 );
64 return true;
65 } ) );
66
67 $this->setMwGlobals( [
68 'wgRCFeeds' => [
69 'myfeed' => [
70 'uri' => 'test://localhost:1234',
71 'formatter' => 'JSONRCFeedFormatter',
72 ],
73 ],
74 'wgRCEngines' => [
75 'test' => $feed,
76 ],
77 ] );
78 $logpage = SpecialPage::getTitleFor( 'Log', 'move' );
79 $user = $this->getTestSysop()->getUser();
80 $rc = RecentChange::newLogEntry(
81 '20110401080000',
82 $logpage, // &$title
83 $user, // &$user
84 '', // $actionComment
85 '127.0.0.1', // $ip
86 'move', // $type
87 'move', // $action
88 Title::makeTitle( 0, 'Example' ), // $target
89 '', // $logComment
90 LogEntryBase::makeParamBlob( [
91 '4::color' => 'green',
92 '5:number:nr' => 42,
93 'pet' => 'cat',
94 ] )
95 );
96 $rc->notifyRCFeeds();
97 }
98 }