mediawiki-skins-Vector/tests/phpunit/unit/FeatureManagement/Requirements/LatestSkinVersionRequirementTest.php
Jon Robson b109e10cf3 End migration mode
Can be merged when database rows have been updated to
no longer use skin version.

* Drop migration code
* Drop skin version preference
* Drop default skin version and existing accounts skin version
* Move skin definitions into skin.json
* Repurpose SkinVector as an abstract class
* Update READMEs

Bug: T301930
Bug: T294995
Bug: T302627
Change-Id: I7454d8f1cfdef81e7f3df476d8ce86736b46fff2
2022-03-23 16:46:42 +00:00

70 lines
2.3 KiB
PHP

<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
namespace Vector\FeatureManagement\Tests;
use MediaWiki\User\UserOptionsLookup;
use User;
use Vector\FeatureManagement\Requirements\LatestSkinVersionRequirement;
use WebRequest;
/**
* @group Vector
* @group FeatureManagement
* @coversDefaultClass \Vector\FeatureManagement\Requirements\LatestSkinVersionRequirement
*/
class LatestSkinVersionRequirementTest extends \MediaWikiUnitTestCase {
public function provideIsMet() {
// $version, $expected, $msg
yield 'not met' => [ 'vector', null, false, '"1" isn\'t considered latest.' ];
yield 'met' => [ 'vector-2022', null, true, '"2" is considered latest.' ];
yield 'met (useskin override)' => [ 'vector', 'vector-2022', true, 'useskin overrides' ];
yield 'not met (useskin override)' => [ 'vector-2022', 'vector', false, 'useskin overrides' ];
}
/**
* @dataProvider provideIsMet
* @covers ::isMet
*/
public function testIsMet( $skin, $useSkin, $expected, $msg ) {
$user = $this->createMock( User::class );
$user->method( 'isRegistered' )->willReturn( true );
$user->method( 'isSafeToLoad' )->willReturn( true );
$userOptionsLookup = $this->createMock( UserOptionsLookup::class );
$userOptionsLookup->method( 'getOption' )
->willReturn( $skin );
$request = $this->createMock( WebRequest::class );
$request->method( 'getVal' )
->willReturn( $useSkin );
$requirement = new LatestSkinVersionRequirement(
$request,
$user,
$userOptionsLookup
);
$this->assertSame( $expected, $requirement->isMet(), $msg );
}
}