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