PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.5
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / matthiasmullie / path-converter / tests / ConverterTest.php

ConverterTest.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/matthiasmullie/path-converter/tests/ConverterTest.php

126 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace MatthiasMullie\PathConverter\Tests;
4
5 use MatthiasMullie\PathConverter\Converter;
6
7 /**
8 * Converter test case.
9 */
10 class ConverterTest extends \PHPUnit_Framework_TestCase
11 {
12 /**
13 * Test Converter, provided by dataProvider.
14 *
15 * @test
16 * @dataProvider dataProvider
17 */
18 public function convert($relative, $from, $to, $expected)
19 {
20 $converter = new Converter($from, $to);
21 $result = $converter->convert($relative);
22
23 $this->assertEquals($expected, $result);
24 }
25
26 /**
27 * @return array [relative, from, to, expected result]
28 */
29 public function dataProvider()
30 {
31 $tests = array();
32
33 $tests[] = array(
34 '../images/img.jpg',
35 '/home/forkcms/frontend/core/layout/css',
36 '/home/forkcms/frontend/cache/minified_css',
37 '../../core/layout/images/img.jpg',
38 );
39
40 $tests[] = array(
41 '../../images/icon.gif',
42 '/css/imports/',
43 '/css/',
44 '../images/icon.gif',
45 );
46
47 // absolute path - doesn't make sense :)
48 $tests[] = array(
49 '/home/username/file.txt',
50 '/css/imports',
51 '/css',
52 '/home/username/file.txt',
53 );
54
55 $tests[] = array(
56 'image.jpg',
57 'tests/css/sample/convert_relative_path/source',
58 'tests/css/sample/convert_relative_path/source',
59 'image.jpg',
60 );
61
62 $tests[] = array(
63 '../images/img.jpg',
64 'C:/My Documents/forkcms/frontend/core/layout/css',
65 'C:/My Documents/forkcms/frontend/cache/minified_css',
66 '../../core/layout/images/img.jpg',
67 );
68
69 // https://github.com/forkcms/forkcms/issues/1186
70 $tests[] = array(
71 '../images/img.jpg',
72 '/Users/mathias/Documents/— Projecten/PROJECT_NAAM/Web/src/Backend/Core/Layout/Css/',
73 '/Users/mathias/Documents/— Projecten/PROJECT_NAAM/Web/src/Backend/Cache/MinifiedCss/',
74 '../../Core/Layout/images/img.jpg',
75 );
76
77 // https://github.com/matthiasmullie/path-converter/issues/1
78 $tests[] = array(
79 'image.jpg',
80 '/var/www/mysite.com/assets/some_random_folder_name/',
81 '/var/www/mysite.com/assets/some_other_random_folder_name/',
82 '../some_random_folder_name/image.jpg',
83 );
84
85 $tests[] = array(
86 'image.jpg',
87 '/var/www/',
88 '/',
89 'var/www/image.jpg',
90 );
91
92 $tests[] = array(
93 'image.jpg',
94 '/',
95 '/var/www/',
96 '../../image.jpg',
97 );
98
99 // https://github.com/matthiasmullie/path-converter/issues/4
100 $tests[] = array(
101 'rotissanser-webfont.eot',
102 'typo3temp/assets/compressed/../../../typo3conf/ext/user_merkl/Resources/Public/Fonts/webfontkit-rotissanser/stylesheet.css',
103 'typo3temp/assets/compressed/merged-abce7d875ee92a78bd5e1871ef774fbe.css',
104 '../../../typo3conf/ext/user_merkl/Resources/Public/Fonts/webfontkit-rotissanser/rotissanser-webfont.eot',
105 );
106
107 // https://github.com/matthiasmullie/path-converter/issues/6
108 $tests[] = array(
109 './../images/header-section/HeroImage.jpg',
110 '/wordpress/wp-content/themes/racine/styles/',
111 '/wordpress/wp-content/cache/min/',
112 '../../themes/racine/images/header-section/HeroImage.jpg',
113 );
114
115 // https://github.com/matthiasmullie/path-converter/issues/6
116 $tests[] = array(
117 '../images/./header-section/HeroImage2.jpg',
118 '/wordpress/wp-content/themes/racine/styles/',
119 '/wordpress/wp-content/cache/min/',
120 '../../themes/racine/images/header-section/HeroImage2.jpg',
121 );
122
123 return $tests;
124 }
125 }
126