Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 39... Línea 39...
39
 
39
 
40
    protected function tearDown(): void {
40
    protected function tearDown(): void {
41
        @unlink($this->tempfile);
41
        @unlink($this->tempfile);
Línea 42... Línea 42...
42
    }
42
    }
43
 
43
 
44
    public function test_scan_file_not_exists() {
44
    public function test_scan_file_not_exists(): void {
45
        $antivirus = $this->getMockBuilder('\antivirus_clamav\scanner')
45
        $antivirus = $this->getMockBuilder('\antivirus_clamav\scanner')
Línea 46... Línea 46...
46
            ->onlyMethods(array('scan_file_execute_commandline', 'message_admins'))
46
            ->onlyMethods(array('scan_file_execute_commandline', 'message_admins'))
Línea 52... Línea 52...
52
        // Run mock scanning, we expect SCAN_RESULT_ERROR.
52
        // Run mock scanning, we expect SCAN_RESULT_ERROR.
53
        $this->assertEquals(2, $antivirus->scan_file($nonexistingfile, ''));
53
        $this->assertEquals(2, $antivirus->scan_file($nonexistingfile, ''));
54
        $this->assertDebuggingCalled();
54
        $this->assertDebuggingCalled();
55
    }
55
    }
Línea 56... Línea 56...
56
 
56
 
57
    public function test_scan_file_no_virus() {
57
    public function test_scan_file_no_virus(): void {
58
        $methods = array(
58
        $methods = array(
59
            'scan_file_execute_commandline',
59
            'scan_file_execute_commandline',
60
            'scan_file_execute_socket',
60
            'scan_file_execute_socket',
61
            'message_admins',
61
            'message_admins',
Línea 93... Línea 93...
93
 
93
 
94
        // Run mock scanning.
94
        // Run mock scanning.
95
        $this->assertEquals(0, $antivirus->scan_file($this->tempfile, ''));
95
        $this->assertEquals(0, $antivirus->scan_file($this->tempfile, ''));
Línea 96... Línea 96...
96
    }
96
    }
97
 
97
 
98
    public function test_scan_file_virus() {
98
    public function test_scan_file_virus(): void {
99
        $methods = array(
99
        $methods = array(
100
            'scan_file_execute_commandline',
100
            'scan_file_execute_commandline',
101
            'scan_file_execute_socket',
101
            'scan_file_execute_socket',
Línea 134... Línea 134...
134
 
134
 
135
        // Run mock scanning.
135
        // Run mock scanning.
136
        $this->assertEquals(1, $antivirus->scan_file($this->tempfile, ''));
136
        $this->assertEquals(1, $antivirus->scan_file($this->tempfile, ''));
Línea 137... Línea 137...
137
    }
137
    }
138
 
138
 
139
    public function test_scan_file_error_donothing() {
139
    public function test_scan_file_error_donothing(): void {
140
        $methods = array(
140
        $methods = array(
141
            'scan_file_execute_commandline',
141
            'scan_file_execute_commandline',
142
            'scan_file_execute_socket',
142
            'scan_file_execute_socket',
Línea 181... Línea 181...
181
 
181
 
182
        // Run mock scanning.
182
        // Run mock scanning.
183
        $this->assertEquals(2, $antivirus->scan_file($this->tempfile, ''));
183
        $this->assertEquals(2, $antivirus->scan_file($this->tempfile, ''));
Línea 184... Línea 184...
184
    }
184
    }
185
 
185
 
186
    public function test_scan_file_error_actlikevirus() {
186
    public function test_scan_file_error_actlikevirus(): void {
187
        $methods = array(
187
        $methods = array(
188
            'scan_file_execute_commandline',
188
            'scan_file_execute_commandline',
189
            'scan_file_execute_socket',
189
            'scan_file_execute_socket',
Línea 231... Línea 231...
231
        // Run mock scanning, we expect SCAN_RESULT_FOUND since configuration
231
        // Run mock scanning, we expect SCAN_RESULT_FOUND since configuration
232
        // require us to act like virus.
232
        // require us to act like virus.
233
        $this->assertEquals(1, $antivirus->scan_file($this->tempfile, ''));
233
        $this->assertEquals(1, $antivirus->scan_file($this->tempfile, ''));
234
    }
234
    }
Línea 235... Línea 235...
235
 
235
 
236
    public function test_scan_file_error_tryagain() {
236
    public function test_scan_file_error_tryagain(): void {
237
        $methods = array(
237
        $methods = array(
238
                'scan_file_execute_commandline',
238
                'scan_file_execute_commandline',
239
                'scan_file_execute_unixsocket',
239
                'scan_file_execute_unixsocket',
240
                'message_admins',
240
                'message_admins',
Línea 263... Línea 263...
263
        $antivirus->scan_file($this->tempfile, '');
263
        $antivirus->scan_file($this->tempfile, '');
264
        $this->assertEquals('antivirusfailed', $this->getExpectedExceptionCode());
264
        $this->assertEquals('antivirusfailed', $this->getExpectedExceptionCode());
265
        $this->assertFileDoesNotExist($this->tempfile);
265
        $this->assertFileDoesNotExist($this->tempfile);
266
    }
266
    }
Línea 267... Línea 267...
267
 
267
 
268
    public function test_scan_data_no_virus() {
268
    public function test_scan_data_no_virus(): void {
269
        $methods = array(
269
        $methods = array(
270
            'scan_data_execute_socket',
270
            'scan_data_execute_socket',
271
            'message_admins',
271
            'message_admins',
272
            'get_config',
272
            'get_config',
Línea 297... Línea 297...
297
 
297
 
298
        // Run mock scanning.
298
        // Run mock scanning.
299
        $this->assertEquals(0, $antivirus->scan_data(''));
299
        $this->assertEquals(0, $antivirus->scan_data(''));
Línea 300... Línea 300...
300
    }
300
    }
301
 
301
 
302
    public function test_scan_data_virus() {
302
    public function test_scan_data_virus(): void {
303
        $methods = array(
303
        $methods = array(
304
            'scan_data_execute_socket',
304
            'scan_data_execute_socket',
305
            'message_admins',
305
            'message_admins',
Línea 331... Línea 331...
331
 
331
 
332
        // Run mock scanning.
332
        // Run mock scanning.
333
        $this->assertEquals(1, $antivirus->scan_data(''));
333
        $this->assertEquals(1, $antivirus->scan_data(''));
Línea 334... Línea 334...
334
    }
334
    }
335
 
335
 
336
    public function test_scan_data_error_donothing() {
336
    public function test_scan_data_error_donothing(): void {
337
        $methods = array(
337
        $methods = array(
338
            'scan_data_execute_socket',
338
            'scan_data_execute_socket',
339
            'message_admins',
339
            'message_admins',
Línea 369... Línea 369...
369
 
369
 
370
        // Run mock scanning.
370
        // Run mock scanning.
371
        $this->assertEquals(2, $antivirus->scan_data(''));
371
        $this->assertEquals(2, $antivirus->scan_data(''));
Línea 372... Línea 372...
372
    }
372
    }
373
 
373
 
374
    public function test_scan_data_error_actlikevirus() {
374
    public function test_scan_data_error_actlikevirus(): void {
375
        $methods = array(
375
        $methods = array(
376
            'scan_data_execute_socket',
376
            'scan_data_execute_socket',
377
            'message_admins',
377
            'message_admins',