|
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 |
|
|
|
|
|
|
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
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths