aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/unit/includes/api
diff options
context:
space:
mode:
authorCindy Cicalese <cindom@gmail.com>2021-04-12 23:28:23 -0400
committerCicalese <ccicalese@wikimedia.org>2021-04-21 04:41:06 +0000
commitb242d49a620464c1cdc69d5f183010d449f34049 (patch)
tree87182e5bb70b75efd93b3ae6ca0f41fe58ed4cf3 /tests/phpunit/unit/includes/api
parent63a29ba72217bab33c34c8021205d9e2446cfa02 (diff)
downloadmediawikicore-b242d49a620464c1cdc69d5f183010d449f34049.tar.gz
mediawikicore-b242d49a620464c1cdc69d5f183010d449f34049.zip
Use WatchlistManager in API classes
Change-Id: I7b2016162e86b455c0102742751981c44d7e829c
Diffstat (limited to 'tests/phpunit/unit/includes/api')
-rw-r--r--tests/phpunit/unit/includes/api/ApiWatchlistTraitTest.php56
1 files changed, 0 insertions, 56 deletions
diff --git a/tests/phpunit/unit/includes/api/ApiWatchlistTraitTest.php b/tests/phpunit/unit/includes/api/ApiWatchlistTraitTest.php
deleted file mode 100644
index a2341169bf8f..000000000000
--- a/tests/phpunit/unit/includes/api/ApiWatchlistTraitTest.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-
-use Wikimedia\TestingAccessWrapper;
-
-/**
- * @group API
- * @covers ApiWatchlistTrait
- */
-class ApiWatchlistTraitTest extends MediaWikiUnitTestCase {
-
- /**
- * @dataProvider provideWatchlistValue
- */
- public function testWatchlistValue( $watchlistValue, $setOption, $isBot, $isWatched, $expect ) {
- $mock = $this->getMockForTrait( ApiWatchlistTrait::class );
-
- // TODO we don't currently test any of the logic that depends on if the title exists
- $user = $this->createMock( User::class );
- $user->method( 'isBot' )->willReturn( $isBot );
- $user->method( 'isWatched' )->willReturn( $isWatched );
- $user->method( 'getBoolOption' )->willReturnCallback(
- function ( $optionName ) use ( $setOption ) {
- if ( $optionName === 'watchdefault' ) {
- return (bool)$setOption;
- }
- // watchcreations is not currently tested, by default it is enabled
- return true;
- }
- );
-
- $title = $this->createMock( Title::class );
- $title->method( 'exists' )->willReturn( true );
-
- $watch = TestingAccessWrapper::newFromObject( $mock )
- ->getWatchlistValue( $watchlistValue, $title, $user, 'watchdefault' );
- $this->assertEquals( $expect, $watch );
- }
-
- public function provideWatchlistValue() {
- return [
- 'watch option on unwatched page' => [ 'watch', null, false, false, true ],
- 'watch option on watched page' => [ 'watch', null, false, true, true ],
- 'unwatch option on unwatched page' => [ 'unwatch', null, false, false, false ],
- 'unwatch option on watched page' => [ 'unwatch', null, false, true, false ],
- 'preferences set to true on unwatched page' => [ 'preferences', true, false, false, true ],
- 'preferences set to false on unwatched page' => [ 'preferences', false, false, false, false ],
- 'preferences set to true on unwatched page (bot group)' => [ 'preferences', true, true, false, false ],
- 'preferences set to true on watched page (bot group)' => [ 'preferences', true, true, true, true ],
- 'preferences set to false on unwatched page (bot group)' => [ 'preferences', false, true, false, false ],
- 'preferences set to false on watched page (bot group)' => [ 'preferences', false, true, true, true ],
- 'nochange option on watched page' => [ 'nochange', null, false, true, true ],
- 'nochange option on unwatched page' => [ 'nochange', null, false, false, false ],
- ];
- }
-
-}