예제 #1
0
 /**
  * Make sure the '.min' assets resolver is materialized
  *
  * @param string $relPath
  * @return void
  */
 private function ensureMinResolverFile($relPath)
 {
     $dir = $this->filesystem->getDirectoryWrite(DirectoryList::STATIC_VIEW);
     if ($this->appState->getMode() == AppState::MODE_DEVELOPER || !$dir->isExist($relPath)) {
         $dir->writeFile($relPath, $this->config->getMinResolverCode());
     }
 }
예제 #2
0
    public function testGetMinResolverCode()
    {
        $this->minificationMock->expects($this->once())->method('getExcludes')->with('js')->willReturn(['\\.min\\.']);
        $this->minificationMock->expects($this->once())->method('isEnabled')->with('js')->willReturn(true);
        $this->minifyAdapterMock->expects($this->once())->method('minify')->willReturnArgument(0);
        $expected = <<<code
    if (!require.s.contexts._.__load) {
        require.s.contexts._.__load = require.s.contexts._.load;
        require.s.contexts._.load = function(id, url) {
            if (!url.match(/\\.min\\./)) {
                url = url.replace(/(\\.min)?\\.js\$/, '.min.js');
            }
            return require.s.contexts._.__load.apply(require.s.contexts._, [id, url]);
        }
    }

code;
        $this->assertEquals($expected, $this->object->getMinResolverCode());
    }