MediaWiki  1.32.5
SpecialMIMESearchTest.php
Go to the documentation of this file.
1 <?php
2 
8 
10  private $page;
11 
12  function setUp() {
13  $this->page = new MIMEsearchPage;
14  $context = new RequestContext();
15  $context->setTitle( Title::makeTitle( NS_SPECIAL, 'MIMESearch' ) );
16  $context->setRequest( new FauxRequest() );
17  $this->page->setContext( $context );
18 
19  parent::setUp();
20  }
21 
28  function testMimeFiltering( $par, $major, $minor ) {
29  $this->page->run( $par );
30  $qi = $this->page->getQueryInfo();
31  $this->assertEquals( $qi['conds']['img_major_mime'], $major );
32  if ( $minor !== null ) {
33  $this->assertEquals( $qi['conds']['img_minor_mime'], $minor );
34  } else {
35  $this->assertArrayNotHasKey( 'img_minor_mime', $qi['conds'] );
36  }
37  $this->assertContains( 'image', $qi['tables'] );
38  }
39 
40  function providerMimeFiltering() {
41  return [
42  [ 'image/gif', 'image', 'gif' ],
43  [ 'image/png', 'image', 'png' ],
44  [ 'application/pdf', 'application', 'pdf' ],
45  [ 'image/*', 'image', null ],
46  [ 'multipart/*', 'multipart', null ],
47  ];
48  }
49 }
SpecialMIMESearchTest\setUp
setUp()
Definition: SpecialMIMESearchTest.php:12
FauxRequest
WebRequest clone which takes values from a provided array.
Definition: FauxRequest.php:33
$context
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2683
SpecialMIMESearchTest
Database MIMEsearchPage.
Definition: SpecialMIMESearchTest.php:7
SpecialMIMESearchTest\testMimeFiltering
testMimeFiltering( $par, $major, $minor)
providerMimeFiltering
Definition: SpecialMIMESearchTest.php:28
page
target page
Definition: All_system_messages.txt:1267
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
SpecialMIMESearchTest\$page
MIMEsearchPage $page
Definition: SpecialMIMESearchTest.php:10
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:53
MIMEsearchPage
Searches the database for files of the requested MIME type, comparing this with the 'img_major_mime' ...
Definition: SpecialMIMEsearch.php:32
MediaWikiTestCase
Definition: MediaWikiTestCase.php:16
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:545
RequestContext
Group all the pieces relevant to the context of a request into one instance.
Definition: RequestContext.php:32
SpecialMIMESearchTest\providerMimeFiltering
providerMimeFiltering()
Definition: SpecialMIMESearchTest.php:40