Move ResultWrapper subclasses to Rdbms
[mediawiki.git] / tests / phpunit / includes / rcfeed / RCFeedIntegrationTest.php
blobe3ea13915dc797e3110040f475214ee46f0a8221
1 <?php
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 ] );
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
26 public function testNotify() {
27 $feed = $this->getMockBuilder( 'RCFeedEngine' )
28 ->setConstructorArgs( [ [ 'formatter' => 'JSONRCFeedFormatter' ] ] )
29 ->setMethods( [ 'send' ] )
30 ->getMock();
32 $feed->method( 'send' )
33 ->willReturn( true );
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',
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
64 return true;
65 } ) );
67 $this->setMwGlobals( [
68 'wgRCFeeds' => [
69 'myfeed' => [
70 'uri' => 'test://localhost:1234',
71 'formatter' => 'JSONRCFeedFormatter',
74 'wgRCEngines' => [
75 'test' => $feed,
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 ] )
96 $rc->notifyRCFeeds();