ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilServicesActiveRecordFieldTest.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
25class ilServicesActiveRecordFieldTest extends TestCase
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 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->assertSame('id', $primaryField->getName());
80 $this->assertSame(8, $primaryField->getLength());
81 $this->assertSame('integer', $primaryField->getFieldType());
82 $this->assertEquals(false, $primaryField->getIndex());
83 $this->assertEquals(true, $primaryField->getPrimary());
84
85 $arField = $arFieldList->getFieldByName('string_data');
86 $this->assertInstanceOf(\arField::class, $arField);
87 $this->assertSame('string_data', $arField->getName());
88 $this->assertSame(256, $arField->getLength());
89 $this->assertSame('text', $arField->getFieldType());
90 $this->assertEquals(true, $arField->getIndex());
91 $this->assertEquals(false, $arField->getPrimary());
92 }
93}
$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
static getInstance(ActiveRecord $activeRecord)
global $DIC
Definition: shib_login.php:26