Пример #1
0
 public function testProcess()
 {
     $expectedContent = 'updated content';
     $tmpFile = 'tmp/file.ext';
     $this->fileGenerator->expects($this->once())->method('generateFileTree')->with($this->chain)->will($this->returnValue($tmpFile));
     $this->adapter->expects($this->once())->method('process')->with($tmpFile)->will($this->returnValue($expectedContent));
     $this->object->process($this->chain);
     $this->assertEquals($expectedContent, $this->chain->getContent());
     $this->assertEquals('css', $this->chain->getContentType());
 }
Пример #2
0
 public function testGettersAndSetters()
 {
     $this->assertEquals('origType', $this->object->getOrigContentType());
     $this->assertEquals('origType', $this->object->getContentType());
     $this->assertEquals('origContent', $this->object->getOrigContent());
     $this->assertEquals('origContent', $this->object->getContent());
     $this->assertEquals('assetType', $this->object->getTargetContentType());
     $this->object->setContent('anotherContent');
     $this->object->setContentType('anotherType');
     $this->assertEquals('origType', $this->object->getOrigContentType());
     $this->assertEquals('anotherType', $this->object->getContentType());
     $this->assertEquals('origContent', $this->object->getOrigContent());
     $this->assertEquals('anotherContent', $this->object->getContent());
     $this->assertEquals('assetType', $this->object->getTargetContentType());
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function process(\Magento\Framework\View\Asset\PreProcessor\Chain $chain)
 {
     $asset = $chain->getAsset();
     $contentType = $chain->getContentType();
     $replaceCallback = function ($matchContent) use($asset, $contentType) {
         return $this->replace($matchContent, $asset, $contentType);
     };
     $content = $this->removeComments($chain->getContent());
     $processedContent = preg_replace_callback(self::REPLACE_PATTERN, $replaceCallback, $content);
     if ($processedContent !== $content) {
         $chain->setContent($processedContent);
     }
 }