aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/PrefixSearchTest.php
Commit message (Collapse)AuthorAgeFilesLines
* PrefixSearchTest: move under /search testsDannyS7122021-03-111-371/+0
| | | | | | To match the location of the PrefixSearch class Change-Id: I0ff0ac61ab6ea2e5494d61362f4648596e713329
* Tests: Mark more more closures as staticUmherirrender2021-02-091-1/+1
| | | | | | | Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208 Bug: T274036 Change-Id: I695873737167a75f0d94901fa40383a33984ca55
* WikiPage: deprecated construction on bad titlesdaniel2021-01-201-0/+5
| | | | | | | | | WikiPage represents a page that can be created and edited. WikiPage should not be constructed on Titles that represent things like special pages or section links. Any such usage should be deprecated. Bug: T272424 Change-Id: I03969883fc0b326dd2374d7f8e24c1d5a650d5fa
* Revert "Make WikiPage a ProperPageIdentity"James D. Forrester2021-01-151-5/+0
| | | | | | | | | This reverts commit 8f46ef5ff4cf141f154cbe5629d9f5ce11350623. This has seemingly broken FlaggedRevs and thus a bunch of repos. Bug: T272170 Change-Id: I67de3dbbbc9163aae937f710ecb0e40db0d483a0
* Make WikiPage a ProperPageIdentitydaniel2021-01-151-0/+5
| | | | | | | | | This makes it so methods that take a WikiPage can be narrowed to a PageIdentity, and prepares WikiPage for the introduction of the PageRecord interface. Bug: T208776 Change-Id: Iab8bd75a1948873baab9c91c76f966d606b23c0f
* Fix tests/ PSR12.Properties.ConstantVisibility.NotFoundReedy2020-05-161-1/+1
| | | | Change-Id: I0beed1a35e046705fb84c9d1f63cf92afd009bb4
* Fix failing tests relying on private Hooks.php propertiesNikki Nikkhoui2020-04-131-13/+0
| | | | | | | | | | Some tests rely on properties in Hooks.php that will no longer exist with the new HookContainer.php (e.g. Hook::handlers). These tests need to be modified to adhere to the changes made in Hooks.php. Bug: T250102 Change-Id: I5e21ee49925c82260c43cb1d6470fae195057ba5
* tests: Add explicit return type void to setUp() and tearDown()Max Semenik2019-10-301-2/+2
| | | | | | Bug: T192167 Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43 Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
* Remove unneeded overrideMwServices/resetServicesAryeh Gregor2019-08-291-2/+0
| | | | Change-Id: If6cbdec05b8f310ef3a0b4649aaa16d9fb80a047
* Reset services before every testTim Starling2018-09-031-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | Trying to avoid resetting services introduces a lot of complexity and several bugs. We were doing a reset for 70% of @group Database tests anyway. Instead: * Reset services at the start of MediaWikiTestCase::run(). * Capture the actual original service container instead of making a special shared service container. * The test-isolated local service container can now only be initialised non-statically. Revert the recent conversion of overrideMwServices() to static. * Store a reference to the local service container in the test case object. In MediaWikiTestCase, always use the original or local service container directly, to avoid confusion about which one is active at the time. * Remove a lot of unnecessary teardown * Always call ServiceContainer::destroy() before forceGlobalInstance() since the memory is not otherwise freed. Change-Id: I4a17c1c7ec92c14e3bc471f0216473ebe19477b9
* Make SpecialPageFactory a serviceAryeh Gregor2018-08-171-2/+2
| | | | | | | | | | | | Calling SpecialPageFactory methods statically is now soft-deprecated. SpecialPageFactory::resetList() is a no-op, and I changed tests in core to use overrideMwServices() instead. Methods that fell back to $wgUser now require a User object being passed. Depends-On: Ie1f80315871085b9fd4763a265b588849d94414d Change-Id: Id8a92d57743f790b7d8c377c033cef38d1bb24de
* Merge "Automatically reset namespace caches when needed"jenkins-bot2018-08-021-8/+1
|\
| * Automatically reset namespace caches when neededAryeh Gregor2018-08-011-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | This avoids error-prone code written separately in every test. In addition to no existing tests resetting the TitleFormatter (more services probably need to be reset as well), they mostly reset only the namespace cache on $wgContLang, which wouldn't help for any other language. The parser test runner still doesn't do this, but maybe it should. Change-Id: I44b7a1aec48f14b0950907fa14bd0df80f674296
* | Disable PHPUnit tests that fail under postgresKunal Mehta2018-08-011-0/+4
|/ | | | | | | | So we can make the job voting, preventing other tests from regressing. These tests can be re-enabled whenever they're made to pass. Bug: T195807 Change-Id: I58261dd70eea3581803987a4a7739c7d55558f42
* Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenientBartosz Dziewoński2018-05-301-2/+2
| | | | | | | | | | | | | | Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/ Replace with: '\1 ?? ' (Everywhere except includes/PHPVersionCheck.php) (Then, manually fix some line length and indentation issues) Then manually reviewed the replacements for cases where confusing operator precedence would result in incorrect results (fixing those in I478db046a1cc162c6767003ce45c9b56270f3372). Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
* Use ::class to resolve class names in testsUmherirrender2018-01-261-3/+3
| | | | | | | This helps to find renamed or misspelled classes earlier. Phan will check the class names Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
* Improve namespace handling in testsBrad Jorsch2017-09-291-1/+4
| | | | | | | | | | | | MWNamespace has three internal caches, only one of which can be cleared (and that somewhat oddly by passing a boolean to MWNamespace::getCanonicalNamespaces()). This change introduces a MWNamespace::clearCaches() method to clear all three caches. It also adds some resetting in tests that seemed to be missing it. Change-Id: I1dcfcd8713888b3ff8fc75e95329ba72bd95d0c9
* Avoid postgres PrefixSearchTest failures due to collation differencesAaron Schulz2017-05-181-0/+10
| | | | | Bug: T75174 Change-Id: I6b1df27ca6ae5c2da46134be3dbd7aed404d9601
* Switch to librarized version of TestingAccessWrapperGergő Tisza2017-04-201-0/+3
| | | | | | | | | | | | | | | Replaces \TestingAccessWrapper (defined in core) with \Wikimedia\TestingAccessWrapper (defined in the composer package wikimedia/testing-access-wrapper). See https://gerrit.wikimedia.org/r/#/q/topic:librarize-testing-access-wrapper for downstream patches. The core version of the class is kept around for a while to avoid circular dependency problems. Bug: T163434 Change-Id: I52cc257e593da3d6c3b01a909e554a950225aec8
* tests: Replace implicit Bugzilla bug numbers with Phab onesJames D. Forrester2017-02-211-2/+2
| | | | | | | It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345" except where it doesn't, so let's just standardise on the real numbers. Change-Id: I46261416f7603558dceb76ebe695a5cac274e417
* Rank aliases in search in order they appear in the messages file.Stanislav Malyshev2016-11-291-3/+3
| | | | | | | This will ensure the local page name (which is the first alias) is prioritized. Bug: T151660 Change-Id: I3cc266024f5e052d20ff55c4b2c6cbd2945e3dd3
* PrefixSearch: Implement searching in multiple namespacesNiklas Laxström2016-09-151-2/+44
| | | | | | | | | | | | | | | I thought there was just an issue with capitalization, but in fact the code explicitly only searched one namespace anyway. Fixed that while taking capitalization differences in namespaces into account. This by extend also brings support for multiple namespaces to the opensearch API. Follows-up I3487bb69. Bug: T67752 Bug: T32323 Change-Id: I4bec7b5548fc27ac51a1b4d4961c3bbc31eb7337
* PrefixSearchTest, SearchEnginePrefixTest: ignore ext. special pagesMatthew Flaschen2016-04-291-1/+18
| | | | | | | | | | | It was attempting to do this before, but it didn't handle special pages registered by hook, and was not clearing the list properly (so it was too late when wgSpecialPages was cleared). This would cause the test to fail if certain extensions were installed (e.g. AbuseFilter). Change-Id: I9affac5ad00e97326ebf9961bbf709ac22aef498
* Avoid rebuilding database fixtures for every test rundaniel2016-03-101-1/+1
| | | | | | | | | | | | | | | | | | | | This reduces the runtime of database-bound tests by about 40% (on my system, from 4:55 to 2:47; results from Jenkins are inconclusive). The basic idea is to call addCoreDBData() only once, and have a addDBDataOnce() that is called once per test class, not for every test method lie addDBData() is. Most tests could be trivially be changed to implement addDBDataOnce() instead of addDBData(). The ones for which this did not work immediately were left out for now. A closer look at the tests that still implement addDBData() may reveal additional potential for improvement. TODO: Once this is merged, try to change addDBData() to addDBDataOnce() where possible in extensions. Change-Id: Iec4ed4c8419fb4ad87e6710de808863ede9998b7
* build: Update mediawiki-codesniffer to 0.6.0, add "composer fix"Kunal Mehta2016-02-171-4/+4
| | | | | | | | | | * Fix errors spotted by new release * Introduce "composer fix", which uses phpcbf to automatically fix some errors spotted by phpcs. * Drop $PHPCS_ARGS variable that didn't work on Windows, and add -s flag * Remove rules from phpcs.xml that are now in MW-CS ruleset. Change-Id: I13e2155695918c918b67497ac65b85a03897095e
* Convert all array() syntax to []Kunal Mehta2016-02-171-94/+94
| | | | | | | | | | Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
* Skip adding wikitext test pages in PrefixSearchTest if NS_MAIN is not wikitextaude2015-08-141-0/+5
| | | | | | | | these tests get skipped and so should adding these pages, since it leads to a fatal error and inability to run tests on such a wiki. Bug: T97416 Change-Id: Icc4e325ecbc5ed069d12bbad686812f6a45b47e7
* PrefixSearchTest: Move insertPage() from setUp() to addDBData()Timo Tijhof2015-03-251-24/+22
| | | | | | | | Doesn't change the semantics much since run() calls addDBData() right before setUp(), but these belong addDBData() per the documentation of setUp(). Change-Id: I304a0aff1fc6b2f0541b3dc3c9e3527772c8f91c
* Fixed spacingumherirrender2014-12-051-5/+5
| | | | | | | | | | - Added/removed spaces around parenthesis - Added newline in empty blocks - Added space after switch/foreach/function - Use tabs at begin of line - Add newline at end of file Change-Id: I244cdb2c333489e1020931bf4ac5266a87439f0d
* Support offsets in prefix searchingChad Horohoe2014-12-021-0/+36
| | | | | Fixes T75522 Change-Id: I7a27a64e295a1efcb1d9728d95cf254bb8bfbe92
* Handle redirects during prefix search exact matchNik Everett2014-11-211-0/+56
| | | | | | | | | | | | | | | Prefix search attempts to find exact matches to the user's query that aren't returned by plugins. In some cases, like when the exact match is a redirect and the target of the redirect is also in the search results, it would result in multiple results in prefix search going the same place. This looks really silly when the top hit is "Barack obama" (a redirect) and the next one is "Barack Obama" (the target of the redirect). This handles a bunch of cases to do with redirects in the matches and when the exact match is a redirect. Bug: 736731 Change-Id: I49fe1ccec84bd5d1f44c6b91b260abf50f2cc3a1
* Make PrefixSearchTest use MediaWikiLangTestCaseumherirrender2014-10-201-1/+1
| | | | | | It uses namespaces which depends on the content language Change-Id: I0a1ef4adea1e1ddff32e37cbbd8cf51a3398905b
* Skip tests in PrefixSearchTest if not wikitext main namespaceaude2014-10-181-1/+7
| | | | | | | Otherwise, running core tests with non-wikitext in the main namespace fail with fatal error. Change-Id: I895e7ee61ba80c0c345b6c05f05d05c368e52d59
* PrefixSearch: Enforce including the exact match as first resultTimo Tijhof2014-10-101-1/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The default search backend implements proper prefix search and does this naturally. But extensions providing search backends like Lucene and CirrusSearch actually fail to implement proper prefix searching and instead use their search engine ranking for prefix search as well. Thus often the exact match is not on top or is not even in the first 10 results at all. On en.wikipedia.org: > Example 1. "Example (musician)" 2. "Example" 3. "Example.com" > John ive 1. "John Ives" 2. "John Ivey" 3. "John Ive" > Foo 1. "Football (soccer)" 2. "Football League Cup" 3. "Foot (length)" "Foo" exists but is NOT among the returned results. Bug: 70958 Change-Id: I78d419424baf43d38beeb6dabfc347f430fa45f6
* PrefixSearch: Add unit tests for StringPrefixSearchTimo Tijhof2014-09-231-0/+134
Change-Id: If0fa66b212f70ea39d2e7feec117930fcd1b9642