ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCertificateMigrationValidatorTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
10  {
11  $settings = $this->getMockBuilder('ilSetting')
12  ->disableOriginalConstructor()
13  ->getMock();
14 
15  $settings->method('get')
16  ->willReturn(0);
17 
18  $validator = new ilCertificateMigrationValidator($settings);
19 
20  $user = $this->getMockBuilder('ilObjUser')
21  ->disableOriginalConstructor()
22  ->getMock();
23 
24  $migrationHelper = $this->getMockBuilder('ilCertificateMigration')
25  ->disableOriginalConstructor()
26  ->getMock();
27 
28  $result = $validator->isMigrationAvailable($user, $migrationHelper);
29 
30  $this->assertFalse($result);
31  }
32 
34  {
35  $settings = $this->getMockBuilder('ilSetting')
36  ->disableOriginalConstructor()
37  ->getMock();
38 
39  $settings->method('get')
40  ->willReturn(1);
41 
42  $validator = new ilCertificateMigrationValidator($settings);
43 
44  $user = $this->getMockBuilder('ilObjUser')
45  ->disableOriginalConstructor()
46  ->getMock();
47 
48  $user->method('getPref')
49  ->with('cert_migr_finished')
50  ->willReturn('1');
51 
52  $migrationHelper = $this->getMockBuilder('ilCertificateMigration')
53  ->disableOriginalConstructor()
54  ->getMock();
55 
56  $result = $validator->isMigrationAvailable($user, $migrationHelper);
57 
58  $this->assertFalse($result);
59  }
60 
62  {
63  $settings = $this->getMockBuilder('ilSetting')
64  ->disableOriginalConstructor()
65  ->getMock();
66 
67  $settings->method('get')
68  ->willReturn(1);
69 
70  $validator = new ilCertificateMigrationValidator($settings);
71 
72  $user = $this->getMockBuilder('ilObjUser')
73  ->disableOriginalConstructor()
74  ->getMock();
75 
76  $user->method('getPref')
77  ->with('cert_migr_finished')
78  ->willReturn('0');
79 
80  $migrationHelper = $this->getMockBuilder('ilCertificateMigration')
81  ->disableOriginalConstructor()
82  ->getMock();
83 
84  $migrationHelper->method('isTaskRunning')
85  ->willReturn(true);
86 
87  $result = $validator->isMigrationAvailable($user, $migrationHelper);
88 
89  $this->assertFalse($result);
90  }
91 
93  {
94  $settings = $this->getMockBuilder('ilSetting')
95  ->disableOriginalConstructor()
96  ->getMock();
97 
98  $settings->method('get')
99  ->willReturn(1);
100 
101  $validator = new ilCertificateMigrationValidator($settings);
102 
103  $user = $this->getMockBuilder('ilObjUser')
104  ->disableOriginalConstructor()
105  ->getMock();
106 
107  $user->method('getPref')
108  ->with('cert_migr_finished')
109  ->willReturn('0');
110 
111  $migrationHelper = $this->getMockBuilder('ilCertificateMigration')
112  ->disableOriginalConstructor()
113  ->getMock();
114 
115  $migrationHelper->method('isTaskRunning')
116  ->willReturn(false);
117 
118  $migrationHelper->method('isTaskFinished')
119  ->willReturn(true);
120 
121  $result = $validator->isMigrationAvailable($user, $migrationHelper);
122 
123  $this->assertFalse($result);
124  }
125 
126  public function testMigrationIsAvailable()
127  {
128  $settings = $this->getMockBuilder('ilSetting')
129  ->disableOriginalConstructor()
130  ->getMock();
131 
132  $settings->method('get')
133  ->withConsecutive(array('active'), array('persisting_cers_introduced_ts'))
134  ->willReturnOnConsecutiveCalls(1, 970000000);
135 
136  $validator = new ilCertificateMigrationValidator($settings);
137 
138  $user = $this->getMockBuilder('ilObjUser')
139  ->disableOriginalConstructor()
140  ->getMock();
141 
142  $user->method('getPref')
143  ->with('cert_migr_finished')
144  ->willReturn('0');
145 
146  $user->method('getCreateDate')
147  ->willReturn('10 September 2000');
148 
149  $migrationHelper = $this->getMockBuilder('ilCertificateMigration')
150  ->disableOriginalConstructor()
151  ->getMock();
152 
153  $migrationHelper->method('isTaskRunning')
154  ->willReturn(false);
155 
156  $migrationHelper->method('isTaskFinished')
157  ->willReturn(false);
158 
159  $result = $validator->isMigrationAvailable($user, $migrationHelper);
160 
161  $this->assertTrue($result);
162  }
163 }
$result
$user
Definition: migrateto20.php:57