ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilObjLanguageDBAccessTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
26 {
28 
29  protected function setUp(): void
30  {
31  $ilDB_mock = $this->getMockBuilder(ilDBInterface::class)->getMock();
32  $this->ilDB = $ilDB_mock;
33  }
34 
35  public function testCreate(): void
36  {
37  $key = "en";
38  $content = ["acc#:#acc_add_document_btn_label#:#Add Document", "administration#:#adm_achievements#:#Achievements"];
39  $local_changes = [];
40 
41  $ilObjLanguageDBAccess = new ilObjLanguageDBAccess($this->ilDB, $key, $content, $local_changes);
42  $this->assertInstanceOf(\ilObjLanguageDBAccess::class, $ilObjLanguageDBAccess);
43  }
44 
45  public function testInsertLangEntriesReturnsArray(): void
46  {
47  $key = "en";
48  $content = ["acc#:#acc_add_document_btn_label#:#Add Document", "administration#:#adm_achievements#:#Achievements"];
49  $local_changes = [];
50 
51  $ilObjLanguageDBAccess = new ilObjLanguageDBAccess($this->ilDB, $key, $content, $local_changes);
52 
53  $result = $ilObjLanguageDBAccess->insertLangEntries("lang/ilias_en.lang");
54 
55  $this->assertIsArray($result);
56  }
57 
59  {
60  $key = "en";
61  $content = ["acc#:#acc_add_document_btn_label#:#Add Document"];
62  $local_changes = [];
63 
64  $ilObjLanguageDBAccess = new ilObjLanguageDBAccess($this->ilDB, $key, $content, $local_changes);
65  $result = $ilObjLanguageDBAccess->insertLangEntries("lang/ilias_en.lang");
66 
67  $this->assertArrayHasKey("acc", $result);
68  $this->assertArrayHasKey("acc_add_document_btn_label", $result["acc"]);
69  $this->assertEquals("Add Document", $result["acc"]["acc_add_document_btn_label"]);
70  }
71 
73  {
74  $key = "en";
75  $content = ["acc#:#acc_add_document_btn_label#:#Add Document"];
76  $local_changes = ["acc" => ["acc_add_document_btn_label" => "Add Documents"]];
77 
78  $ilObjLanguageDBAccess = new ilObjLanguageDBAccess($this->ilDB, $key, $content, $local_changes);
79  $result = $ilObjLanguageDBAccess->insertLangEntries("lang/ilias_en.lang");
80 
81  $this->assertEquals("Add Documents", $result["acc"]["acc_add_document_btn_label"]);
82  }
83 
85  {
86  $key = "en";
87  $content = ["acc#:#acc_add_document_btn_label#:#Add Document"];
88  $local_changes = [];
89 
90  $ilObjLanguageDBAccess = new ilObjLanguageDBAccess($this->ilDB, $key, $content, $local_changes);
91 
92  $this->ilDB->expects($this->once())->method("manipulate");
93  $result = $ilObjLanguageDBAccess->insertLangEntries("lang/ilias_en.lang");
94  }
95 
97  {
98  $key = "en";
99  $content = ["acc#:#acc_add_document_btn_label#:#Add Document"];
100  $local_changes = ["acc" => ["acc_add_document_btn_label" => "Add Documents"]];
101 
102  $ilObjLanguageDBAccess = new ilObjLanguageDBAccess($this->ilDB, $key, $content, $local_changes);
103 
104  $this->ilDB->expects($this->never())->method("manipulate");
105  $result = $ilObjLanguageDBAccess->insertLangEntries("lang/ilias_en.lang");
106  }
107 }
Class ilObjLanguageDBAccessTest.
Class ilLanguageBaseTest.