X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fsession%2FCookieSessionProviderTest.php;h=a47fd9a18b9a0e6a14644250634050adbef39cad;hb=6c9a2923fe1ee3a65cb027be5e781772f2b12fbd;hp=da4b06ec831af8b11e2c759aa64be1306a03f4d6;hpb=fe922d470fbddff5617448e0d90df3e18c04644e;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/session/CookieSessionProviderTest.php b/tests/phpunit/includes/session/CookieSessionProviderTest.php index da4b06ec83..a47fd9a18b 100644 --- a/tests/phpunit/includes/session/CookieSessionProviderTest.php +++ b/tests/phpunit/includes/session/CookieSessionProviderTest.php @@ -5,6 +5,7 @@ namespace MediaWiki\Session; use MediaWikiTestCase; use User; use Psr\Log\LogLevel; +use Wikimedia\TestingAccessWrapper; /** * @group Session @@ -76,7 +77,7 @@ class CookieSessionProviderTest extends MediaWikiTestCase { } $config = $this->getConfig(); - $p = \TestingAccessWrapper::newFromObject( + $p = TestingAccessWrapper::newFromObject( new CookieSessionProvider( [ 'priority' => 1 ] ) ); $p->setLogger( new \TestLogger() ); @@ -95,7 +96,7 @@ class CookieSessionProviderTest extends MediaWikiTestCase { ], $p->cookieOptions ); $config->set( 'SessionName', 'SessionName' ); - $p = \TestingAccessWrapper::newFromObject( + $p = TestingAccessWrapper::newFromObject( new CookieSessionProvider( [ 'priority' => 3 ] ) ); $p->setLogger( new \TestLogger() ); @@ -113,7 +114,7 @@ class CookieSessionProviderTest extends MediaWikiTestCase { 'httpOnly' => true, ], $p->cookieOptions ); - $p = \TestingAccessWrapper::newFromObject( new CookieSessionProvider( [ + $p = TestingAccessWrapper::newFromObject( new CookieSessionProvider( [ 'priority' => 10, 'callUserSetCookiesHook' => true, 'cookieOptions' => [ @@ -151,7 +152,7 @@ class CookieSessionProviderTest extends MediaWikiTestCase { $this->assertEquals( $extendedCookies, - \TestingAccessWrapper::newFromObject( $provider )->getExtendedLoginCookies(), + TestingAccessWrapper::newFromObject( $provider )->getExtendedLoginCookies(), 'List of extended cookies (subclasses can add values, but we\'re calling the core one here)' ); @@ -412,9 +413,11 @@ class CookieSessionProviderTest extends MediaWikiTestCase { new \Psr\Log\NullLogger(), 10 ); - \TestingAccessWrapper::newFromObject( $backend )->usePhpSessionHandling = false; + TestingAccessWrapper::newFromObject( $backend )->usePhpSessionHandling = false; - $mock = $this->getMock( 'stdClass', [ 'onUserSetCookies' ] ); + $mock = $this->getMockBuilder( 'stdClass' ) + ->setMethods( [ 'onUserSetCookies' ] ) + ->getMock(); $mock->expects( $this->never() )->method( 'onUserSetCookies' ); $this->mergeMwGlobalArrayValue( 'wgHooks', [ 'UserSetCookies' => [ $mock ] ] ); @@ -497,7 +500,7 @@ class CookieSessionProviderTest extends MediaWikiTestCase { new \Psr\Log\NullLogger(), 10 ); - \TestingAccessWrapper::newFromObject( $backend )->usePhpSessionHandling = false; + TestingAccessWrapper::newFromObject( $backend )->usePhpSessionHandling = false; $backend->setUser( $user ); $backend->setRememberUser( $remember ); $backend->setForceHTTPS( $secure ); @@ -560,13 +563,15 @@ class CookieSessionProviderTest extends MediaWikiTestCase { } protected function getSentRequest() { - $sentResponse = $this->getMock( 'FauxResponse', [ 'headersSent', 'setCookie', 'header' ] ); + $sentResponse = $this->getMockBuilder( 'FauxResponse' ) + ->setMethods( [ 'headersSent', 'setCookie', 'header' ] )->getMock(); $sentResponse->expects( $this->any() )->method( 'headersSent' ) ->will( $this->returnValue( true ) ); $sentResponse->expects( $this->never() )->method( 'setCookie' ); $sentResponse->expects( $this->never() )->method( 'header' ); - $sentRequest = $this->getMock( 'FauxRequest', [ 'response' ] ); + $sentRequest = $this->getMockBuilder( 'FauxRequest' ) + ->setMethods( [ 'response' ] )->getMock(); $sentRequest->expects( $this->any() )->method( 'response' ) ->will( $this->returnValue( $sentResponse ) ); return $sentRequest; @@ -600,10 +605,11 @@ class CookieSessionProviderTest extends MediaWikiTestCase { new \Psr\Log\NullLogger(), 10 ); - \TestingAccessWrapper::newFromObject( $backend )->usePhpSessionHandling = false; + TestingAccessWrapper::newFromObject( $backend )->usePhpSessionHandling = false; // Anonymous user - $mock = $this->getMock( 'stdClass', [ 'onUserSetCookies' ] ); + $mock = $this->getMockBuilder( 'stdClass' ) + ->setMethods( [ 'onUserSetCookies' ] )->getMock(); $mock->expects( $this->never() )->method( 'onUserSetCookies' ); $this->mergeMwGlobalArrayValue( 'wgHooks', [ 'UserSetCookies' => [ $mock ] ] ); $backend->setUser( $anon ); @@ -621,7 +627,8 @@ class CookieSessionProviderTest extends MediaWikiTestCase { $provider->persistSession( $backend, $this->getSentRequest() ); // Logged-in user, no remember - $mock = $this->getMock( __CLASS__, [ 'onUserSetCookies' ] ); + $mock = $this->getMockBuilder( __CLASS__ ) + ->setMethods( [ 'onUserSetCookies' ] )->getMock(); $mock->expects( $this->once() )->method( 'onUserSetCookies' ) ->will( $this->returnCallback( function ( $u, &$sessionData, &$cookies ) use ( $user ) { $this->assertSame( $user, $u ); @@ -664,7 +671,8 @@ class CookieSessionProviderTest extends MediaWikiTestCase { $provider->persistSession( $backend, $this->getSentRequest() ); // Logged-in user, remember - $mock = $this->getMock( __CLASS__, [ 'onUserSetCookies' ] ); + $mock = $this->getMockBuilder( __CLASS__ ) + ->setMethods( [ 'onUserSetCookies' ] )->getMock(); $mock->expects( $this->once() )->method( 'onUserSetCookies' ) ->will( $this->returnCallback( function ( $u, &$sessionData, &$cookies ) use ( $user ) { $this->assertSame( $user, $u ); @@ -729,7 +737,7 @@ class CookieSessionProviderTest extends MediaWikiTestCase { } public function testSetLoggedOutCookie() { - $provider = \TestingAccessWrapper::newFromObject( new CookieSessionProvider( [ + $provider = TestingAccessWrapper::newFromObject( new CookieSessionProvider( [ 'priority' => 1, 'sessionName' => 'MySessionName', 'cookieOptions' => [ 'prefix' => 'x' ], @@ -776,7 +784,7 @@ class CookieSessionProviderTest extends MediaWikiTestCase { $provider->setLogger( new \Psr\Log\NullLogger() ); $provider->setConfig( $this->getConfig() ); $provider->setManager( SessionManager::singleton() ); - $provider = \TestingAccessWrapper::newFromObject( $provider ); + $provider = TestingAccessWrapper::newFromObject( $provider ); $request = new \FauxRequest(); $request->setCookies( [ @@ -808,7 +816,7 @@ class CookieSessionProviderTest extends MediaWikiTestCase { public function testGetLoginCookieExpiration() { $config = $this->getConfig(); - $provider = \TestingAccessWrapper::newFromObject( new CookieSessionProvider( [ + $provider = TestingAccessWrapper::newFromObject( new CookieSessionProvider( [ 'priority' => 10 ] ) ); $provider->setLogger( new \Psr\Log\NullLogger() );