Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 38... Línea 38...
38
    /**
38
    /**
39
     * Installing repository tests
39
     * Installing repository tests
40
     *
40
     *
41
     * @copyright 2012 Dongsheng Cai {@link http://dongsheng.org}
41
     * @copyright 2012 Dongsheng Cai {@link http://dongsheng.org}
42
     */
42
     */
43
    public function test_install_repository() {
43
    public function test_install_repository(): void {
44
        global $CFG, $DB;
44
        global $CFG, $DB;
Línea 45... Línea 45...
45
 
45
 
Línea 46... Línea 46...
46
        $this->resetAfterTest(true);
46
        $this->resetAfterTest(true);
Línea 62... Línea 62...
62
        $this->assertInstanceOf('repository', $repository);
62
        $this->assertInstanceOf('repository', $repository);
63
        $info = $repository->get_meta();
63
        $info = $repository->get_meta();
64
        $this->assertEquals($repositorypluginname, $info->type);
64
        $this->assertEquals($repositorypluginname, $info->type);
65
    }
65
    }
Línea 66... Línea 66...
66
 
66
 
67
    public function test_get_unused_filename() {
67
    public function test_get_unused_filename(): void {
Línea 68... Línea 68...
68
        global $USER;
68
        global $USER;
Línea 69... Línea 69...
69
 
69
 
Línea 116... Línea 116...
116
        $this->assertEquals('test3 (1001).txt', repository::get_unused_filename($draftitemid, '/', 'test3 (1000).txt'));
116
        $this->assertEquals('test3 (1001).txt', repository::get_unused_filename($draftitemid, '/', 'test3 (1000).txt'));
117
        $this->assertEquals('test3 (1000MB) (1).txt', repository::get_unused_filename($draftitemid, '/', 'test3 (1000MB).txt'));
117
        $this->assertEquals('test3 (1000MB) (1).txt', repository::get_unused_filename($draftitemid, '/', 'test3 (1000MB).txt'));
118
        $this->assertEquals('test4 (1).txt', repository::get_unused_filename($draftitemid, '/', 'test4 (1).txt'));
118
        $this->assertEquals('test4 (1).txt', repository::get_unused_filename($draftitemid, '/', 'test4 (1).txt'));
119
    }
119
    }
Línea 120... Línea 120...
120
 
120
 
121
    public function test_draftfile_exists() {
121
    public function test_draftfile_exists(): void {
Línea 122... Línea 122...
122
        global $USER;
122
        global $USER;
Línea 123... Línea 123...
123
 
123
 
Línea 157... Línea 157...
157
        foreach (array('Terminator.movie', 'Where is Wally?', 'barfoo') as $filename) {
157
        foreach (array('Terminator.movie', 'Where is Wally?', 'barfoo') as $filename) {
158
            $this->assertFalse(repository::draftfile_exists($draftitemid, '/', $filename));
158
            $this->assertFalse(repository::draftfile_exists($draftitemid, '/', $filename));
159
        }
159
        }
160
    }
160
    }
Línea 161... Línea 161...
161
 
161
 
162
    public function test_delete_selected_files() {
162
    public function test_delete_selected_files(): void {
Línea 163... Línea 163...
163
        global $USER;
163
        global $USER;
Línea 164... Línea 164...
164
 
164
 
Línea 211... Línea 211...
211
        $areafiles = $fs->get_area_files($context->id, 'user', 'draft', $draftitemid);
211
        $areafiles = $fs->get_area_files($context->id, 'user', 'draft', $draftitemid);
212
        // Should be the 1 file left plus the folder.
212
        // Should be the 1 file left plus the folder.
213
        $this->assertEquals(2, count($areafiles));
213
        $this->assertEquals(2, count($areafiles));
214
    }
214
    }
Línea 215... Línea 215...
215
 
215
 
216
    public function test_can_be_edited_by_user() {
216
    public function test_can_be_edited_by_user(): void {
Línea 217... Línea 217...
217
        $this->resetAfterTest(true);
217
        $this->resetAfterTest(true);
218
 
218
 
219
        $syscontext = \context_system::instance();
219
        $syscontext = \context_system::instance();
Línea 291... Línea 291...
291
        $userrepo = repository::get_repository_by_id($repoid, $syscontext);
291
        $userrepo = repository::get_repository_by_id($repoid, $syscontext);
292
        $this->assertTrue($userrepo->can_be_edited_by_user());
292
        $this->assertTrue($userrepo->can_be_edited_by_user());
Línea 293... Línea 293...
293
 
293
 
Línea 294... Línea 294...
294
    }
294
    }
295
 
295
 
Línea 296... Línea 296...
296
    public function test_check_capability() {
296
    public function test_check_capability(): void {
297
        $this->resetAfterTest(true);
297
        $this->resetAfterTest(true);
298
 
298
 
Línea 516... Línea 516...
516
 
516
 
517
        // Logged in as, I can view a non-private instance.
517
        // Logged in as, I can view a non-private instance.
518
        $this->assertTrue($notprivaterepo->check_capability());
518
        $this->assertTrue($notprivaterepo->check_capability());
Línea 519... Línea 519...
519
    }
519
    }
520
 
520
 
521
    function test_delete_all_for_context() {
521
    function test_delete_all_for_context(): void {
Línea 522... Línea 522...
522
        global $DB;
522
        global $DB;
523
        $this->resetAfterTest(true);
523
        $this->resetAfterTest(true);
Línea 621... Línea 621...
621
 
621
 
622
        $fs = get_file_storage();
622
        $fs = get_file_storage();
623
        $fs->create_file_from_string($filerecord, hash("md5", $filepath . $filename));
623
        $fs->create_file_from_string($filerecord, hash("md5", $filepath . $filename));
Línea 624... Línea 624...
624
    }
624
    }
625
 
625
 
626
    public function test_listing_and_filter() {
626
    public function test_listing_and_filter(): void {
627
        $this->resetAfterTest(true);
627
        $this->resetAfterTest(true);
628
        $this->setUser($this->getDataGenerator()->create_user());
628
        $this->setUser($this->getDataGenerator()->create_user());
629
        $repoid = $this->getDataGenerator()->create_repository('user')->id;
629
        $repoid = $this->getDataGenerator()->create_repository('user')->id;