xref: /dokuwiki/_test/tests/lib/exe/css_css_loadfile.test.php (revision e260f93b6cea05bc39bbd77b9db5bdc0c2c424bf)
1<?php
2
3require_once DOKU_INC.'lib/exe/css.php';
4
5class css_css_loadfile_test extends DokuWikiTest {
6    public function setUp() {
7        $this->file = tempnam('/tmp', 'css');
8    }
9
10    private function csstest($input, $output = null, $location = 'http://www.example.com/') {
11        io_saveFile($this->file, $input);
12        $this->assertEquals(css_loadfile($this->file, $location), (is_null($output) ? $input : $output));
13    }
14
15    public function test_url_relative() {
16        $this->csstest('#test { background: url("test/test.png"); }', '#test { background: url("http://www.example.com/test/test.png"); }');
17        $this->csstest('#test { background: url(\'test/test.png\'); }', '#test { background: url(\'http://www.example.com/test/test.png\'); }');
18    }
19
20    public function test_url_absolute() {
21        $this->csstest('#test { background: url("/test/test.png"); }');
22        $this->csstest('#test { background: url(\'/test/test.png\'); }');
23    }
24
25    public function test_url_with_protocol() {
26        $this->csstest('#test { background: url("http://www.test.com/test/test.png"); }');
27        $this->csstest('#test { background: url("https://www.test.com/test/test.png"); }');
28        $this->csstest('#test { background: url(\'http://www.test.com/test/test.png\'); }');
29        $this->csstest('#test { background: url(\'https://www.test.com/test/test.png\'); }');
30    }
31
32    public function test_import_relative() {
33        $this->csstest('@import "test/test.png";', '@import "http://www.example.com/test/test.png";');
34        $this->csstest('@import \'test/test.png\';', '@import \'http://www.example.com/test/test.png\';');
35    }
36
37    public function test_import_absolute() {
38        $this->csstest('@import "/test/test.png";');
39        $this->csstest('@import \'/test/test.png\';');
40    }
41
42    public function test_import_with_protocol() {
43        $this->csstest('@import "http://www.test.com/test/test.png";');
44        $this->csstest('@import "https://www.test.com/test/test.png";');
45        $this->csstest('@import \'http://www.test.com/test/test.png\';');
46        $this->csstest('@import \'https://www.test.com/test/test.png\';');
47    }
48
49    public function tearDown() {
50        unlink($this->file);
51        unset($this->file);
52    }
53}
54
55//Setup VIM: ex: et ts=4 sw=4 :
56