ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilServicesActiveRecordConnectorTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
25 {
30  protected $db_mock;
31 
32  protected function setUp(): void
33  {
34  global $DIC;
35  $this->dic_backup = is_object($DIC) ? clone $DIC : $DIC;
36 
37  $DIC = new Container();
38  $DIC['ilDB'] = $this->db_mock = $this->createMock(ilDBInterface::class);
39  }
40 
41  protected function tearDown(): void
42  {
43  global $DIC;
44  $DIC = $this->dic_backup;
45  }
46 
47  public function testDbConnector(): void
48  {
49  $ilBiblEntry = new ilBiblEntry();
50  $this->db_mock->expects($this->once())
51  ->method('nextId')
53  ->willReturn(1);
54 
55  $arConnectorDB = new arConnectorDB($this->db_mock);
56  $this->assertEquals(1, $arConnectorDB->nextID($ilBiblEntry));
57 
58  $this->db_mock->expects($this->once())
59  ->method('tableExists')
61  ->willReturn(true);
62  $this->assertEquals(true, $arConnectorDB->checkTableExists($ilBiblEntry));
63 
64  $this->db_mock->expects($this->once())
65  ->method('tableColumnExists')
66  ->with(ilBiblEntry::TABLE_NAME, 'data_id')
67  ->willReturn(true);
68  $this->assertEquals(true, $arConnectorDB->checkFieldExists($ilBiblEntry, 'data_id'));
69  }
70 
71  public function testConnectorMap(): void
72  {
73  $arConnectorCache = new arConnectorCache(new arConnectorDB($this->db_mock));
74  $ar = new class () extends ActiveRecord {
83  protected int $id = 0;
84  };
85  arConnectorMap::register($ar, $arConnectorCache);
86  $this->assertEquals($arConnectorCache, arConnectorMap::get($ar));
87  }
88 }
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
global $DIC
Definition: feed.php:28
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)