X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fsession%2FSessionBackendTest.php;h=4a28f7ae1d8c3c991c15b5170c452d1c853e4edd;hp=a3d5de772c71e1bec4c259f4571ed3d95b05ec74;hb=424251a2cb5842727756d96f877c787c443ea056;hpb=b746001c6659413c70b12651075872532de6130c diff --git a/tests/phpunit/includes/session/SessionBackendTest.php b/tests/phpunit/includes/session/SessionBackendTest.php index a3d5de772c..4a28f7ae1d 100644 --- a/tests/phpunit/includes/session/SessionBackendTest.php +++ b/tests/phpunit/includes/session/SessionBackendTest.php @@ -293,7 +293,8 @@ class SessionBackendTest extends MediaWikiTestCase { } public function testPersist() { - $this->provider = $this->getMock( 'DummySessionProvider', [ 'persistSession' ] ); + $this->provider = $this->getMockBuilder( 'DummySessionProvider' ) + ->setMethods( [ 'persistSession' ] )->getMock(); $this->provider->expects( $this->once() )->method( 'persistSession' ); $backend = $this->getBackend(); $this->assertFalse( $backend->isPersistent(), 'sanity check' ); @@ -312,7 +313,8 @@ class SessionBackendTest extends MediaWikiTestCase { } public function testUnpersist() { - $this->provider = $this->getMock( 'DummySessionProvider', [ 'unpersistSession' ] ); + $this->provider = $this->getMockBuilder( 'DummySessionProvider' ) + ->setMethods( [ 'unpersistSession' ] )->getMock(); $this->provider->expects( $this->once() )->method( 'unpersistSession' ); $backend = $this->getBackend(); $wrap = \TestingAccessWrapper::newFromObject( $backend ); @@ -362,7 +364,8 @@ class SessionBackendTest extends MediaWikiTestCase { public function testSetUser() { $user = static::getTestSysop()->getUser(); - $this->provider = $this->getMock( 'DummySessionProvider', [ 'canChangeUser' ] ); + $this->provider = $this->getMockBuilder( 'DummySessionProvider' ) + ->setMethods( [ 'canChangeUser' ] )->getMock(); $this->provider->expects( $this->any() )->method( 'canChangeUser' ) ->will( $this->returnValue( false ) ); $backend = $this->getBackend(); @@ -464,7 +467,7 @@ class SessionBackendTest extends MediaWikiTestCase { // Save happens when delay is consumed $this->onSessionMetadataCalled = false; $priv->metaDirty = true; - \ScopedCallback::consume( $delay ); + \Wikimedia\ScopedCallback::consume( $delay ); $this->assertTrue( $this->onSessionMetadataCalled ); // Test multiple delays @@ -475,11 +478,11 @@ class SessionBackendTest extends MediaWikiTestCase { $priv->metaDirty = true; $priv->autosave(); $this->assertFalse( $this->onSessionMetadataCalled ); - \ScopedCallback::consume( $delay3 ); + \Wikimedia\ScopedCallback::consume( $delay3 ); $this->assertFalse( $this->onSessionMetadataCalled ); - \ScopedCallback::consume( $delay1 ); + \Wikimedia\ScopedCallback::consume( $delay1 ); $this->assertFalse( $this->onSessionMetadataCalled ); - \ScopedCallback::consume( $delay2 ); + \Wikimedia\ScopedCallback::consume( $delay2 ); $this->assertTrue( $this->onSessionMetadataCalled ); } @@ -488,7 +491,8 @@ class SessionBackendTest extends MediaWikiTestCase { $this->store = new TestBagOStuff(); $testData = [ 'foo' => 'foo!', 'bar', [ 'baz', null ] ]; - $neverHook = $this->getMock( __CLASS__, [ 'onSessionMetadata' ] ); + $neverHook = $this->getMockBuilder( __CLASS__ ) + ->setMethods( [ 'onSessionMetadata' ] )->getMock(); $neverHook->expects( $this->never() )->method( 'onSessionMetadata' ); $builder = $this->getMockBuilder( 'DummySessionProvider' ) @@ -694,7 +698,8 @@ class SessionBackendTest extends MediaWikiTestCase { // Bad hook $this->provider = null; - $mockHook = $this->getMock( __CLASS__, [ 'onSessionMetadata' ] ); + $mockHook = $this->getMockBuilder( __CLASS__ ) + ->setMethods( [ 'onSessionMetadata' ] )->getMock(); $mockHook->expects( $this->any() )->method( 'onSessionMetadata' ) ->will( $this->returnCallback( function ( SessionBackend $backend, array &$metadata, array $requests ) { @@ -738,7 +743,8 @@ class SessionBackendTest extends MediaWikiTestCase { $testData = [ 'foo' => 'foo!', 'bar', [ 'baz', null ] ]; // Not persistent - $this->provider = $this->getMock( 'DummySessionProvider', [ 'persistSession' ] ); + $this->provider = $this->getMockBuilder( 'DummySessionProvider' ) + ->setMethods( [ 'persistSession' ] )->getMock(); $this->provider->expects( $this->never() )->method( 'persistSession' ); $this->onSessionMetadataCalled = false; $this->mergeMwGlobalArrayValue( 'wgHooks', [ 'SessionMetadata' => [ $this ] ] ); @@ -763,7 +769,8 @@ class SessionBackendTest extends MediaWikiTestCase { $this->assertNotEquals( 0, $wrap->expires ); // Persistent - $this->provider = $this->getMock( 'DummySessionProvider', [ 'persistSession' ] ); + $this->provider = $this->getMockBuilder( 'DummySessionProvider' ) + ->setMethods( [ 'persistSession' ] )->getMock(); $this->provider->expects( $this->atLeastOnce() )->method( 'persistSession' ); $this->onSessionMetadataCalled = false; $this->mergeMwGlobalArrayValue( 'wgHooks', [ 'SessionMetadata' => [ $this ] ] ); @@ -789,7 +796,8 @@ class SessionBackendTest extends MediaWikiTestCase { $this->assertNotEquals( 0, $wrap->expires ); // Not persistent, not expiring - $this->provider = $this->getMock( 'DummySessionProvider', [ 'persistSession' ] ); + $this->provider = $this->getMockBuilder( 'DummySessionProvider' ) + ->setMethods( [ 'persistSession' ] )->getMock(); $this->provider->expects( $this->never() )->method( 'persistSession' ); $this->onSessionMetadataCalled = false; $this->mergeMwGlobalArrayValue( 'wgHooks', [ 'SessionMetadata' => [ $this ] ] ); @@ -822,7 +830,7 @@ class SessionBackendTest extends MediaWikiTestCase { $rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' ); $rProp->setAccessible( true ); $handler = \TestingAccessWrapper::newFromObject( $rProp->getValue() ); - $resetHandler = new \ScopedCallback( function () use ( $handler ) { + $resetHandler = new \Wikimedia\ScopedCallback( function () use ( $handler ) { session_write_close(); $handler->enable = false; } ); @@ -862,7 +870,7 @@ class SessionBackendTest extends MediaWikiTestCase { $rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' ); $rProp->setAccessible( true ); $handler = \TestingAccessWrapper::newFromObject( $rProp->getValue() ); - $resetHandler = new \ScopedCallback( function () use ( $handler ) { + $resetHandler = new \Wikimedia\ScopedCallback( function () use ( $handler ) { session_write_close(); $handler->enable = false; } ); @@ -898,7 +906,7 @@ class SessionBackendTest extends MediaWikiTestCase { $rProp = new \ReflectionProperty( PHPSessionHandler::class, 'instance' ); $rProp->setAccessible( true ); $handler = \TestingAccessWrapper::newFromObject( $rProp->getValue() ); - $resetHandler = new \ScopedCallback( function () use ( $handler ) { + $resetHandler = new \Wikimedia\ScopedCallback( function () use ( $handler ) { session_write_close(); $handler->enable = false; } );