/** * Transform content and/or content type for the specified preprocessing chain object * * @param PreProcessor\Chain $chain * @return void */ public function process(PreProcessor\Chain $chain) { $content = $chain->getContent(); if (trim($content) !== '') { return; } try { $this->lockerProcess->lockProcess($this->lockName); $path = $chain->getAsset()->getFilePath(); $module = $chain->getAsset()->getModule(); /** @var FallbackContext $context */ $context = $chain->getAsset()->getContext(); $chain->setContent($this->processContent($path, $content, $module, $context)); } finally { $this->lockerProcess->unlockProcess(); } }
/** * Run test for process method (content not empty) */ public function testProcessContentNotEmpty() { $chainMock = $this->getChainMock(); $assetMock = $this->getAssetMock(); $chainMock->expects(self::once())->method('getContent')->willReturn('test-content'); $chainMock->expects(self::never())->method('getAsset')->willReturn($assetMock); $this->lockerProcessMock->expects(self::never())->method('lockProcess'); $this->lockerProcessMock->expects(self::never())->method('unlockProcess'); $frontendCompilation = new FrontendCompilation($this->assetSourceMock, $this->assetBuilderMock, $this->alternativeSourceMock, $this->lockerProcessMock, 'lock'); $frontendCompilation->process($chainMock); }
/** * Run test for process method (content not empty) */ public function testProcessContentNotEmpty() { $chainMock = $this->getChainMock(); $assetMock = $this->getAssetMock(); $chainMock->expects(self::once())->method('getContent')->willReturn('test-content'); $chainMock->expects(self::once())->method('getAsset')->willReturn($assetMock); $this->lockerProcessMock->expects(self::never())->method('lockProcess'); $this->lockerProcessMock->expects(self::never())->method('unlockProcess'); $alternativeSource = new AlternativeSource($this->objectManagerMock, $this->lockerProcessMock, $this->sorterMock, $this->assetBuilderMock, 'lock', []); $alternativeSource->process($chainMock); }