- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetFullPathTest.php
More file actions
79 lines (65 loc) · 2.26 KB
/
GetFullPathTest.php
File metadata and controls
79 lines (65 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace Mpdf;
class GetFullPathTest extends \Yoast\PHPUnitPolyfills\TestCases\TestCase
{
public function testGetFullPath()
{
$originalImagePath = $path = __DIR__ . '/../data/img/demo.svg';
$originalImagePath = str_replace("\\", '/', $originalImagePath); //Fix path if on Windows
$mpdf = new Mpdf();
$mpdf->basepath = 'http://test.com';
/* Test absolute path is returned */
$mpdf->GetFullPath($path);
$this->assertEquals($originalImagePath, $path);
/* Test URL is returned using $mpdf->basepath */
$localImage = $path = 'path/for/empty/image.jpg';
$mpdf->GetFullPath($path);
$this->assertEquals($mpdf->basepath . $localImage, $path);
/* Test URL is returned using $mpdf->basepath */
$localImage2 = $path = '/path/for/empty/image.jpg';
$mpdf->GetFullPath($path);
$this->assertEquals($mpdf->basepath . $localImage2, $path);
}
/**
* @dataProvider dataProviderRemoteBasepath
*/
public function testGetFullPathRemoteBasepath($path, $result, $basePath)
{
$mpdf = new Mpdf();
$mpdf->basepath = 'http://test.com';
$mpdf->GetFullPath($path, $basePath);
$this->assertEquals($result, $path);
}
/**
* @dataProvider dataProviderLocalBasepath
*/
public function testGetFullPathLocalBasepath($path, $result, $basePath)
{
$mpdf = new Mpdf();
$mpdf->basepath = '/var/www/test';
$mpdf->GetFullPath($path, $basePath);
$this->assertEquals($result, $path);
}
public function dataProviderRemoteBasepath()
{
return [
['simple-path', 'http://test.comsimple-path', null],
['/absolute-path', 'http://test.com/absolute-path', null],
['../relative-path', 'http://test.com/relative-path', null],
['../../../multi-level-relative-path', 'http://test.com/multi-level-relative-path', null],
['https://absolute.url', 'https://absolute.url', null],
['file://local.url', 'file://local.url', null],
];
}
public function dataProviderLocalBasepath()
{
return [
['simple-path', '/var/www/testsimple-path', null],
['/absolute-path', '/absolute-path', null],
['../relative-path', '/var/www/relative-path', null],
['../../../multi-level-relative-path', '/var/www/multi-level-relative-path', null], // @todo
['https://absolute.url', 'https://absolute.url', null],
['file://local.url', 'file://local.url', null],
];
}
}