Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 36... Línea 36...
36
class licenselib_test extends advanced_testcase {
36
class licenselib_test extends advanced_testcase {
Línea 37... Línea 37...
37
 
37
 
38
    /**
38
    /**
39
     * Test getting licenses from database or cache.
39
     * Test getting licenses from database or cache.
40
     */
40
     */
41
    public function test_get_licenses() {
41
    public function test_get_licenses(): void {
Línea 42... Línea 42...
42
        $this->resetAfterTest();
42
        $this->resetAfterTest();
43
 
43
 
44
        // Reset the cache, to make sure we are not getting cached licenses.
44
        // Reset the cache, to make sure we are not getting cached licenses.
Línea 72... Línea 72...
72
    }
72
    }
Línea 73... Línea 73...
73
 
73
 
74
    /**
74
    /**
75
     * Test saving a license.
75
     * Test saving a license.
76
     */
76
     */
77
    public function test_save() {
77
    public function test_save(): void {
Línea 78... Línea 78...
78
        global $DB;
78
        global $DB;
Línea 79... Línea 79...
79
 
79
 
Línea 118... Línea 118...
118
    }
118
    }
Línea 119... Línea 119...
119
 
119
 
120
    /**
120
    /**
121
     * Test ability to get a license by it's short name.
121
     * Test ability to get a license by it's short name.
122
     */
122
     */
Línea 123... Línea 123...
123
    public function test_get_license_by_shortname() {
123
    public function test_get_license_by_shortname(): void {
124
 
124
 
Línea 125... Línea 125...
125
        $license = license_manager::get_license_by_shortname('cc-nc-4.0');
125
        $license = license_manager::get_license_by_shortname('cc-nc-4.0');
Línea 130... Línea 130...
130
    }
130
    }
Línea 131... Línea 131...
131
 
131
 
132
    /**
132
    /**
133
     * Test disabling a license.
133
     * Test disabling a license.
134
     */
134
     */
135
    public function test_disable_license() {
135
    public function test_disable_license(): void {
Línea 136... Línea 136...
136
        global $DB;
136
        global $DB;
Línea 137... Línea 137...
137
 
137
 
Línea 149... Línea 149...
149
    }
149
    }
Línea 150... Línea 150...
150
 
150
 
151
    /**
151
    /**
152
     * Test enabling a license.
152
     * Test enabling a license.
153
     */
153
     */
154
    public function test_enable_license() {
154
    public function test_enable_license(): void {
Línea 155... Línea 155...
155
        global $DB;
155
        global $DB;
Línea 156... Línea 156...
156
 
156
 
Línea 168... Línea 168...
168
    }
168
    }
Línea 169... Línea 169...
169
 
169
 
170
    /**
170
    /**
171
     * Test deleting a custom license.
171
     * Test deleting a custom license.
172
     */
172
     */
173
    public function test_delete() {
173
    public function test_delete(): void {
Línea 174... Línea 174...
174
        $this->resetAfterTest();
174
        $this->resetAfterTest();
175
 
175
 
176
        // Create a custom license.
176
        // Create a custom license.
Línea 189... Línea 189...
189
    }
189
    }
Línea 190... Línea 190...
190
 
190
 
191
    /**
191
    /**
192
     * Test trying to delete a license currently in use by a file.
192
     * Test trying to delete a license currently in use by a file.
193
     */
193
     */
194
    public function test_delete_license_in_use_by_file() {
194
    public function test_delete_license_in_use_by_file(): void {
Línea 195... Línea 195...
195
        $this->resetAfterTest();
195
        $this->resetAfterTest();
196
 
196
 
197
        // Create a custom license.
197
        // Create a custom license.
Línea 224... Línea 224...
224
    }
224
    }
Línea 225... Línea 225...
225
 
225
 
226
    /**
226
    /**
227
     * Test trying to delete a core license.
227
     * Test trying to delete a core license.
228
     */
228
     */
229
    public function test_delete_license_core() {
229
    public function test_delete_license_core(): void {
230
        // Should not be able to delete a standard/core license.
230
        // Should not be able to delete a standard/core license.
231
        $this->expectException(moodle_exception::class);
231
        $this->expectException(moodle_exception::class);
232
        license_manager::delete('cc-nc-4.0');
232
        license_manager::delete('cc-nc-4.0');
Línea 233... Línea 233...
233
    }
233
    }
234
 
234
 
235
    /**
235
    /**
236
     * Test trying to delete a license which doesn't exist.
236
     * Test trying to delete a license which doesn't exist.
237
     */
237
     */
238
    public function test_delete_license_not_exists() {
238
    public function test_delete_license_not_exists(): void {
239
        // Should throw an exception if license with shortname doesn't exist.
239
        // Should throw an exception if license with shortname doesn't exist.
240
        $this->expectException(moodle_exception::class);
240
        $this->expectException(moodle_exception::class);
Línea 241... Línea 241...
241
        license_manager::delete('somefakelicense');
241
        license_manager::delete('somefakelicense');
242
    }
242
    }
243
 
243
 
244
    /**
244
    /**
245
     * Test setting active licenses.
245
     * Test setting active licenses.
Línea 246... Línea 246...
246
     */
246
     */
247
    public function test_set_active_licenses() {
247
    public function test_set_active_licenses(): void {
248
        $this->resetAfterTest();
248
        $this->resetAfterTest();
Línea 256... Línea 256...
256
    }
256
    }
Línea 257... Línea 257...
257
 
257
 
258
    /**
258
    /**
259
     * Test getting active licenses.
259
     * Test getting active licenses.
260
     */
260
     */
261
    public function test_get_active_licenses() {
261
    public function test_get_active_licenses(): void {
Línea 262... Línea 262...
262
        $this->resetAfterTest();
262
        $this->resetAfterTest();
263
 
263
 
Línea 275... Línea 275...
275
    }
275
    }
Línea 276... Línea 276...
276
 
276
 
277
    /**
277
    /**
278
     * Test getting active licenses as array.
278
     * Test getting active licenses as array.
279
     */
279
     */
280
    public function test_get_active_licenses_as_array() {
280
    public function test_get_active_licenses_as_array(): void {
Línea 281... Línea 281...
281
        $this->resetAfterTest();
281
        $this->resetAfterTest();
282
 
282
 
Línea 296... Línea 296...
296
    }
296
    }
Línea 297... Línea 297...
297
 
297
 
298
    /**
298
    /**
299
     * Test resetting the license cache.
299
     * Test resetting the license cache.
300
     */
300
     */
301
    public function test_reset_license_cache() {
301
    public function test_reset_license_cache(): void {
Línea 302... Línea 302...
302
        global $DB;
302
        global $DB;
Línea 303... Línea 303...
303
 
303
 
Línea 324... Línea 324...
324
    }
324
    }
Línea 325... Línea 325...
325
 
325
 
326
    /**
326
    /**
327
     * Test that all licenses are installed correctly.
327
     * Test that all licenses are installed correctly.
328
     */
328
     */
329
    public function test_install_licenses() {
329
    public function test_install_licenses(): void {
Línea 330... Línea 330...
330
        global $DB;
330
        global $DB;
Línea 331... Línea 331...
331
 
331