MediaWiki  1.33.0
RCFeedIntegrationTest.php
Go to the documentation of this file.
1 <?php
2 
13  protected function setUp() {
14  parent::setUp();
15  $this->setMwGlobals( [
16  'wgCanonicalServer' => 'https://example.org',
17  'wgServerName' => 'example.org',
18  'wgScriptPath' => '/w',
19  'wgDBname' => 'example',
20  'wgDBprefix' => '',
21  'wgRCFeeds' => [],
22  'wgRCEngines' => [],
23  ] );
24  }
25 
26  public function testNotify() {
27  $feed = $this->getMockBuilder( RCFeedEngine::class )
28  ->setConstructorArgs( [ [ 'formatter' => JSONRCFeedFormatter::class ] ] )
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::class,
72  ],
73  ],
74  'wgRCEngines' => [
75  'test' => $feed,
76  ],
77  ] );
78  $logpage = SpecialPage::getTitleFor( 'Log', 'move' );
79  $user = $this->getTestSysop()->getUser();
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
91  '4::color' => 'green',
92  '5:number:nr' => 42,
93  'pet' => 'cat',
94  ] )
95  );
96  $rc->notifyRCFeeds();
97  }
98 }
$user
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1476
anything
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same so they can t rely on Unix and must forbid reads to even standard directories like tmp lest users read each others files We cannot assume that the user has the ability to install or run any programs not written as web accessible PHP scripts Since anything that works on cheap shared hosting will work if you have shell or root access MediaWiki s design is based around catering to the lowest common denominator Although we support higher end setups as the way many things work by default is tailored toward shared hosting These defaults are unconventional from the point of view of and they certainly aren t ideal for someone who s installing MediaWiki as MediaWiki does not conform to normal Unix filesystem layout Hopefully we ll offer direct support for standard layouts in the but for now *any change to the location of files is unsupported *Moving things and leaving symlinks will *probably *not break anything
Definition: distributors.txt:39
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Definition: SpecialPage.php:82
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition: MediaWikiTestCase.php:709
MediaWikiTestCase
Definition: MediaWikiTestCase.php:17
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:576
RCFeedIntegrationTest\setUp
setUp()
Definition: RCFeedIntegrationTest.php:13
$line
$line
Definition: cdb.php:59
MediaWikiTestCase\getTestSysop
static getTestSysop()
Convenience method for getting an immutable admin test user.
Definition: MediaWikiTestCase.php:204
RecentChange\newLogEntry
static newLogEntry( $timestamp, $title, $user, $actionComment, $ip, $type, $action, $target, $logComment, $params, $newId=0, $actionCommentIRC='', $revId=0, $isPatrollable=false)
Definition: RecentChange.php:863
RCFeedIntegrationTest
medium Database FormattedRCFeed RecentChange JSONRCFeedFormatter MachineReadableRCFeedFormatter RCFee...
Definition: RCFeedIntegrationTest.php:12
LogEntryBase\makeParamBlob
static makeParamBlob( $params)
Create a blob from a parameter array.
Definition: LogEntry.php:146
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
RCFeedIntegrationTest\testNotify
testNotify()
Definition: RCFeedIntegrationTest.php:26