| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Tests\Session; |
| 4 | |
| 5 | use MediaWiki\User\User; |
| 6 | |
| 7 | /** |
| 8 | * Dummy session backend |
| 9 | * |
| 10 | * This isn't a real backend, but implements some methods that SessionBackend |
| 11 | * does so tests can run. |
| 12 | * |
| 13 | * FIXME This class is a huge hack, and it won't work e.g. as methods in Session(Backend) are typehinted. |
| 14 | * SessionBackend should be mocked directly instead, but that's currently impossible because the class is final. |
| 15 | * At the very least, there should be an interface that SessionBackend implements, and that could also be used |
| 16 | * for mocks. |
| 17 | */ |
| 18 | class DummySessionBackend { |
| 19 | /** @var array */ |
| 20 | public $data = [ |
| 21 | 'foo' => 1, |
| 22 | 'bar' => 2, |
| 23 | 0 => 'zero', |
| 24 | ]; |
| 25 | /** @var bool */ |
| 26 | public $dirty = false; |
| 27 | |
| 28 | public function &getData() { |
| 29 | return $this->data; |
| 30 | } |
| 31 | |
| 32 | public function dirty() { |
| 33 | $this->dirty = true; |
| 34 | } |
| 35 | |
| 36 | public function getUser(): User { |
| 37 | return new User(); |
| 38 | } |
| 39 | |
| 40 | public function deregisterSession( $index ) { |
| 41 | } |
| 42 | } |