getMockBuilder( \WebRequest::class )->getMock(); $request ->expects( $this->exactly( 2 ) ) ->method( 'getVal' ) ->with( $this->anything(), $this->equalTo( '1' ) ) ->willReturn( 'beta' ); $user = $this->createMock( \User::class ); $user ->expects( $this->exactly( 2 ) ) ->method( 'getOption' ) ->with( $this->anything(), $this->equalTo( '2' ) ) ->willReturn( '1' ); $config = new HashConfig( [ 'VectorDefaultSkinVersion' => '2' ] ); $skinVersionLookup = new SkinVersionLookup( $request, $user, $config ); $this->assertSame( $skinVersionLookup->getVersion(), 'beta', 'Query parameter is the first priority.' ); $this->assertSame( $skinVersionLookup->isLegacy(), false, 'Version is non-legacy.' ); } /** * @covers ::getVersion * @covers ::isLegacy */ public function testUserPreference() { $request = $this->getMockBuilder( \WebRequest::class )->getMock(); $request ->expects( $this->exactly( 2 ) ) ->method( 'getVal' ) ->with( $this->anything(), $this->equalTo( '1' ) ) ->willReturn( '1' ); $user = $this->createMock( \User::class ); $user ->expects( $this->exactly( 2 ) ) ->method( 'getOption' ) ->with( $this->anything(), $this->equalTo( '2' ) ) ->willReturn( '1' ); $config = new HashConfig( [ 'VectorDefaultSkinVersion' => '2' ] ); $skinVersionLookup = new SkinVersionLookup( $request, $user, $config ); $this->assertSame( $skinVersionLookup->getVersion(), '1', 'User preference is the second priority.' ); $this->assertSame( $skinVersionLookup->isLegacy(), true, 'Version is legacy.' ); } /** * @covers ::getVersion * @covers ::isLegacy */ public function testConfig() { $request = $this->getMockBuilder( \WebRequest::class )->getMock(); $request ->expects( $this->exactly( 2 ) ) ->method( 'getVal' ) ->with( $this->anything(), $this->equalTo( '2' ) ) ->willReturn( '2' ); $user = $this->createMock( \User::class ); $user ->expects( $this->exactly( 2 ) ) ->method( 'getOption' ) ->with( $this->anything(), $this->equalTo( '2' ) ) ->willReturn( '2' ); $config = new HashConfig( [ 'VectorDefaultSkinVersion' => '2' ] ); $skinVersionLookup = new SkinVersionLookup( $request, $user, $config ); $this->assertSame( $skinVersionLookup->getVersion(), '2', 'Config is the third priority.' ); $this->assertSame( $skinVersionLookup->isLegacy(), false, 'Version is non-legacy.' ); } }