From a3a12064d234e951fe735d6d585c457b3ad39b05 Mon Sep 17 00:00:00 2001 From: Ievgen Kolesov <ikolesov@magento.com> Date: Tue, 8 Nov 2016 17:53:09 +0200 Subject: [PATCH] MAGETWO-59003: Js file version regenerated in browser on every page reload in develop mode --- .../App/View/Deployment/VersionTest.php | 1 - .../Deployment/Version/Storage/FileTest.php | 45 +++---------------- .../Test/Unit/View/Deployment/VersionTest.php | 4 +- .../Framework/App/View/Deployment/Version.php | 3 +- 4 files changed, 9 insertions(+), 44 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Framework/App/View/Deployment/VersionTest.php b/dev/tests/integration/testsuite/Magento/Framework/App/View/Deployment/VersionTest.php index 351c509fe27..5a313c318f9 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/App/View/Deployment/VersionTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/App/View/Deployment/VersionTest.php @@ -84,7 +84,6 @@ class VersionTest extends \PHPUnit_Framework_TestCase $this->getVersionModel(State::MODE_PRODUCTION)->getValue(); } - public function testGetValueInDeveloperMode() { $this->assertFalse($this->directoryWrite->isExist($this->fileName)); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/Version/Storage/FileTest.php b/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/Version/Storage/FileTest.php index 3981511ad47..e7206bf5566 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/Version/Storage/FileTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/Version/Storage/FileTest.php @@ -34,48 +34,15 @@ class FileTest extends \PHPUnit_Framework_TestCase public function testLoad() { - $this->directory - ->expects($this->once()) - ->method('readFile') + $this->directory->expects($this->once()) + ->method('isReadable') ->with('fixture_file.txt') - ->will($this->returnValue('123')); - $this->assertEquals('123', $this->object->load()); - } - - /** - * @expectedException \Exception - * @expectedExceptionMessage Exception to be propagated - */ - public function testLoadExceptionPropagation() - { - $this->directory - ->expects($this->once()) + ->willReturn(true); + $this->directory->expects($this->once()) ->method('readFile') ->with('fixture_file.txt') - ->will($this->throwException(new \Exception('Exception to be propagated'))); - $this->object->load(); - } - - /** - * @expectedException \UnexpectedValueException - * @expectedExceptionMessage Unable to retrieve deployment version of static files from the file system - */ - public function testLoadExceptionWrapping() - { - $filesystemException = new \Magento\Framework\Exception\FileSystemException( - new \Magento\Framework\Phrase('File does not exist') - ); - $this->directory - ->expects($this->once()) - ->method('readFile') - ->with('fixture_file.txt') - ->will($this->throwException($filesystemException)); - try { - $this->object->load(); - } catch (\Exception $e) { - $this->assertSame($filesystemException, $e->getPrevious(), 'Wrapping of original exception is expected'); - throw $e; - } + ->willReturn('123'); + $this->assertEquals('123', $this->object->load()); } public function testSave() diff --git a/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/VersionTest.php b/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/VersionTest.php index 6f2fec55922..8d804102f7a 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/VersionTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/View/Deployment/VersionTest.php @@ -6,7 +6,6 @@ namespace Magento\Framework\App\Test\Unit\View\Deployment; use Magento\Framework\App\View\Deployment\Version; -use Magento\Framework\Exception\FileSystemException; /** * Class VersionTest @@ -70,7 +69,8 @@ class VersionTest extends \PHPUnit_Framework_TestCase ]; } - public function testGetValueInNonProductionMode() { + public function testGetValueInNonProductionMode() + { $version = 123123123123; $this->versionStorageMock->expects($this->once()) ->method('load') diff --git a/lib/internal/Magento/Framework/App/View/Deployment/Version.php b/lib/internal/Magento/Framework/App/View/Deployment/Version.php index 64f7ed1d5e1..73d4a0c926c 100644 --- a/lib/internal/Magento/Framework/App/View/Deployment/Version.php +++ b/lib/internal/Magento/Framework/App/View/Deployment/Version.php @@ -7,7 +7,6 @@ namespace Magento\Framework\App\View\Deployment; use Psr\Log\LoggerInterface; -use Magento\Framework\Exception\FileSystemException; /** * Deployment version of static files @@ -72,7 +71,7 @@ class Version if ($appMode == \Magento\Framework\App\State::MODE_PRODUCTION) { $this->getLogger()->critical('Can not load static content version.'); throw new \UnexpectedValueException( - __('Unable to retrieve deployment version of static files from the file system.') + "Unable to retrieve deployment version of static files from the file system." ); } $result = $this->generateVersion(); -- GitLab