Skip to content

Commit

Permalink
Merge pull request magento#478 from magento-performance/pr-develop
Browse files Browse the repository at this point in the history
Both issues does not have linked tests in jira. Could you please clarify why these fixes do not require testing?
  • Loading branch information
Oleksii Korshenko authored Oct 10, 2016
2 parents 492f0ca + 8dbc880 commit c533b3d
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Deploy\Console\Command;

use Magento\Framework\App\Utility\Files;
Expand All @@ -19,6 +18,8 @@
use Magento\Framework\App\State;
use Magento\Deploy\Console\Command\DeployStaticOptionsInterface as Options;
use Magento\Deploy\Model\DeployManager;
use Magento\Framework\App\Cache;
use Magento\Framework\App\Cache\Type\Dummy as DummyCache;

/**
* Deploy static content command
Expand All @@ -29,7 +30,7 @@ class DeployStaticContentCommand extends Command
/**
* Key for dry-run option
* @deprecated
* @see Magento\Deploy\Console\Command\DeployStaticOptionsInterface::DRY_RUN
* @see \Magento\Deploy\Console\Command\DeployStaticOptionsInterface::DRY_RUN
*/
const DRY_RUN_OPTION = 'dry-run';

Expand Down Expand Up @@ -87,6 +88,7 @@ class DeployStaticContentCommand extends Command
* @param ObjectManagerFactory $objectManagerFactory
* @param Locale $validator
* @param ObjectManagerInterface $objectManager
* @throws \LogicException When the command name is empty
*/
public function __construct(
ObjectManagerFactory $objectManagerFactory,
Expand All @@ -96,6 +98,7 @@ public function __construct(
$this->objectManagerFactory = $objectManagerFactory;
$this->validator = $validator;
$this->objectManager = $objectManager;

parent::__construct();
}

Expand Down Expand Up @@ -373,6 +376,7 @@ private function getDeployableEntities($entities, $includedEntities, $excludedEn
/**
* {@inheritdoc}
* @throws \InvalidArgumentException
* @throws LocalizedException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Expand All @@ -394,9 +398,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
list ($deployableLanguages, $deployableAreaThemeMap, $requestedThemes)
= $this->prepareDeployableEntities($filesUtil);

$output->writeln("Requested languages: " . implode(', ', $deployableLanguages));
$output->writeln("Requested areas: " . implode(', ', array_keys($deployableAreaThemeMap)));
$output->writeln("Requested themes: " . implode(', ', $requestedThemes));
$output->writeln('Requested languages: ' . implode(', ', $deployableLanguages));
$output->writeln('Requested areas: ' . implode(', ', array_keys($deployableAreaThemeMap)));
$output->writeln('Requested themes: ' . implode(', ', $requestedThemes));

/** @var $deployManager DeployManager */
$deployManager = $this->objectManager->create(
Expand All @@ -415,11 +419,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}

$this->mockCache();
return $deployManager->deploy();
}

/**
* @param Files $filesUtil
* @throws \InvalidArgumentException
* @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
Expand Down Expand Up @@ -476,4 +482,18 @@ private function prepareDeployableEntities($filesUtil)

return [$deployableLanguages, $deployableAreaThemeMap, $requestedThemes];
}

/**
* Mock Cache class with dummy implementation
*
* @return void
*/
private function mockCache()
{
$this->objectManager->configure([
'preferences' => [
Cache::class => DummyCache::class
]
]);
}
}
67 changes: 67 additions & 0 deletions lib/internal/Magento/Framework/App/Cache/Type/Dummy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\App\Cache\Type;

use Magento\Framework\App\CacheInterface;

/**
* Dummy cache adapter
*
* for cases when need to disable interaction with cache
* but no specific cache type is used
*/
class Dummy implements CacheInterface
{
/**
* Required by CacheInterface
*
* @return null
*/
public function getFrontend()
{
return null;
}

/**
* Pretend to load data from cache by id
*
* {@inheritdoc}
*/
public function load($identifier)
{
return null;
}

/**
* Pretend to save data
*
* {@inheritdoc}
*/
public function save($data, $identifier, $tags = [], $lifeTime = null)
{
return false;
}

/**
* Pretend to remove cached data by identifier
*
* {@inheritdoc}
*/
public function remove($identifier)
{
return true;
}

/**
* Pretend to clean cached data by specific tag
*
* {@inheritdoc}
*/
public function clean($tags = [])
{
return true;
}
}
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/View/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getViewConfig(array $params = [])
if (isset($params['themeModel'])) {
/** @var \Magento\Framework\View\Design\ThemeInterface $currentTheme */
$currentTheme = $params['themeModel'];
$key = $currentTheme->getCode();
$key = $currentTheme->getFullPath();
if (isset($this->viewConfigs[$key])) {
return $this->viewConfigs[$key];
}
Expand Down
6 changes: 3 additions & 3 deletions lib/internal/Magento/Framework/View/Test/Unit/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ protected function setUp()

public function testGetViewConfig()
{
$themeCode = 2;
$themeCode = 'area/theme';

$themeMock = $this->getMock(
\Magento\Theme\Model\Theme::class,
['getCode'],
['getFullPath'],
[],
'',
false
);
$themeMock->expects($this->atLeastOnce())
->method('getCode')
->method('getFullPath')
->will($this->returnValue($themeCode));
$params = [
'themeModel' => $themeMock,
Expand Down

0 comments on commit c533b3d

Please sign in to comment.