[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/_test/tests/lib/exe/ -> css_css_loadfile.test.php (source)

   1  <?php
   2  
   3  require_once  DOKU_INC.'lib/exe/css.php';
   4  
   5  class css_css_loadfile_test extends DokuWikiTest {
   6  
   7      protected $file = '';
   8  
   9      public function setUp() : void {
  10          $this->file = tempnam(TMP_DIR, 'css');
  11      }
  12  
  13      private function csstest($input, $output = null, $location = 'http://www.example.com/') {
  14          io_saveFile($this->file, $input);
  15          $this->assertEquals((is_null($output) ? $input : $output), css_loadfile($this->file, $location));
  16      }
  17  
  18      public function test_url_relative() {
  19          $this->csstest('#test { background: url("test/test.png"); }', '#test { background: url("http://www.example.com/test/test.png"); }');
  20          $this->csstest('#test { background: url(\'test/test.png\'); }', '#test { background: url(\'http://www.example.com/test/test.png\'); }');
  21      }
  22  
  23      public function test_url_absolute() {
  24          $this->csstest('#test { background: url("/test/test.png"); }');
  25          $this->csstest('#test { background: url(\'/test/test.png\'); }');
  26      }
  27  
  28      public function test_url_with_protocol() {
  29          $this->csstest('#test { background: url("http://www.test.com/test/test.png"); }');
  30          $this->csstest('#test { background: url("https://www.test.com/test/test.png"); }');
  31          $this->csstest('#test { background: url(\'http://www.test.com/test/test.png\'); }');
  32          $this->csstest('#test { background: url(\'https://www.test.com/test/test.png\'); }');
  33      }
  34  
  35      public function test_import_relative() {
  36          $this->csstest('@import "test/test.png";', '@import "http://www.example.com/test/test.png";');
  37          $this->csstest('@import \'test/test.png\';', '@import \'http://www.example.com/test/test.png\';');
  38          $this->csstest('@import url(test/test.png);', '@import url(http://www.example.com/test/test.png);');
  39          $this->csstest('@import url("test/test.png");', '@import url("http://www.example.com/test/test.png");');
  40      }
  41  
  42      public function test_import_absolute() {
  43          $this->csstest('@import "/test/test.png";');
  44          $this->csstest('@import \'/test/test.png\';');
  45          $this->csstest('@import url(/test/test.png);');
  46          $this->csstest('@import url("/test/test.png");');
  47      }
  48  
  49      public function test_import_with_protocol() {
  50          $this->csstest('@import "http://www.test.com/test/test.png";');
  51          $this->csstest('@import "https://www.test.com/test/test.png";');
  52          $this->csstest('@import \'http://www.test.com/test/test.png\';');
  53          $this->csstest('@import \'https://www.test.com/test/test.png\';');
  54          $this->csstest('@import url(http://www.test.com/test/test.png);');
  55          $this->csstest('@import url("http://www.test.com/test/test.png");');
  56      }
  57  
  58      public function test_less_basic() {
  59          $this->csstest('@import "test.less"', '@import "/test.less"');
  60          $this->csstest('@import "/test.less"', '@import "/test.less"');
  61          $this->csstest('@import "foo/test.less"', '@import "/foo/test.less"');
  62          $this->csstest('@import url(http://test.less)');
  63      }
  64  
  65      // more expected use, where less @import(ed) from e.g. lib/plugins/plugin_name
  66      public function test_less_subdirectories() {
  67  
  68          unlink($this->file);
  69  
  70          $dir = TMP_DIR.'/foo/bar';
  71          if (!is_dir($dir)) {
  72              mkdir($dir, 0777, true);
  73          }
  74          if (!is_dir($dir)) {
  75              $this->markTestSkipped('Could not create directory.');
  76          }
  77  
  78          $this->file = tempnam($dir, 'css');
  79  
  80          if (isWindows()) {
  81              $this->csstest('@import "test.less"', '@import "\foo\bar/test.less"');
  82              $this->csstest('@import \'test.less\'', '@import \'\foo\bar/test.less\'');
  83              $this->csstest('@import url(test.less)', '@import url(\foo\bar/test.less)');
  84              $this->csstest('@import "abc/test.less"', '@import "\foo\bar/abc/test.less"');
  85          } else {
  86              $this->csstest('@import "test.less"', '@import "/foo/bar/test.less"');
  87              $this->csstest('@import \'test.less\'', '@import \'/foo/bar/test.less\'');
  88              $this->csstest('@import url(test.less)', '@import url(/foo/bar/test.less)');
  89              $this->csstest('@import "abc/test.less"', '@import "/foo/bar/abc/test.less"');
  90          }
  91      }
  92  
  93      public function tearDown() : void {
  94          unlink($this->file);
  95          unset($this->file);
  96      }
  97  }
  98  
  99  //Setup VIM: ex: et ts=4 sw=4 :