ImageSanitizeTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 7
dl 0
loc 20
rs 10
c 3
b 1
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A it_removes_malicious_code() 0 7 1
A it_detects_embedded_malicious_code() 0 6 1
1
<?php
2
3
namespace LaravelAt\ImageSanitize\Tests;
4
5
use LaravelAt\ImageSanitize\ImageSanitize;
6
7
class ImageSanitizeTest extends TestCase
8
{
9
    /** @test */
10
    public function it_detects_embedded_malicious_code()
11
    {
12
        $content = file_get_contents(__DIR__.'/stubs/exploit.jpeg');
13
14
        $this->assertTrue(
15
            $this->app->make(ImageSanitize::class)->detect($content)
0 ignored issues
show
Bug introduced by
The method make() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

15
            $this->app->/** @scrutinizer ignore-call */ 
16
                        make(ImageSanitize::class)->detect($content)

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
16
        );
17
    }
18
19
    /** @test */
20
    public function it_removes_malicious_code()
21
    {
22
        $content = file_get_contents(__DIR__.'/stubs/exploit.jpeg');
23
24
        $secureImage = $this->app->make(ImageSanitize::class)->sanitize($content);
25
26
        $this->assertFalse($this->app->make(ImageSanitize::class)->detect($secureImage));
27
    }
28
}
29