MediaWiki  1.33.0
ExpressionTest.php
Go to the documentation of this file.
1 <?php
2 
4 
9 
13  public function testExpression( $input, $expected ) {
14  $parser = new ExprParser();
15  $this->assertEquals(
16  $expected,
17  $parser->doExpression( $input )
18  );
19  }
20 
21  public function provideExpressions() {
22  return [
23  [ '1 or 0', '1' ],
24  [ 'not (1 and 0)', '1' ],
25  [ 'not 0', '1' ],
26  [ '4 < 5', '1' ],
27  [ '-5 < 2', '1' ],
28  [ '-2 <= -2', '1' ],
29  [ '4 > 3', '1' ],
30  [ '4 > -3', '1' ],
31  [ '5 >= 2', '1' ],
32  [ '2 >= 2', '1' ],
33  [ '1 != 2', '1' ],
34  [ '-4 * -4 = 4 * 4', '1' ],
35  [ 'not (1 != 1)', '1' ],
36  [ '1 + 1', '2' ],
37  [ '-1 + 1', '0' ],
38  [ '+1 + 1', '2' ],
39  [ '4 * 4', '16' ],
40  [ '(1/3) * 3', '1' ],
41  [ '3 / 1.5', '2' ],
42  [ '3 / 0.2', '15' ],
43  [ '3 / ( 2.0 * 0.1 )', '15' ],
44  [ '3 / ( 2.0 / 10 )', '15' ],
45  [ '3 / (- 0.2 )', '-15' ],
46  [ '3 / abs( 0.2 )', '15' ],
47  [ '3 mod 2', '1' ],
48  [ '1e4', '10000' ],
49  [ '1e-2', '0.01' ],
50  [ '4.0 round 0', '4' ],
51  [ 'ceil 4', '4' ],
52  [ 'floor 4', '4' ],
53  [ '4.5 round 0', '5' ],
54  [ '4.2 round 0', '4' ],
55  [ '-4.2 round 0', '-4' ],
56  [ '-4.5 round 0', '-5' ],
57  [ '-2.0 round 0', '-2' ],
58  [ 'ceil -3', '-3' ],
59  [ 'floor -6.0', '-6' ],
60  [ 'ceil 4.2', '5' ],
61  [ 'ceil -4.5', '-4' ],
62  [ 'floor -4.5', '-5' ],
63  [ 'abs(-2)', '2' ],
64  [ 'ln(exp(1))', '1' ],
65  [ 'trunc(4.5)', '4' ],
66  [ 'trunc(-4.5)', '-4' ],
67  [ '123 fmod (2^64-1)', '123' ],
68  [ '5.7 mod 1.3', '0' ],
69  [ '5.7 fmod 1.3', '0.5' ],
70  ];
71  }
72 }
ExpressionTest
\MediaWiki\Extensions\ParserFunctions\ExprParser
Definition: ExpressionTest.php:8
creation
In both all secondary updates will be triggered handle like object that caches derived data representing a and can trigger updates of cached copies of that e g in the links the and the CDN layer DerivedPageDataUpdater is used by PageUpdater when creating new but can also be used independently when performing meta data updates during or when puring a page It s a stepping stone on the way to a more complete refactoring of WikiPage we want to define interfaces for the different use cases of particularly providing access to post PST content and ParserOutput to callbacks during revision creation
Definition: pageupdater.txt:78
sample
they could even be mouse clicks or menu items whatever suits your program You should also get your if to sign a copyright disclaimer for the if necessary Here is a sample
Definition: COPYING.txt:326
MediaWiki\Extensions\ParserFunctions\ExprParser
Definition: ExprParser.php:67
ExpressionTest\provideExpressions
provideExpressions()
Definition: ExpressionTest.php:21
normal
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 normal(non-web) applications -- they might conflict with distributors' policies
a
</source > ! result< div class="mw-highlight mw-content-ltr" dir="ltr">< pre >< span ></span >< span class="kd"> var</span >< span class="nx"> a</span >< span class="p"></span ></pre ></div > ! end ! test Multiline< source/> in lists !input *< source > a b</source > *foo< source > a b</source > ! html< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! html tidy< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! end ! test Custom attributes !input< source lang="javascript" id="foo" class="bar" dir="rtl" style="font-size: larger;"> var a
Definition: parserTests.txt:85
page
target page
Definition: All_system_messages.txt:1267
value
if( $inline) $status value
Definition: SyntaxHighlight.php:345
so
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is and will automatically terminate your rights under this License parties who have received or from you under this License will not have their licenses terminated so long as such parties remain in full compliance You are not required to accept this since you have not signed it nothing else grants you permission to modify or distribute the Program or its derivative works These actions are prohibited by law if you do not accept this License by modifying or distributing the you indicate your acceptance of this License to do so
Definition: COPYING.txt:185
is
This document provides an overview of the usage of PageUpdater and that is
Definition: pageupdater.txt:3
lt
& lt
Definition: funcsParserTests.txt:123
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
specified
! hooks source ! endhooks ! test Non existent language !input< source lang="doesnotexist"> foobar</source > ! result< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > foobar</pre ></div > ! end ! test No language specified ! wikitext< source > foo</source > ! html< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > foo</pre ></div > ! end ! test No language specified(no wellformed xml) !! config !! wikitext< source > bar</source > !! html< div class
none
</source > ! result< p > Text< code class="mw-highlight" dir="ltr">< span class="kd"> var</span >< span class="nx"> a</span >< span class="p"></span ></code ></p > ! end ! test Enclose none(inline code) !!input Text< source lang
Page
! article ParserFunctions page ! text A sample page so we can test ifexist This used to be a Main Page
Definition: funcsParserTests.txt:14
File
! article ParserFunctions page ! text A sample page so we can test ifexist This used to be a Main but that caused duplicate article warnings when running the normal tests at the same time ! endarticle ! article File
Definition: funcsParserTests.txt:14
ExpressionTest\testExpression
testExpression( $input, $expected)
provideExpressions
Definition: ExpressionTest.php:13
$input
if(is_array( $mode)) switch( $mode) $input
Definition: postprocess-phan.php:141
in
null for the wiki Added in
Definition: hooks.txt:1588
MediaWikiTestCase
Definition: MediaWikiTestCase.php:17
not
if not
Definition: COPYING.txt:307
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
div
div
Definition: parserTests.txt:6850
$parser
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
Definition: hooks.txt:1802
language
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of either verbatim or with modifications and or translated into another language(Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying
captcha-old.p
p
Definition: captcha-old.py:275
c
type show c for details The hypothetical commands show w and show c should show the appropriate parts of the General Public License Of the commands you use may be called something other than show w and show c
Definition: COPYING.txt:321
text
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
Definition: All_system_messages.txt:1267
article
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of or an object and a method hook function The function part of a third party developers and administrators to define code that will be run at certain points in the mainline and to modify the data run by that mainline code Hooks can keep mainline code and make it easier to write extensions Hooks are a principled alternative to patches for two options in MediaWiki One reverses the order of a title before displaying the article
Definition: hooks.txt:23
used
you don t have to do a grep find to see where the $wgReverseTitle variable is used
Definition: hooks.txt:115
are
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of and so on Built in content types are
Definition: contenthandler.txt:5
values
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible values
Definition: hooks.txt:175
from
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable from
Definition: APACHE-LICENSE-2.0.txt:43
that
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if that
Definition: deferred.txt:11
captcha-old.output
output
Definition: captcha-old.py:240
gt
DEF & gt
Definition: funcsParserTests.txt:122
then
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been the default skin since then
Definition: skin.txt:10
amp
& amp
Definition: parserTests.txt:54