ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
UserPreferenceStoreTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 use ilObjUser;
27 
28 require_once __DIR__ . '/../../ContainerMock.php';
29 
30 class UserPreferenceStoreTest extends TestCase
31 {
32  use ContainerMock;
33 
34  public function testConstruct(): void
35  {
36  $this->assertInstanceOf(UserPreferenceStore::class, new UserPreferenceStore($this->mock(ilObjUser::class)));
37  }
38 
39  public function testValue(): void
40  {
41  $this->assertSame('bar', (new UserPreferenceStore($this->mockMethod(ilObjUser::class, 'getPref', ['foo'], 'bar')))->value('foo'));
42  }
43 
44  public function testNullValue(): void
45  {
46  $this->assertSame('', (new UserPreferenceStore($this->mockMethod(ilObjUser::class, 'getPref', ['foo'], null)))->value('foo'));
47  }
48 
49  public function testUpdate(): void
50  {
51  $user = $this->mock(ilObjUser::class);
52  $user->expects(self::once())->method('writePref')->with('foo', 'bar');
53 
54  (new UserPreferenceStore($user))->update('foo', 'bar');
55  }
56 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null