コード例 #1
0
 public function testShouldNotMinifyCozExists()
 {
     $this->prepareAttemptToMinifyMock(true);
     // IS_EXISTS is assumed by default, so nothing to mock here
     $this->_adapter->expects($this->never())->method('minify');
     $this->assertStringMatchesFormat('%s_library.min.js', $this->_model->getFilePath());
 }
コード例 #2
0
 /**
  * @param int $mtimeOrig
  * @param int $mtimeMinified
  * @param bool $isMinifyExpected
  * @dataProvider minifyMtimeDataProvider
  */
 public function testMinifyMtime($mtimeOrig, $mtimeMinified, $isMinifyExpected)
 {
     $this->prepareAttemptToMinifyMock(true, false);
     $model = new Minified($this->_asset, $this->_logger, $this->_filesystem, $this->_baseUrl, $this->_adapter, Minified::MTIME);
     $this->_rootDir->expects($this->any())->method('getRelativePath')->will($this->returnValueMap([['/foo/bar/test/library.min.js', 'test/library.min.js'], ['/foo/bar/test/library.js', 'test/library.js']]));
     $this->_rootDir->expects($this->once())->method('isExist')->with('test/library.min.js')->will($this->returnValue(false));
     $this->_rootDir->expects($this->once())->method('stat')->with('test/library.js')->will($this->returnValue(['mtime' => $mtimeOrig]));
     $this->_staticViewDir->expects($this->once())->method('stat')->with($this->anything())->will($this->returnValue(['mtime' => $mtimeMinified]));
     if ($isMinifyExpected) {
         $this->_asset->expects($this->once())->method('getContent')->will($this->returnValue('content'));
         $this->_adapter->expects($this->once())->method('minify')->with('content')->will($this->returnValue('mini'));
         $this->_staticViewDir->expects($this->once())->method('writeFile')->with($this->anything(), 'mini');
     } else {
         $this->_adapter->expects($this->never())->method('minify');
     }
     $this->assertStringMatchesFormat('%s_library.min.js', $model->getFilePath());
 }