예제 #1
0
 /**
  * Test for processContent method (not empty content)
  */
 public function testProcessContentNotEmpty()
 {
     $assetMock = $this->getAssetMock();
     $this->appStateMock->expects(self::once())->method('getMode')->willReturn(State::MODE_DEVELOPER);
     $this->assetSourceMock->expects(self::once())->method('getContent')->with($assetMock)->willReturn(self::TEST_CONTENT);
     $this->temporaryFileMock->expects(self::once())->method('createFile')->with(self::ASSET_PATH, self::TEST_CONTENT)->willReturn(__DIR__ . '/' . self::TMP_PATH_LESS);
     $assetMock->expects(self::once())->method('getPath')->willReturn(self::ASSET_PATH);
     $this->loggerMock->expects(self::never())->method('critical');
     $clearSymbol = ["\n", "\r", "\t", ' '];
     self::assertEquals(trim(str_replace($clearSymbol, '', file_get_contents(__DIR__ . '/' . self::TMP_PATH_CSS))), trim(str_replace($clearSymbol, '', $this->processor->processContent($assetMock))));
 }
 public function testGenerateFileTree()
 {
     $lessDirectory = 'path/to/less';
     $expectedContent = 'updated content';
     $expectedRelativePath = 'some/file.less';
     $expectedPath = $lessDirectory . '/some/file.less';
     $asset = $this->getMock('Magento\\Framework\\View\\Asset\\File', [], [], '', false);
     $chain = $this->getMock('Magento\\Framework\\View\\Asset\\PreProcessor\\Chain', [], [], '', false);
     $this->config->expects($this->any())->method('getLessDirectory')->willReturn($lessDirectory);
     $this->tmpDirectory->expects($this->once())->method('isExist')->willReturn(true);
     $this->magentoImport->expects($this->once())->method('process')->with($chain);
     $this->import->expects($this->once())->method('process')->with($chain);
     $this->relatedGenerator->expects($this->once())->method('generate')->with($this->import);
     $asset->expects($this->once())->method('getPath')->will($this->returnValue('some/file.css'));
     $chain->expects($this->once())->method('getContent')->willReturn($expectedContent);
     $chain->expects($this->once())->method('getAsset')->willReturn($asset);
     $chain->expects($this->once())->method('getContentType')->willReturn('less');
     $this->temporaryFile->expects($this->once())->method('createFile')->with($expectedRelativePath, $expectedContent)->willReturn($expectedPath);
     $this->assertSame($expectedPath, $this->object->generateFileTree($chain));
 }