Passed
Branch develop (bae466)
by Paul
06:12
created

SvgTest::testFilePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Tests;
4
5
use GeminiLabs\SiteReviews\Helpers\Svg;
6
7
/**
8
 * Test case for the Plugin.
9
 *
10
 * @group plugin
11
 */
12
class SvgTest extends \WP_UnitTestCase
0 ignored issues
show
Bug introduced by
The type WP_UnitTestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
{
14
    public function testContents()
15
    {
16
        $this->assertEquals(Svg::contents('xxx'), '');
17
        $this->assertEquals(Svg::contents('tests/assets/test.svg.txt'), '');
18
        $this->assertEquals(Svg::contents(glsr()->path('tests/assets/test.svg.txt')), '');
19
        $this->assertEquals(Svg::contents(glsr()->path('tests/assets/test.svg')),
20
            '<svg xmlns="http://www.w3.org/2000/svg"></svg>'
21
        );
22
        $this->assertEquals(Svg::contents('tests/assets/test.svg'),
23
            '<svg xmlns="http://www.w3.org/2000/svg"></svg>'
24
        );
25
    }
26
27
    public function testEncoded()
28
    {
29
        $this->assertEquals(Svg::encoded('xxx'), '');
30
        $this->assertEquals(Svg::encoded('tests/assets/test.svg.txt'), '');
31
        $this->assertEquals(Svg::encoded(glsr()->path('tests/assets/test.svg.txt')), '');
32
        $this->assertEquals(Svg::encoded(glsr()->path('tests/assets/test.svg')),
33
            'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg=='
34
        );
35
        $this->assertEquals(Svg::encoded('tests/assets/test.svg'),
36
            'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg=='
37
        );
38
    }
39
40
    public function testFilePath()
41
    {
42
        $this->assertEquals(Svg::filePath('xxx'), '');
43
        $this->assertEquals(Svg::filePath('tests/assets/test.svg.txt'), '');
44
        $this->assertEquals(Svg::filePath(glsr()->path('tests/assets/test.svg.txt')), '');
45
        $this->assertEquals(Svg::filePath(glsr()->path('tests/assets/test.svg')),
46
            glsr()->path('tests/assets/test.svg')
47
        );
48
        $this->assertEquals(Svg::filePath('tests/assets/test.svg'),
49
            glsr()->path('tests/assets/test.svg')
50
        );
51
    }
52
53
    public function testGet()
54
    {
55
        $this->assertEquals(Svg::get('xxx'), '');
56
        $this->assertEquals(Svg::get('tests/assets/test.svg.txt'), '');
57
        $this->assertEquals(Svg::get(glsr()->path('tests/assets/test.svg.txt')), '');
58
        $this->assertEquals(Svg::get(glsr()->path('tests/assets/test.svg')),
59
            '<svg style="pointer-events: none;" xmlns="http://www.w3.org/2000/svg"></svg>'
60
        );
61
        $this->assertEquals(Svg::get('tests/assets/test.svg'),
62
            '<svg style="pointer-events: none;" xmlns="http://www.w3.org/2000/svg"></svg>'
63
        );
64
        $this->assertEquals(
65
            Svg::get('tests/assets/test.svg', [
66
                'fill' => 'currentColor',
67
                'height' => 20,
68
                'style' => 'color: red;',
69
                'width' => 20,
70
            ]),
71
            '<svg fill="currentColor" height="20" style="pointer-events: none; color: red;" width="20" xmlns="http://www.w3.org/2000/svg"></svg>'
72
        );
73
    }
74
}
75