aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/unit/includes/api
Commit message (Collapse)AuthorAgeFilesLines
* Add namespace to includes/api classesJames D. Forrester2024-09-252-17/+17
| | | | | Bug: T353458 Change-Id: I3ea6b08c5018ba03ba45c5766e1f46e12f6b8597
* Import InvalidArgumentException at top of the sourceEbrahim Byagowi2024-05-191-1/+2
| | | | | | | | | | | | | | It was asked in a patch review to apply fully import InvalidArgumentException where possible. I was guessing some of my other already merged patches have but turned out such thing exists other places style so for the sake of consistency I've turned rest of inline import of the specific exception at top of the file. There are instances of source files that aren't in any namespace but have fully qualified import which this patch doesn't touch. Change-Id: I4071fc698b65746d9594cf4d5f45bae82843d436
* tests: Namespace api testsReedy2024-02-182-0/+14
| | | | | Bug: T357823 Change-Id: I0d7cc2c9b166d5e5b913c1305f7cee017fe377af
* tests: Fix @covers and @coversDefaultClass to have leading \Reedy2024-02-162-9/+9
| | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* Namespace includes/contextJames D. Forrester2024-02-081-0/+1
| | | | | Bug: T353458 Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
* tests: Use namespaced classesUmherirrender2023-12-111-0/+1
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statements and changes to docs done manually Change-Id: Ib326ae1e5c8409a98398c721e8b8ce42c73bd012
* Move user options related classes into its own namespaceMartin Urbanec2023-11-291-1/+1
| | | | | | | | | | | | | There are a couple of user options related classes already, and the T321527 work on dynamic defaults is going to add even more. Let's move them into a separate namespace to make core a bit more organized. Old name is kept as an alias for compatibility purposes. Bug: T321527 Bug: T352284 Change-Id: I9822eb1553870b876d0b8a927e4e86c27d83bd52
* Replace array_keys in foreach to use $_ as value insteadUmherirrender2023-07-101-1/+1
| | | | | | | | When the value of the associated array is not used, there is no need to use array_keys and create internal a copy of the array, just omit the value with $_ to tell static analyzer that the var is unused. Change-Id: I5c6d667e98c0167c0573c683f0d617bc1d4ca619
* tests: Make some PHPUnit data providers staticTim Starling2023-03-241-1/+1
| | | | | | | | | | | | | Just methods where adding "static" to the declaration was enough, I didn't do anything with providers that used $this. Initially by search and replace. There were many mistakes which I found mostly by running the PHPStorm inspection which searches for $this usage in a static method. Later I used the PHPStorm "make static" action which avoids the more obvious mistakes. Bug: T332865 Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
* 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
* Tests: add ObjectFactory to DummyServicesTraitDannyS7122023-01-231-7/+6
| | | | | | | | Mocks a ContainerInterface to support a specific list of services, with has() and get() working correctly, and uses that for a real ObjectFactory object. Change-Id: Ie49b5a34e0f449cc4b9f6b31d6cc1bc943d04b43
* Use updated ObjectFactory namespaceAlexander Vorwerk2022-03-091-1/+1
| | | | | | | Depends-On: I99c5e5664d2401c36a9890f148eba7c25e6e8324 Depends-On: I48ab818b2965da14af15ef370aa83ad9455badd9 Depends-On: I018371e4b77911e56152ca7b2df734afc73f58a5 Change-Id: I04ebdb52102f6191d49a9cc70b1f98308299e72f
* Move ApiWatchlistTraitTest back to unit testsDannyS7122021-07-061-0/+64
| | | | | | All dependencies are once again injected Change-Id: I0c7d45fcb8d451a92dcf438a076a24cf231827d8
* Inject AuthManager into some api classesDannyS7122021-05-291-33/+33
| | | | | | | | | | | | | | | | | - ApiAMCreateAccount - ApiClientLogin - ApiChangeAuthenticationData - ApiLinkAccount - ApiLogin - ApiRemoveAuthenticationData Now that ApiLogin needs services injected, update ApiModuleManagerTest to use ApiRsd as the example api module that doesn't need any services. Bug: T259960 Change-Id: If78457f1d859d3d575f2016ef4b212263473cea6
* Remove ApiUnblock unit test.Petr Pchelko2021-04-271-334/+0
| | | | | | | | | | The class already has decent coverage with integration tests, and I couldn't find anything the unit test provides in addition. The unit tests is trying to mock the world, which locks the implementation in place - any attempt to change internals of the API module breaks the test. Change-Id: I3eabd089faab04710828a0bba37f112721f9f888
* Remove unnecessary ->equalTo() from testsThiemo Kreuz2021-04-231-40/+13
| | | | | | | | | | | | | This is the default anyway when using ->with(). The test code becomes so much more readable without this, I would like to argue. Let it just say "with these values". Because of the way I split my changes into multiple patches there are a few other changes in this patch I could not split, e.g. removing unnecessary ->any(). This is the default anyway and doesn't make the test more specific. Change-Id: I34990799fa9258ba8dc64c7e78ec43f7903b7681
* Use WatchlistManager in API classesCindy Cicalese2021-04-211-56/+0
| | | | Change-Id: I7b2016162e86b455c0102742751981c44d7e829c
* phpunit: Mass-replace setMethods with onlyMethods and adjustDaimona Eaytoy2021-04-161-1/+1
| | | | | | | | | | | | Ended up using grep -Prl '\->setMethods\(' . | xargs sed -r -i 's/setMethods\(/onlyMethods\(/g' special-casing setMethods( null ) -> onlyMethods( [] ) and then manual fix of failing test (from PS2 onwards). Bug: T278010 Change-Id: I012dca7ae774bb430c1c44d50991ba0b633353f1
* Merge "Make ApiWatchlistTraitTest a pure unit test"jenkins-bot2021-03-011-0/+56
|\
| * Make ApiWatchlistTraitTest a pure unit testDannyS7122021-02-261-0/+56
| | | | | | | | | | | | We can use mocks :) Change-Id: Ic0ca07191598e22741a14bb7f0d8f08fe4c98e41
* | ApiUnblockTest: fix file locationDannyS7122021-02-271-0/+361
| | | | | | | | | | | | Should have been under /includes/api Change-Id: Id2a61d1f8724fd4de0afd86dadb5fbd69e1819fc
* | Make ApiModuleManagerTest a pure unit testDannyS7122021-02-261-0/+393
|/ | | | | | | | Switch test case with services to use a service other than ObjectFactory, to make it easier to mock. Change-Id: I374a516b6bcc8111b2432245faf935f8287d45a7
* Revert "Separate MediaWiki unit and integration tests"Legoktm2019-06-135-1914/+0
| | | | | | | | This reverts commit 0a2b996278e57a8b8c5377cd3a3eaa54f993d4a9. Reason for revert: Broke postgres tests. Change-Id: I27d8e0c807ad5f0748b9611a4f3df84cc213fbe1
* Separate MediaWiki unit and integration testsMáté Szabó2019-06-135-0/+1914
This changeset implements T89432 and related tickets and is based on exploration done at the Prague Hackathon. The goal is to identify tests in MediaWiki core that can be run without having to install & configure MediaWiki and its dependencies, and provide a way to execute these tests via the standard phpunit entry point, allowing for faster development and integration with existing tooling like IDEs. The initial set of tests that met these criteria were identified using the work Amir did in I88822667693d9e00ac3d4639c87bc24e5083e5e8. These tests were then moved into a new subdirectory under phpunit/ and organized into a separate test suite. The environment for this suite is set up via a PHPUnit bootstrap file without a custom entry point. You can execute these tests by running: $ vendor/bin/phpunit -d memory_limit=512M -c tests/phpunit/unit-tests.xml Bug: T89432 Bug: T87781 Bug: T84948 Change-Id: Iad01033a0548afd4d2a6f2c1ef6fcc9debf72c0d