21 $priv = TestingAccessWrapper::newFromObject( $provider );
23 $provider->setConfig( $config );
25 $provider->setLogger( $logger );
27 $provider->setManager( $manager );
29 $this->
assertSame( $manager, $provider->getManager() );
31 $provider->invalidateSessionsForUser(
new \
User );
33 $this->
assertSame( [], $provider->getVaryHeaders() );
34 $this->
assertSame( [], $provider->getVaryCookies() );
39 $this->
assertNull( $provider->getRememberUserDuration() );
41 $this->
assertNull( $provider->whyNoSession() );
44 'id' =>
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
45 'provider' => $provider,
47 $metadata = [
'foo' ];
62 ->setMethods( [
'canChangeUser',
'persistsSessionId' ] )
63 ->getMockForAbstractClass();
64 $provider->expects( $this->
any() )->method(
'persistsSessionId' )
66 $provider->expects( $this->
any() )->method(
'canChangeUser' )
68 $provider->setManager( $manager );
71 $info = $provider->newSessionInfo();
76 $id =
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
77 $info = $provider->newSessionInfo( $id );
83 $this->
assertNull( $provider->newSessionInfo() );
89 ->getMockForAbstractClass();
92 $provider->mergeMetadata(
93 [
'foo' => 1,
'baz' => 3 ],
94 [
'bar' => 2,
'baz' =>
'3' ]
96 $this->fail(
'Expected exception not thrown' );
98 $this->
assertSame(
'Key "baz" changed', $ex->getMessage() );
100 [
'old_value' => 3,
'new_value' =>
'3' ], $ex->
getContext() );
103 $res = $provider->mergeMetadata(
104 [
'foo' => 1,
'baz' => 3 ],
105 [
'bar' => 2,
'baz' => 3 ]
112 [
false,
false,
false ],
113 [
true,
false,
false ],
114 [
false,
true,
false ],
115 [
true,
true,
true ],
121 ->setMethods( [
'canChangeUser',
'persistsSessionId' ] )
122 ->getMockForAbstractClass();
123 $provider->expects( $this->
any() )->method(
'canChangeUser' )
125 $provider->preventSessionsForUser(
'Foo' );
128 ->setMethods( [
'canChangeUser',
'persistsSessionId' ] )
129 ->getMockForAbstractClass();
130 $provider->expects( $this->
any() )->method(
'canChangeUser' )
133 $provider->preventSessionsForUser(
'Foo' );
134 $this->fail(
'Expected exception not thrown' );
135 }
catch ( \BadMethodCallException $ex ) {
137 'MediaWiki\\Session\\SessionProvider::preventSessionsForUser must be implemented ' .
138 'when canChangeUser() is false',
146 'SecretKey' =>
'Shhh!',
150 [],
'MockSessionProvider' );
151 $provider->setConfig( $config );
152 $priv = TestingAccessWrapper::newFromObject( $provider );
154 $this->
assertSame(
'eoq8cb1mg7j30ui5qolafps4hg29k5bb', $priv->hashToSessionId(
'foobar' ) );
155 $this->
assertSame(
'4do8j7tfld1g8tte9jqp3csfgmulaun9',
156 $priv->hashToSessionId(
'foobar',
'secret' ) );
159 $priv->hashToSessionId( [] );
160 $this->fail(
'Expected exception not thrown' );
161 }
catch ( \InvalidArgumentException $ex ) {
163 '$data must be a string, array was passed',
168 $priv->hashToSessionId(
'',
false );
169 $this->fail(
'Expected exception not thrown' );
170 }
catch ( \InvalidArgumentException $ex ) {
172 '$key must be a string or null, boolean was passed',
180 [],
'MockSessionProvider' );
183 'MockSessionProvider sessions',
184 $provider->describe( \Language::factory(
'en' ) )
193 $provider->getAllowedUserRights( $backend );
194 $this->fail(
'Expected exception not thrown' );
195 }
catch ( \InvalidArgumentException $ex ) {
197 'Backend\'s provider isn\'t $this',
202 TestingAccessWrapper::newFromObject( $backend )->provider = $provider;
203 $this->
assertNull( $provider->getAllowedUserRights( $backend ) );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
WebRequest clone which takes values from a provided array.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
processing should stop and the error should be shown to the user * false