diff --git a/lib/internal/Magento/Framework/View/Asset/File.php b/lib/internal/Magento/Framework/View/Asset/File.php index 2aa6cdd733c352e65b4ab91527d0aaae4e4f44a7..8354e2aa3d417b93690f41168861b073a5da4633 100644 --- a/lib/internal/Magento/Framework/View/Asset/File.php +++ b/lib/internal/Magento/Framework/View/Asset/File.php @@ -6,8 +6,7 @@ namespace Magento\Framework\View\Asset; -use Magento\Framework\Filesystem; -use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\View\Asset\ConfigInterface as AssetConfigInterface; /** * A locally available static view file asset that can be referred with a file path @@ -51,9 +50,6 @@ class File implements MergeableInterface */ private $minification; - /** @var Filesystem */ - protected $filesystem; - /** * @param Source $source * @param ContextInterface $context @@ -61,7 +57,6 @@ class File implements MergeableInterface * @param string $module * @param string $contentType * @param Minification $minification - * @param Filesystem $filesystem */ public function __construct( Source $source, @@ -69,8 +64,7 @@ class File implements MergeableInterface $filePath, $module, $contentType, - Minification $minification, - Filesystem $filesystem + Minification $minification ) { $this->source = $source; $this->context = $context; @@ -78,7 +72,6 @@ class File implements MergeableInterface $this->module = $module; $this->contentType = $contentType; $this->minification = $minification; - $this->filesystem = $filesystem; } /** @@ -110,17 +103,12 @@ class File implements MergeableInterface */ public function getPath() { - $path = ''; - $path = $this->join($path, $this->context->getPath()); - $path = $this->join($path, $this->module); - $path = $this->join($path, $this->filePath); - $minifiedPath = $this->minification->addMinifiedSign($path); - if ($path !== $minifiedPath - && $this->filesystem->getDirectoryRead(DirectoryList::STATIC_VIEW)->isExist($minifiedPath) - ) { - $path = $minifiedPath; - } - return $path; + $result = ''; + $result = $this->join($result, $this->context->getPath()); + $result = $this->join($result, $this->module); + $result = $this->join($result, $this->filePath); + $result = $this->minification->addMinifiedSign($result); + return $result; } /** diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php index 0307ac4b738135498583336b4e72e9a309aa9fce..128081901a5c97d0cee7f901429ac1cf6466feb5 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/FileTest.php @@ -6,8 +6,7 @@ namespace Magento\Framework\View\Test\Unit\Asset; -use Magento\Framework\View\Asset\File; -use Magento\Framework\App\Filesystem\DirectoryList; +use \Magento\Framework\View\Asset\File; class FileTest extends \PHPUnit_Framework_TestCase { @@ -31,9 +30,6 @@ class FileTest extends \PHPUnit_Framework_TestCase */ private $object; - /** @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject */ - private $filesystem; - public function setUp() { $this->source = $this->getMock('Magento\Framework\View\Asset\Source', [], [], '', false); @@ -41,9 +37,6 @@ class FileTest extends \PHPUnit_Framework_TestCase $this->minificationMock = $this->getMockBuilder('Magento\Framework\View\Asset\Minification') ->disableOriginalConstructor() ->getMock(); - $this->filesystem = $this->getMockBuilder('Magento\Framework\Filesystem') - ->disableOriginalConstructor() - ->getMock(); $this->minificationMock ->expects($this->any()) @@ -56,8 +49,7 @@ class FileTest extends \PHPUnit_Framework_TestCase 'dir/file.css', 'Magento_Module', 'css', - $this->minificationMock, - $this->filesystem + $this->minificationMock ); } @@ -71,7 +63,7 @@ class FileTest extends \PHPUnit_Framework_TestCase public function testGetContentType() { $this->assertEquals('css', $this->object->getContentType()); - $object = new File($this->source, $this->context, '', '', 'type', $this->minificationMock, $this->filesystem); + $object = new File($this->source, $this->context, '', '', 'type', $this->minificationMock); $this->assertEquals('type', $object->getContentType()); } @@ -84,57 +76,8 @@ class FileTest extends \PHPUnit_Framework_TestCase */ public function testGetPath($contextPath, $module, $filePath, $expected) { - $this->context->expects($this->atLeastOnce()) - ->method('getPath') - ->willReturn($contextPath); - $object = new File( - $this->source, - $this->context, - $filePath, - $module, - '', - $this->minificationMock, - $this->filesystem - ); - $this->assertEquals($expected, $object->getPath()); - } - - public function testGetPathWithMinification() - { - $expected = 'path/to/directory/Module/path/to/file.min.js'; - /** - * @var \Magento\Framework\View\Asset\Minification|\PHPUnit_Framework_MockObject_MockObject $minificationMock - */ - $minificationMock = $this->getMockBuilder('Magento\Framework\View\Asset\Minification') - ->disableOriginalConstructor() - ->getMock(); - $minificationMock->expects($this->once()) - ->method('addMinifiedSign') - ->with('path/to/directory/Module/path/to/file') - ->willReturn($expected); - $directoryRead = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\ReadInterface') - ->disableOriginalConstructor() - ->getMock(); - $this->context->expects($this->atLeastOnce()) - ->method('getPath') - ->willReturn('/path/to/directory'); - $this->filesystem->expects($this->once()) - ->method('getDirectoryRead') - ->with(DirectoryList::STATIC_VIEW) - ->willReturn($directoryRead); - $directoryRead->expects($this->once()) - ->method('isExist') - ->with($expected) - ->willReturn(true); - $object = new File( - $this->source, - $this->context, - 'path/to/file', - 'Module', - '', - $minificationMock, - $this->filesystem - ); + $this->context->expects($this->once())->method('getPath')->will($this->returnValue($contextPath)); + $object = new File($this->source, $this->context, $filePath, $module, '', $this->minificationMock); $this->assertEquals($expected, $object->getPath()); }