ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilObjTestGUITest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 {
25  public function __construct()
26  {
27  }
28  private function getHereURL(): string
29  {
30  return 'http://www.ilias.de';
31  }
32 }
33 
39 {
41 
42  protected function setUp(): void
43  {
44  if (!defined('ANONYMOUS_USER_ID')) {
45  define('ANONYMOUS_USER_ID', 13);
46  }
47  if (!defined('CLIENT_DATA_DIR')) {
48  define('CLIENT_DATA_DIR', 'data/');
49  }
50 
51  parent::setUp();
52 
53  $this->addGlobal_ilLocator();
54  $this->addGlobal_ilSetting();
55  $this->addGlobal_rbacreview();
56  $this->addGlobal_ilToolbar();
57  $this->addGlobal_rbacsystem();
58  $this->addGlobal_filesystem();
59  $this->addGlobal_ilErr();
60  $this->addGlobal_ilTabs();
61  $this->addGlobal_ilias();
62  $this->addGlobal_ilNavigationHistory();
63  $this->addGlobal_skillService();
64  $this->addGlobal_ilHelp();
65  $this->addGlobal_ilObjDataCache();
66  $this->addGlobal_ilRbacAdmin();
67  $this->addGlobal_objectService();
68  $this->addGlobal_GlobalScreenService();
69  $this->addGlobal_resourceStorage();
70 
71  $this->testObj = $this->getNewTestGUI();
72  }
73 
74  protected function getNewTestGUI(): ilObjTestGUI
75  {
76  $table_query = $this->getMockBuilder(QuestionsTableQueryMock::class)->getMock();
77  return new class ($table_query) extends ilObjTestGUI {
78  public function __construct(
79  protected QuestionsTableQuery $mock_table_query
80  ) {
82  }
83  protected function getQuestionsTableQuery(): QuestionsTableQuery
84  {
85  return $this->mock_table_query;
86  }
87  };
88  }
89 
90  protected function tearDown(): void
91  {
92  global $DIC;
93 
94  $DIC = $this->dic;
95 
96  parent::tearDown();
97  }
98 
100  {
101  $this->assertInstanceOf(ilObjTestGUI::class, $this->testObj);
102  }
103 
104  public function testTestAccess(): void
105  {
106  $testAccess_mock = $this->createMock(ilTestAccess::class);
107 
108  $this->testObj->setTestAccess($testAccess_mock);
109  $this->assertEquals($testAccess_mock, $this->testObj->getTestAccess());
110  }
111 
112  public function testRunObject(): void
113  {
114  $ctrl_mock = $this->createMock(ilCtrl::class);
115  $this->setGlobalVariable('ilCtrl', $ctrl_mock);
116  $testObj = $this->getNewTestGUI();
117  $ctrl_mock
118  ->expects($this->once())
119  ->method('redirectByClass')
120  ->with([ilRepositoryGUI::class, ilObjTestGUI::class, ilInfoScreenGUI::class]);
121 
122  $testObj->runObject();
123  }
124 
125  public function testCancelCreateQuestionObject(): void
126  {
127  $ctrl_mock = $this->createMock(ilCtrl::class);
128  $this->setGlobalVariable('ilCtrl', $ctrl_mock);
129  $testObj = $this->getNewTestGUI();
130  $ctrl_mock
131  ->expects($this->once())
132  ->method('redirect')
133  ->with($testObj, ilObjTestGUI::SHOW_QUESTIONS_CMD)
134  ;
135  $testObj->cancelCreateQuestionObject();
136  }
137 }
test_instantiateObject_shouldReturnInstance()
Class ilObjTestGUITest.
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
$dic
Definition: result.php:31
ilObjTestGUI $testObj