ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilServicesActiveRecordConnectorTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
24 
26 {
31  protected ?MockObject $db_mock = null;
32 
33  protected function setUp(): void
34  {
35  global $DIC;
36  $this->dic_backup = is_object($DIC) ? clone $DIC : $DIC;
37 
38  $DIC = new Container();
39  $DIC['ilDB'] = $this->db_mock = $this->createMock(ilDBInterface::class);
40  }
41 
42  protected function tearDown(): void
43  {
44  global $DIC;
45  $DIC = $this->dic_backup;
46  }
47 
48  public function testDbConnector(): void
49  {
50  $ilBiblEntry = new ilBiblEntry();
51  $this->db_mock->expects($this->once())
52  ->method('nextId')
54  ->willReturn(1);
55 
56  $arConnectorDB = new arConnectorDB($this->db_mock);
57  $this->assertEquals(1, $arConnectorDB->nextID($ilBiblEntry));
58 
59  $this->db_mock->expects($this->once())
60  ->method('tableExists')
62  ->willReturn(true);
63  $this->assertEquals(true, $arConnectorDB->checkTableExists($ilBiblEntry));
64 
65  $this->db_mock->expects($this->once())
66  ->method('tableColumnExists')
67  ->with(ilBiblEntry::TABLE_NAME, 'data_id')
68  ->willReturn(true);
69  $this->assertEquals(true, $arConnectorDB->checkFieldExists($ilBiblEntry, 'data_id'));
70  }
71 
72  public function testConnectorMap(): void
73  {
74  $arConnectorCache = new arConnectorCache(new arConnectorDB($this->db_mock));
75  $ar = new class () extends ActiveRecord {
84  protected int $id = 0;
85  };
86  arConnectorMap::register($ar, $arConnectorCache);
87  $this->assertEquals($arConnectorCache, arConnectorMap::get($ar));
88  }
89 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static register(ActiveRecord $activeRecord, arConnector $arConnector)
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
Class ilGSStorageCache.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static get(ActiveRecord $activeRecord)