summaryrefslogtreecommitdiff
path: root/_test/tests/lib/exe/css_css_loadfile.test.php
blob: c89b69b2c56e4701f67a7b2b5d9ebeabe5bacb99 (plain)
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
<?php

require_once DOKU_INC.'lib/exe/css.php';

class css_css_loadfile_test extends DokuWikiTest {
    public function setUp() {
        $this->file = tempnam('/tmp', 'css');
    }

    private function csstest($input, $output = null, $location = 'http://www.example.com/') {
        io_saveFile($this->file, $input);
        $this->assertEquals(css_loadfile($this->file, $location), (is_null($output) ? $input : $output));
    }

    public function test_url_relative() {
        $this->csstest('#test { background: url("test/test.png"); }', '#test { background: url("http://www.example.com/test/test.png"); }');
        $this->csstest('#test { background: url(\'test/test.png\'); }', '#test { background: url(\'http://www.example.com/test/test.png\'); }');
    }

    public function test_url_absolute() {
        $this->csstest('#test { background: url("/test/test.png"); }');
        $this->csstest('#test { background: url(\'/test/test.png\'); }');
    }

    public function test_url_with_protocol() {
        $this->csstest('#test { background: url("http://www.test.com/test/test.png"); }');
        $this->csstest('#test { background: url("https://www.test.com/test/test.png"); }');
        $this->csstest('#test { background: url(\'http://www.test.com/test/test.png\'); }');
        $this->csstest('#test { background: url(\'https://www.test.com/test/test.png\'); }');
    }

    public function test_import_relative() {
        $this->csstest('@import "test/test.png";', '@import "http://www.example.com/test/test.png";');
        $this->csstest('@import \'test/test.png\';', '@import \'http://www.example.com/test/test.png\';');
    }

    public function test_import_absolute() {
        $this->csstest('@import "/test/test.png";');
        $this->csstest('@import \'/test/test.png\';');
    }

    public function test_import_with_protocol() {
        $this->csstest('@import "http://www.test.com/test/test.png";');
        $this->csstest('@import "https://www.test.com/test/test.png";');
        $this->csstest('@import \'http://www.test.com/test/test.png\';');
        $this->csstest('@import \'https://www.test.com/test/test.png\';');
    }

    public function tearDown() {
        unlink($this->file);
        unset($this->file);
    }
}

//Setup VIM: ex: et ts=4 sw=4 :