aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/mocks/MockTitleTrait.php
Commit message (Collapse)AuthorAgeFilesLines
* Define Title::isSpecialPage in MockTitleTrait::makeMockTitleDreamy Jazz2025-01-151-0/+1
| | | | | | | | | | | | | | | | | | | Why: * The CheckUser extension wants to use the MockTitleTrait to make a mock title for a unit test. * The code being tested calls Title::isSpecialPage, but this method is not defined in the mock Title returned by MockTitleTrait::makeMockTitle. * Therefore, MockTitleTrait should mock the return value of the ::isSpecialPage method which only needs to check if the namespace is NS_SPECIAL. What: * Define Title::isSpecialPage in the Title class mock returned by MockTitleTrait::makeMockTitle Bug: T370083 Change-Id: If5a5b98299674264c33c6a87f5e0877ae0e1b241
* tests: Use namespaced classes (2)Umherirrender2024-06-131-0/+1
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statement done manually Change-Id: I4ff4d0c10820dc2a3b8419b4115fadf81a76f7a2
* Tests: enable non-integration tests to use TitleFactory service.daniel2024-04-251-0/+15
| | | | | | | | | | | | | | | | | | | | This change implements two things that can be combined to allow the usage of services like the TitleFactory in subclasses of MediaWikiUnitTestCase: 1) This adds getServiceContainer() to the MediaWikiUnitTestCase base class, to mirror the method of the same name on MediaWikiIntegrationtest case, along with a a setService() method for defining service objects for use in tests. 2) This adds makeMockTitleFactory() to the MockTitleTrait, to allow tests to esaily define the TitleFactory service. Making services available through a service container primarily benefits code that relies on ObjectFactory, like REST handlers. Needed-By: Iac113a9e766e38b2d19ae99b7e448548a515469e Change-Id: Ida6c37c7133b9e3887268025daf6e5b7c1340e52
* Add missing hasContentModel to MockTitleTraitthiemowmde2023-10-201-2/+4
| | | | | | | I worked around this with a custom mock for the moment, but would like to use the upstream trait in the future. Change-Id: Idf28d905f9fd01c24f29ad6a60419bfb4896704c
* Unit test for LinkRenderer::makeRedirectHeader() used by WikitextContentHandlerC. Scott Ananian2023-09-221-0/+2
| | | | Change-Id: I3577633670d0c2a771c690e3d6601300e1867222
* Merge "Make MockTitleTrait @stable to use."jenkins-bot2023-09-021-0/+4
|\
| * Make MockTitleTrait @stable to use.Petr Pchelko2023-09-021-0/+4
| | | | | | | | | | | | | | This is much better then mocking Titles manually in extensions. Change-Id: I40c0d118de94e85568bcb33ab1a6d1e1f9eb3eb4
* | title: Remove protection related deprecated Title functionsUmherirrender2023-05-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Title::areCascadeProtectionSourcesLoaded() - Title::areRestrictionsCascading() - Title::areRestrictionsLoaded() - Title::getAllRestrictions() - Title::getCascadeProtectionSources() - Title::getFilteredRestrictionTypes() - Title::getRestrictionExpiry() - Title::getRestrictionTypes() - Title::getRestrictions() - Title::isCascadeProtected() - Title::isProtected() - Title::isSemiProtected() - Title::loadRestrictionsFromRows() Bug: T306131 Change-Id: Id6c3a648453db51c464faeef2ecac4ffaa0676c1
* | Reorg: Namespace the Title classJames D. Forrester2023-03-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is moderately messy. Process was principally: * xargs rg --files-with-matches '^use Title;' | grep 'php$' | \ xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1' * rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \ xargs rg --files-with-matches 'Title\b' | \ xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1' * composer fix Then manual fix-ups for a few files that don't have any use statements. Bug: T166010 Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
* | Set page id to 0 for pages in virtual namespacesNikki Nikkhoui2022-03-101-1/+5
| | | | | | | | | | | | | | | | | | If we are creating a Mock title, the ID should be set to 0 for any Titles that are in "virtual" namespaces (e.g. any with a namespace ID < 0, which is Special: or Media:) Change-Id: I6aae00ae8f68ad3a93d9edd1194e828735e2a878
* | Add inNamespace support to MockTitleTraitdaniel2022-03-021-0/+3
|/ | | | | Needed-By: Ibcfe05f2c15f6148cb81463dbcdbdacb142dc58e Change-Id: I571619b8b538f496f4d1db82ee443a21ab7af42e
* Remove SearchResultPageIdentity interfacedaniel2021-05-101-0/+29
| | | | | | | | | | | SearchResultPageIdentity and SearchResultPageIdentityValue were introduced as placeholders for PageIdentity and PageIdentityValues. They can now become aliases. Bug: T282091 Depends-On: I9b1ab02e0acf12ace107361ea2c443aa543c4880 Depends-On: Ie405ea9539cd18e15b0abb6db6df64ec0135825d Change-Id: I6eb55c78a0a72be66814f8bc854ba663e7c6f62b
* Add MediaWikiTitleCodec and NamespaceInfo to DummyServicesTraitDannyS7122021-05-041-72/+0
| | | | | | | | | | | | | | | | | | | | Move MockTitleTrait::makeMockTitleCodec to DummyServicesTrait, and replace the two existing uses, which are in core. Add some new uses instead of mocking each time. Unfortunately, we cannot use an actual MediaWikiTitleCodec for the tests in BadFileLookup, because those tests are unit tests and a MalformedTitleException cannot be created in the context of a unit test. BadFileLookupTest gets around this by using a mock that throws a mock exception - add a comment inline explaining why we cannot use a real MediaWikiTitleCodec. Paired with adding of NamespaceInfo to make mocking the language methods related to namespaces easier by matching the real logic in the Language class to the extend possible. Update a few tests to use the DummyServicesTrait for their NamespaceInfo services. Change-Id: Ibd691ccf0e632e1bf0bc1f7e9ddc0c660d5cad32
* Merge "MockTitleTrait: clean up makeMockTitle"jenkins-bot2021-05-031-2/+7
|\
| * MockTitleTrait: clean up makeMockTitleDannyS7122021-05-031-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't mock Title::getContentModel() twice: The first time, its either $props['contentModel'] or falling back to CONTENT_MODEL_WIKITEXT, and the second was just always CONTENT_MODEL_WIKITEXT - keep the first. Update the documentation with latest supported options. Add a todo about ::getPageLanguage() returning 'qqx' by default, it should be returning a Language object Change-Id: I715e46ecc56288be5f8cbd8672ffe051b2c3f8d9
* | Expand functionality of MediaWikiTitleCodec in MockTitleTraitDannyS7122021-05-031-3/+45
|/ | | | | | | | Add support for full interwiki handling, and then use this service in UserNameUtilsTest as a step towards making that test a full unit test Change-Id: I3b54909e33e69fea8bb5ec55c99848c196859185
* Remove Title from public interface of OutputPagedaniel2021-04-161-0/+1
| | | | | Bug: T278459 Change-Id: If455682540faf8d42fd8a14e0ef09bac24f72db4
* Convert WatchedItem et al to PageIdentityCindy Cicalese2021-03-261-1/+2
| | | | Change-Id: Iddcd109b7f78efdbcb0e4016e81fd2c8d4666b46
* Merge "phpunit: Don't redefine methods in traits"jenkins-bot2021-03-241-19/+0
|\
| * phpunit: Don't redefine methods in traitsDaimona Eaytoy2021-03-231-19/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The signatures of these methods will change in PHPUnit 9, and in general, having these methods means additional code to maintain. Since this is test code, any attempt to use these traits from a class which doesn't have the required methods will fail hard, and as such, there's no reason to have these methods at all. Also, MockServiceDependenciesTrait was redeclaring fail() as a non-static method, but it is actually static in the parent class, which makes tests fail on PHP 8. Bug: T243600 Change-Id: I78bf1bdd2eb2e09aed27d1b6bff2302e28600703
* | Introduce PageStoredaniel2021-03-231-1/+5
|/ | | | | | | | | | | PageStore is unused so far, usage will be demonstrated in follow-up patches. For now, this only implements the lookup (read) functionality of PageStore. Bug: T195069 Change-Id: I25cb9945795ecaf2d0b816a5abc7362424d11ba4
* Convert MovePage to AuthorityPetr Pchelko2021-03-171-0/+1
| | | | Change-Id: I7d4503711ab1b739ca88b5fd0aa9e336cbac06aa
* Deprecate constructing revision with non-proper pagePetr Pchelko2021-03-101-0/+13
| | | | | Bug: T275531 Change-Id: If641a5a901210ba1a1ea6a41fa6a18c08f4183db
* Convert EditConstraints to AuthorityPetr Pchelko2021-03-031-0/+3
| | | | | Bug: T271977 Change-Id: I12a2f71f52a1ba7e94bf325621e62ed0e255601b
* Tests: Mark more more closures as staticUmherirrender2021-02-091-2/+2
| | | | | | | Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208 Bug: T274036 Change-Id: I695873737167a75f0d94901fa40383a33984ca55
* Make vast majority of RevisionRecord tests unit.Petr Pchelko2021-01-221-2/+9
| | | | Change-Id: Icc94fbd7090ee5f73fc1fba353ff7c936436f76f
* Convert RevisionRecord to Authority and PageIdentityPetr Pchelko2021-01-211-0/+3
| | | | | | | | | | | | | | | | | | | As we convert the RevisionRecord to using Authority, we no longer need Title instances, so we can convert that to PageIdentity. Ideally, we'd part away from using Title at all, but: 1. For foreign wikis PageIdentity has stronger validation, so calling PageIdentity getId() on Title will break things. There's still a lot of code depending on lax Title guarantees, so we keep it. 2. A lot of code still depends on Title, so we try to pass it through even if we don't nesessarily need to, to save cost on recreating it later on. Bug: T271458 Depends-On: I287400b967b467ea18bebbb579e881a785a19158 Change-Id: I63d9807264d7e2295afef51fc9d982447f92fcbd
* Split title mocking methods out of HandlerTestTrait.Petr Pchelko2021-01-131-0/+96
The functionality of creating title mocks is generally useful and this will also allow to make HandlerTestTrait more narrow. Bug: T264058 Change-Id: I76eca48dfcff65a6203fccde5366912a2d66c495