ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilServicesActiveRecordFieldTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
24 class ilServicesActiveRecordFieldTest extends TestCase
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 testFieldList(): void
48  {
49  $test_ar = new class () extends ActiveRecord {
58  protected int $id = 0;
59 
67  protected string $string_data;
68 
69  public function getConnectorContainerName(): string
70  {
71  return 'table_name';
72  }
73  };
74 
75  $arFieldList = arFieldList::getInstance($test_ar);
76 
77  $primaryField = $arFieldList->getPrimaryField();
78  $this->assertEquals('id', $primaryField->getName());
79  $this->assertEquals(8, $primaryField->getLength());
80  $this->assertEquals('integer', $primaryField->getFieldType());
81  $this->assertEquals(false, $primaryField->getIndex());
82  $this->assertEquals(true, $primaryField->getPrimary());
83 
84  $arField = $arFieldList->getFieldByName('string_data');
85  $this->assertEquals('string_data', $arField->getName());
86  $this->assertEquals(256, $arField->getLength());
87  $this->assertEquals('text', $arField->getFieldType());
88  $this->assertEquals(true, $arField->getIndex());
89  $this->assertEquals(false, $arField->getPrimary());
90  }
91 }
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
global $DIC
Definition: shib_login.php:25
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24