ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilServicesActiveRecordConnectorTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\MockObject\MockObject;
22use PHPUnit\Framework\TestCase;
24
26{
27 private ?Container $dic_backup = null;
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;
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->assertSame(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}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Class ilGSStorageCache.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static get(ActiveRecord $activeRecord)
static register(ActiveRecord $activeRecord, arConnector $arConnector)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26