ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilServicesActiveRecordFieldTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /******************************************************************************
6  *
7  * This file is part of ILIAS, a powerful learning management system.
8  *
9  * ILIAS is licensed with the GPL-3.0, you should have received a copy
10  * of said license along with the source code.
11  *
12  * If this is not the case or you just want to try ILIAS, you'll find
13  * us at:
14  * https://www.ilias.de
15  * https://github.com/ILIAS-eLearning
16  *
17  *****************************************************************************/
18 
21 
22 class ilServicesActiveRecordFieldTest extends TestCase
23 {
28  protected $db_mock;
29 
30  protected function setUp(): void
31  {
32  global $DIC;
33  $this->dic_backup = is_object($DIC) ? clone $DIC : $DIC;
34 
35  $DIC = new Container();
36  $DIC['ilDB'] = $this->db_mock = $this->createMock(ilDBInterface::class);
37  }
38 
39  protected function tearDown(): void
40  {
41  global $DIC;
42  $DIC = $this->dic_backup;
43  }
44 
45  public function testFieldList(): void
46  {
47  $test_ar = new class () extends ActiveRecord {
57  protected int $id = 0;
58 
67  protected string $string_data;
68 
69  public function getConnectorContainerName(): string
70  {
71  return 'table_name';
72  }
73  };
74 
75  $field_list = arFieldList::getInstance($test_ar);
76 
77  $primary_field = $field_list->getPrimaryField();
78  $this->assertEquals('id', $primary_field->getName());
79  $this->assertEquals(8, $primary_field->getLength());
80  $this->assertEquals('integer', $primary_field->getFieldType());
81  $this->assertEquals(false, $primary_field->getIndex());
82  $this->assertEquals(true, $primary_field->getPrimary());
83 
84  $string_field = $field_list->getFieldByName('string_data');
85  $this->assertEquals('string_data', $string_field->getName());
86  $this->assertEquals(256, $string_field->getLength());
87  $this->assertEquals('text', $string_field->getFieldType());
88  $this->assertEquals(true, $string_field->getIndex());
89  $this->assertEquals(false, $string_field->getPrimary());
90  }
91 }
static getInstance(ActiveRecord $ar)
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:31
global $DIC
Definition: feed.php:28
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23