ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
SkillProfileCompletionManagerTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Skill\Profile;
22 
24 
25 
26 class SkillProfileCompletionManagerTest extends TestCase
27 {
29  {
30  $s_manager = $this->getProfileManagerMock();
31  $repo = $this->getMockBuilder(SkillProfileCompletionDBRepository::class)->disableOriginalConstructor()->getMock();
32 
33  return new class ($s_manager, $repo) extends SkillProfileCompletionManager {
34  public function __construct(
35  protected SkillProfileManager $profile_manager,
36  protected SkillProfileCompletionDBRepository $profile_completion_repo
37  ) {
38  }
39 
40  public function getActualMaxLevels(
41  int $user_id,
42  array $skills,
43  string $gap_mode = "",
44  string $gap_mode_type = "",
45  int $gap_mode_obj_id = 0,
46  string $trigger_user = ""
47  ): array {
48  $actual_levels = [];
49 
50  if ($user_id === 101) {
51  $actual_levels[301][0] = 501;
52  $actual_levels[302][0] = 504;
53  $actual_levels[303][0] = 503;
54  $actual_levels[304][0] = 502;
55  $actual_levels[305][0] = 502;
56  } elseif ($user_id === 102) {
57  $actual_levels[301][0] = 505;
58  $actual_levels[302][0] = 505;
59  $actual_levels[303][0] = 505;
60  $actual_levels[304][0] = 505;
61  $actual_levels[305][0] = 505;
62  } elseif ($user_id === 103) {
63  $actual_levels[301][0] = 505;
64  $actual_levels[302][0] = 501;
65  $actual_levels[303][0] = 505;
66  $actual_levels[304][0] = 501;
67  $actual_levels[305][0] = 501;
68  } elseif ($user_id === 104) {
69  $actual_levels[301][0] = 505;
70  $actual_levels[305][0] = 501;
71  } elseif ($user_id === 105) {
72  // no levels
73  }
74 
75  return $actual_levels;
76  }
77  };
78  }
79 
81  {
82  $p_repo = $this->getMockBuilder(SkillProfileDBRepository::class)->disableOriginalConstructor()->getMock();
83  $pl_repo = $this->getMockBuilder(SkillProfileLevelsDBRepository::class)->disableOriginalConstructor()->getMock();
84  $pu_repo = $this->getMockBuilder(SkillProfileUserDBRepository::class)->disableOriginalConstructor()->getMock();
85  $pr_repo = $this->getMockBuilder(SkillProfileRoleDBRepository::class)->disableOriginalConstructor()->getMock();
86 
87  return new class ($p_repo, $pl_repo, $pu_repo, $pr_repo) extends SkillProfileManager {
88  public function __construct(
89  protected SkillProfileDBRepository $profile_repo,
90  protected SkillProfileLevelsDBRepository $profile_levels_repo,
91  protected SkillProfileUserDBRepository $profile_user_repo,
92  protected SkillProfileRoleDBRepository $profile_role_repo
93  ) {
94  }
95 
96  public function getSkillLevels(int $profile_id): array
97  {
98  $levels = [];
99 
100  if ($profile_id > 0) {
101  $levels[] = new SkillProfileLevel($profile_id, 301, 0, 502, 10);
102  $levels[] = new SkillProfileLevel($profile_id, 302, 0, 505, 20);
103  $levels[] = new SkillProfileLevel($profile_id, 303, 0, 505, 30);
104  $levels[] = new SkillProfileLevel($profile_id, 304, 0, 504, 40);
105  $levels[] = new SkillProfileLevel($profile_id, 305, 0, 505, 50);
106  }
107 
108  return $levels;
109  }
110  };
111  }
112 
113  public function testGetProfileProgress(): void
114  {
115  $manager = $this->getManagerMock();
116 
117  $this->assertSame(0, $manager->getProfileProgress(101, 201));
118  $this->assertSame(100, $manager->getProfileProgress(102, 201));
119  $this->assertSame(40, $manager->getProfileProgress(103, 201));
120  $this->assertSame(20, $manager->getProfileProgress(104, 201));
121  $this->assertSame(0, $manager->getProfileProgress(105, 201));
122  $this->assertSame(0, $manager->getProfileProgress(101, 0));
123  $this->assertSame(0, $manager->getProfileProgress(0, 201));
124  $this->assertSame(0, $manager->getProfileProgress(0, 0));
125  }
126 }
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...