diff options
author | Michael Hamann <michael@content-space.de> | 2011-01-09 14:52:50 +0100 |
---|---|---|
committer | Michael Hamann <michael@content-space.de> | 2011-01-09 14:52:50 +0100 |
commit | 6e0b4b67444b8434ed2c351ea0e36008667251d5 (patch) | |
tree | 7becc46027688b2a07ad4321370a31211140ebe8 /_test | |
parent | f7d780b9b82a664525120a90a8b1cb25be57d0e0 (diff) | |
download | rpg-6e0b4b67444b8434ed2c351ea0e36008667251d5.tar.gz rpg-6e0b4b67444b8434ed2c351ea0e36008667251d5.tar.bz2 |
Fixed css_loadfile and removed unneeded complexity, added testcases
Diffstat (limited to '_test')
-rw-r--r-- | _test/cases/lib/exe/css_css_loadfile.test.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/_test/cases/lib/exe/css_css_loadfile.test.php b/_test/cases/lib/exe/css_css_loadfile.test.php new file mode 100644 index 000000000..a444d0086 --- /dev/null +++ b/_test/cases/lib/exe/css_css_loadfile.test.php @@ -0,0 +1,57 @@ +<?php + +require_once DOKU_INC.'lib/exe/css.php'; + +class css_css_loadfile_test extends UnitTestCase { + public function setUp() { + $this->file = tempnam('/tmp', 'css'); + parent::setUp(); + } + + private function csstest($input, $output = null, $location = 'http://www.example.com/') { + io_saveFile($this->file, $input); + $this->assertEqual(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); + parent::tearDown(); + } +} + +//Setup VIM: ex: et ts=4 sw=4 : |