ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjLanguageDBAccessTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
28 {
30 
31  protected function setUp(): void
32  {
33  $ilDB_mock = $this->getMockBuilder(ilDBInterface::class)->getMock();
34  $this->ilDB = $ilDB_mock;
35  }
36 
37  public function testCreate(): void
38  {
39  $key = "en";
40  $content = ["acc#:#acc_add_document_btn_label#:#Add Document", "administration#:#adm_achievements#:#Achievements"];
41  $local_changes = [];
42 
43  $ilObjLanguageDBAccess = new ilObjLanguageDBAccess($this->ilDB, $key, $content, $local_changes);
44  $this->assertInstanceOf(\ilObjLanguageDBAccess::class, $ilObjLanguageDBAccess);
45  }
46 
47  public function testInsertLangEntriesReturnsArray(): void
48  {
49  $key = "en";
50  $content = ["acc#:#acc_add_document_btn_label#:#Add Document", "administration#:#adm_achievements#:#Achievements"];
51  $local_changes = [];
52 
53  $ilObjLanguageDBAccess = new ilObjLanguageDBAccess($this->ilDB, $key, $content, $local_changes);
54 
55  $result = $ilObjLanguageDBAccess->insertLangEntries("lang/ilias_en.lang");
56 
57  $this->assertIsArray($result);
58  }
59 
61  {
62  $key = "en";
63  $content = ["acc#:#acc_add_document_btn_label#:#Add Document"];
64  $local_changes = [];
65 
66  $ilObjLanguageDBAccess = new ilObjLanguageDBAccess($this->ilDB, $key, $content, $local_changes);
67  $result = $ilObjLanguageDBAccess->insertLangEntries("lang/ilias_en.lang");
68 
69  $this->assertArrayHasKey("acc", $result);
70  $this->assertArrayHasKey("acc_add_document_btn_label", $result["acc"]);
71  $this->assertEquals("Add Document", $result["acc"]["acc_add_document_btn_label"]);
72  }
73 
75  {
76  $key = "en";
77  $content = ["acc#:#acc_add_document_btn_label#:#Add Document"];
78  $local_changes = ["acc"=>["acc_add_document_btn_label"=>"Add Documents"]];
79 
80  $ilObjLanguageDBAccess = new ilObjLanguageDBAccess($this->ilDB, $key, $content, $local_changes);
81  $result = $ilObjLanguageDBAccess->insertLangEntries("lang/ilias_en.lang");
82 
83  $this->assertEquals("Add Documents", $result["acc"]["acc_add_document_btn_label"]);
84  }
85 
87  {
88  $key = "en";
89  $content = ["acc#:#acc_add_document_btn_label#:#Add Document"];
90  $local_changes = [];
91 
92  $ilObjLanguageDBAccess = new ilObjLanguageDBAccess($this->ilDB, $key, $content, $local_changes);
93 
94  $this->ilDB->expects($this->once())->method("manipulate");
95  $result = $ilObjLanguageDBAccess->insertLangEntries("lang/ilias_en.lang");
96  }
97 
99  {
100  $key = "en";
101  $content = ["acc#:#acc_add_document_btn_label#:#Add Document"];
102  $local_changes = ["acc"=>["acc_add_document_btn_label"=>"Add Documents"]];
103 
104  $ilObjLanguageDBAccess = new ilObjLanguageDBAccess($this->ilDB, $key, $content, $local_changes);
105 
106  $this->ilDB->expects($this->never())->method("manipulate");
107  $result = $ilObjLanguageDBAccess->insertLangEntries("lang/ilias_en.lang");
108  }
109 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilLanguageBaseTest.
string $key
Consumer key/client ID value.
Definition: System.php:193