| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Tests\Rest\Handler; |
| 4 |
|
| 5 |
use MediaWiki\Session\Session; |
| 6 |
use MediaWiki\Session\SessionId; |
| 7 |
use MediaWiki\Session\SessionProviderInterface; |
| 8 |
use PHPUnit\Framework\MockObject\MockObject; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
trait SessionHelperTestTrait { |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
public function getSession( bool $csrfSafe ) { |
| 23 |
|
| 24 |
$sessionProvider = $this->createMock( SessionProviderInterface::class ); |
| 25 |
$sessionProvider->method( 'safeAgainstCsrf' )->willReturn( $csrfSafe ); |
| 26 |
|
| 27 |
|
| 28 |
$session = $this->createMock( Session::class ); |
| 29 |
$session->method( 'getSessionId' )->willReturn( new SessionId( 'test' ) ); |
| 30 |
$session->method( 'getProvider' )->willReturn( $sessionProvider ); |
| 31 |
$session->method( 'isPersistent' )->willReturn( true ); |
| 32 |
|
| 33 |
return $session; |
| 34 |
} |
| 35 |
} |