public function testStylesheetsRespectCacheBustOption()
 {
     $tagger = new Tagger();
     $tag = $tagger->getStylesheetTag('myscript.css', "text");
     $this->assertEquals('<link href="myscript.css?cb=text" rel="stylesheet" type="text/css" />', $tag, 'Tagger should not contain end of lines by default');
     $tagger->cacheBustKey = 'mtime';
     $tag = $tagger->getStylesheetTag('myscript.css', 123);
     $this->assertEquals('<link href="myscript.css?mtime=123" rel="stylesheet" type="text/css" />', $tag, 'Tagger should contain end of lines by default');
 }
 public function testGetStylesheetTag()
 {
     $tagger = new Tagger();
     $tag = $tagger->getStylesheetTag('myscript.css');
     $this->assertEquals('<link href="myscript.css" rel="stylesheet" type="text/css" />', $tag, 'Tagger should convert filepath to stylesheet tag pointing to file path');
     $tag = $tagger->getStylesheetTag('some/path/myscript.css');
     $this->assertEquals('<link href="some/path/myscript.css" rel="stylesheet" type="text/css" />', $tag, 'Tagger should convert filepath to stylesheet tag pointing to file path');
     $tag = $tagger->getStylesheetTag('https://www.somewhere.com/css/myscript.css');
     $this->assertEquals('<link href="https://www.somewhere.com/css/myscript.css" rel="stylesheet" type="text/css" />', $tag, 'Tagger should convert filepath to stylesheet tag pointing to file path');
 }
 public function testGetScriptTag()
 {
     $tagger = new Tagger();
     $tag = $tagger->getScriptTag('myscript.js');
     $this->assertEquals('<script type="text/javascript" src="myscript.js"></script>', $tag, 'Tagger should convert filepath to script tag pointing to file path');
     $tag = $tagger->getScriptTag('some/path/myscript.js');
     $this->assertEquals('<script type="text/javascript" src="some/path/myscript.js"></script>', $tag, 'Tagger should convert filepath to script tag pointing to file path');
     $tag = $tagger->getScriptTag('http://www.somewhere.com/js/myscript.js');
     $this->assertEquals('<script type="text/javascript" src="http://www.somewhere.com/js/myscript.js"></script>', $tag, 'Tagger should convert filepath to script tag pointing to file path');
 }
예제 #4
0
 public function testGetTagThrowsOnTypeDetectionFailure()
 {
     $tagger = new Tagger();
     try {
         $tag = $tagger->getTag('myscript.gif');
         $this->fail('Should throw ExtensionParsingException');
     } catch (ExtensionParsingException $e) {
         $this->assertInstanceOf('JsPackager\\Exception\\ExtensionParsingException', $e);
         $this->assertEquals($e->getItemThatFailedToParse(), 'myscript.gif');
     }
 }
 public function testStylesheetsRespectEndOfLineOption()
 {
     $tagger = new Tagger();
     $tag = $tagger->getStylesheetTag('myscript.css');
     $this->assertEquals('<link href="myscript.css" rel="stylesheet" type="text/css" />', $tag, 'Tagger should not contain end of lines by default');
     $tagger->includingEndOfLine = true;
     $tag = $tagger->getStylesheetTag('myscript.css');
     $this->assertEquals('<link href="myscript.css" rel="stylesheet" type="text/css" />' . PHP_EOL, $tag, 'Tagger should contain end of lines by default');
     $tagger->includingEndOfLine = false;
     $tag = $tagger->getStylesheetTag('myscript.css');
     $this->assertEquals('<link href="myscript.css" rel="stylesheet" type="text/css" />', $tag, 'Tagger should respect flag when toggled');
 }
 public function testConfigureStylesheetMediaType()
 {
     $tagger = new Tagger();
     $tag = $tagger->getStylesheetTag('myscript.css');
     $this->assertEquals('<link href="myscript.css" rel="stylesheet" type="text/css" />', $tag, 'Tagger should use media="screen" by default');
     $tagger->setStylesheetMediaType('screen');
     $tag = $tagger->getStylesheetTag('myscript.css');
     $this->assertEquals('<link href="myscript.css" media="screen" rel="stylesheet" type="text/css" />', $tag, 'Tagger should use media="screen" by default');
     $tagger->setStylesheetMediaType('print, screen');
     $tag = $tagger->getStylesheetTag('myscript.css');
     $this->assertEquals('<link href="myscript.css" media="print, screen" rel="stylesheet" type="text/css" />', $tag, 'Tagger should use media="screen" by default');
     $tagger->setStylesheetMediaType(null);
 }