ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilServicesActiveRecordFieldTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
24 
25 class ilServicesActiveRecordFieldTest extends TestCase
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 testFieldList(): void
49  {
50  $test_ar = new class () extends ActiveRecord {
59  protected int $id = 0;
60 
68  protected string $string_data;
69 
70  public function getConnectorContainerName(): string
71  {
72  return 'table_name';
73  }
74  };
75 
76  $arFieldList = arFieldList::getInstance($test_ar);
77 
78  $primaryField = $arFieldList->getPrimaryField();
79  $this->assertEquals('id', $primaryField->getName());
80  $this->assertEquals(8, $primaryField->getLength());
81  $this->assertEquals('integer', $primaryField->getFieldType());
82  $this->assertEquals(false, $primaryField->getIndex());
83  $this->assertEquals(true, $primaryField->getPrimary());
84 
85  $arField = $arFieldList->getFieldByName('string_data');
86  $this->assertEquals('string_data', $arField->getName());
87  $this->assertEquals(256, $arField->getLength());
88  $this->assertEquals('text', $arField->getFieldType());
89  $this->assertEquals(true, $arField->getIndex());
90  $this->assertEquals(false, $arField->getPrimary());
91  }
92 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(ActiveRecord $activeRecord)
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
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23