ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
DataRetrievalTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace Results\Toplist;
22 
28 
34 {
36 
37  private \ilObjTest $testObjMock;
38 
39  protected function setUp(): void
40  {
41  global $DIC;
42  parent::setUp();
43 
44  $this->addGlobal_ilCtrl();
45  $this->addGlobal_lng();
46  $this->addGlobal_ilUser();
47 
48  $this->testObjMock = $this->getTestObjMock();
49 
50  $this->tableObj = new DataRetrieval(
51  $this->testObjMock,
52  $this->createMock(TestTopListRepository::class),
53  $DIC['lng'],
54  $DIC['ilUser'],
55  $DIC['ui.factory'],
56  $DIC['ui.renderer'],
57  $this->createMock(Factory::class),
58  TopListType::GENERAL,
59  TopListOrder::BY_SCORE
60  );
61  }
62 
64  {
65  $this->assertInstanceOf(DataRetrieval::class, $this->tableObj);
66  }
67 
69  {
70  $this->testObjMock->method('getHighscoreAchievedTS')->willReturn(true);
71  $this->testObjMock->method('getHighscoreScore')->willReturn(true);
72  $this->testObjMock->method('getHighscorePercentage')->willReturn(true);
73  $this->testObjMock->method('getHighscoreHints')->willReturn(true);
74  $this->testObjMock->method('getHighscoreWTime')->willReturn(true);
75 
76  $columns = $this->tableObj->getColumns();
77  $this->assertIsArray($columns);
78  $this->assertNotEmpty($columns);
79  $this->assertArrayHasKey('is_actor', $columns);
80  $this->assertArrayHasKey('rank', $columns);
81  $this->assertArrayHasKey('participant', $columns);
82  $this->assertArrayHasKey('achieved', $columns);
83  $this->assertArrayHasKey('score', $columns);
84  $this->assertArrayHasKey('percentage', $columns);
85  $this->assertArrayHasKey('hints', $columns);
86  $this->assertArrayHasKey('workingtime', $columns);
87  }
88 
90  {
91  $this->testObjMock->method('getHighscoreAchievedTS')->willReturn(true);
92  $this->testObjMock->method('getHighscoreScore')->willReturn(false);
93  $this->testObjMock->method('getHighscorePercentage')->willReturn(true);
94  $this->testObjMock->method('getHighscoreHints')->willReturn(true);
95  $this->testObjMock->method('getHighscoreWTime')->willReturn(false);
96 
97  $columns = $this->tableObj->getColumns();
98  $this->assertIsArray($columns);
99  $this->assertNotEmpty($columns);
100  $this->assertArrayHasKey('achieved', $columns);
101  $this->assertArrayHasKey('percentage', $columns);
102  $this->assertArrayHasKey('hints', $columns);
103 
104  $this->assertArrayNotHasKey('score', $columns);
105  $this->assertArrayNotHasKey('workingtime', $columns);
106  }
107 
108  public function test_formatTime_shouldReturnZeroTime(): void
109  {
110  $this->assertEquals('00:00:00', $this->tableObj->formatTime(0));
111  }
112 
114  {
115  $this->assertEquals('01:00:00', $this->tableObj->formatTime(3600));
116  $this->assertEquals('00:02:00', $this->tableObj->formatTime(120));
117  $this->assertEquals('00:02:01', $this->tableObj->formatTime(121));
118  $this->assertEquals('03:09:40', $this->tableObj->formatTime(11380));
119  }
120 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:22
Class ilTestBaseClass.