diff options
author | Christopher Smith <chris@jalakai.co.uk> | 2013-11-05 20:09:45 +0000 |
---|---|---|
committer | Christopher Smith <chris@jalakai.co.uk> | 2013-11-05 20:09:45 +0000 |
commit | 5f5982130c1a9b9adb0e294b811327ddcfbd4fef (patch) | |
tree | ecadd4eeb3d1e4b615ed81099b7ca12466fe6ef4 /_test | |
parent | 6a5d68178752212e9dc2ef82d500940b49bf6500 (diff) | |
download | rpg-5f5982130c1a9b9adb0e294b811327ddcfbd4fef.tar.gz rpg-5f5982130c1a9b9adb0e294b811327ddcfbd4fef.tar.bz2 |
Improve css_loadfile() tests
- use TMP_DIR constant rather than /tmp
- swap order of parameters in csstest() to match reported 'expected' & 'actual'
- add tests for use of 'url()' in @import
- add tests for @import of '.less' files (these test will fail per FS#2875)
Diffstat (limited to '_test')
-rw-r--r-- | _test/tests/lib/exe/css_css_loadfile.test.php | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/_test/tests/lib/exe/css_css_loadfile.test.php b/_test/tests/lib/exe/css_css_loadfile.test.php index c89b69b2c..0aa27b0af 100644 --- a/_test/tests/lib/exe/css_css_loadfile.test.php +++ b/_test/tests/lib/exe/css_css_loadfile.test.php @@ -3,13 +3,16 @@ require_once DOKU_INC.'lib/exe/css.php'; class css_css_loadfile_test extends DokuWikiTest { + + protected $file = ''; + public function setUp() { - $this->file = tempnam('/tmp', 'css'); + $this->file = tempnam(TMP_DIR, '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)); + $this->assertEquals((is_null($output) ? $input : $output), css_loadfile($this->file, $location)); } public function test_url_relative() { @@ -32,11 +35,15 @@ class css_css_loadfile_test extends DokuWikiTest { 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\';'); + $this->csstest('@import url(test/test.png);', '@import url(http://www.example.com/test/test.png);'); + $this->csstest('@import url("test/test.png");', '@import url("http://www.example.com/test/test.png");'); } public function test_import_absolute() { $this->csstest('@import "/test/test.png";'); $this->csstest('@import \'/test/test.png\';'); + $this->csstest('@import url(/test/test.png);'); + $this->csstest('@import url("/test/test.png");'); } public function test_import_with_protocol() { @@ -44,6 +51,28 @@ class css_css_loadfile_test extends DokuWikiTest { $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\';'); + $this->csstest('@import url(http://www.test.com/test/test.png);'); + $this->csstest('@import url("http://www.test.com/test/test.png");'); + } + + public function test_less_basic() { + $this->csstest('@import "test.less"', '@import "/test.less"'); + $this->csstest('@import "/test.less"', '@import "/test.less"'); + $this->csstest('@import url(http://test.less)'); + } + + // more expected use, where less @import(ed) from e.g. lib/plugins/plugin_name + public function test_less_subdirectories() { + + unlink($this->file); + + $dir = TMP_DIR.'/foo/bar'; + mkdir($dir,0777,true); + $this->file = tempnam($dir, 'css'); + + $this->csstest('@import "test.less"', '@import "/foo/bar/test.less"'); + $this->csstest('@import \'test.less\'', '@import \'/foo/bar/test.less\''); + $this->csstest('@import url(test.less)', '@import url(/foo/bar/test.less)'); } public function tearDown() { |