Skip to content

Commit

Permalink
Merge pull request #108 from magento-mpi/develop
Browse files Browse the repository at this point in the history
[MPI] Sprint 58 contribution
  • Loading branch information
dkvashninbay committed Feb 26, 2015
2 parents d1a0d51 + bc47efb commit 116d26d
Show file tree
Hide file tree
Showing 60 changed files with 1,939 additions and 353 deletions.

This file was deleted.

This file was deleted.

25 changes: 25 additions & 0 deletions app/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@
<argument name="mode" xsi:type="init_parameter">Magento\Framework\App\State::PARAM_MODE</argument>
</arguments>
</type>
<type name="Magento\Framework\View\Asset\Source">
<arguments>
<argument name="appMode" xsi:type="init_parameter">Magento\Framework\App\State::PARAM_MODE</argument>
</arguments>
</type>
<type name="Magento\Framework\View\Page\Config\Renderer">
<arguments>
<argument name="appMode" xsi:type="init_parameter">Magento\Framework\App\State::PARAM_MODE</argument>
</arguments>
</type>
<type name="Magento\Framework\App\Arguments\ValidationState">
<arguments>
<argument name="appMode" xsi:type="init_parameter">Magento\Framework\App\State::PARAM_MODE</argument>
Expand Down Expand Up @@ -535,11 +545,26 @@
<argument name="stateCollection" xsi:type="object" shared="false">Magento\Framework\Mview\View\State\CollectionInterface</argument>
</arguments>
</type>
<type name="Magento\Framework\App\View\Asset\Publisher" shared="false" />
<type name="Magento\Framework\App\StaticResource">
<arguments>
<argument name="response" xsi:type="object" shared="false">Magento\Core\Model\File\Storage\Response</argument>
<argument name="publisher" xsi:type="object">developerPublisher</argument>
</arguments>
</type>
<virtualType name="developerPublisher" type="Magento\Framework\App\View\Asset\Publisher">
<arguments>
<argument name="materializationStrategyFactory" xsi:type="object">developerMaterialization</argument>
</arguments>
</virtualType>
<virtualType name="developerMaterialization" type="Magento\Framework\App\View\Asset\MaterializationStrategy\Factory">
<arguments>
<argument name="strategiesList" xsi:type="array">
<item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>
<item name="default" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Copy</item>
</argument>
</arguments>
</virtualType>
<virtualType name="fallbackResolverSimpleWithGroupedCache" type="Magento\Framework\View\Design\FileResolution\Fallback\Resolver\Simple">
<arguments>
<argument name="cache" xsi:type="object">Magento\Framework\View\Design\FileResolution\Fallback\CacheData\Grouped</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,32 @@ function ($className) {
)
);

$sharedInstances = [
'Magento\Framework\App\Cache\Type\Config' => $cache,
'Magento\Framework\App\ObjectManager\ConfigLoader' => $configLoader,
'Magento\Framework\App\ObjectManager\ConfigCache' => $configCache,
'Magento\Framework\Config\ReaderInterface' => $this->getMock(
'Magento\Framework\Config\ReaderInterface'
),
'Magento\Framework\Config\ScopeInterface' => $this->getMock('Magento\Framework\Config\ScopeInterface'),
'Magento\Framework\Config\CacheInterface' => $this->getMock('Magento\Framework\Config\CacheInterface'),
'Magento\Framework\Cache\FrontendInterface' =>
$this->getMock('Magento\Framework\Cache\FrontendInterface'),
'Magento\Framework\App\Resource' => $this->getMockBuilder('Magento\Framework\App\Resource')
->disableOriginalConstructor()
->getMock(),
'Magento\Framework\App\Resource\Config' => $this->getMock(
'Magento\Framework\App\Resource\Config',
[],
[],
'',
false
)
];
$model = new \Magento\TestFramework\ObjectManager(
$factory,
$configMock,
[
'Magento\Framework\App\Cache\Type\Config' => $cache,
'Magento\Framework\App\ObjectManager\ConfigLoader' => $configLoader,
'Magento\Framework\App\ObjectManager\ConfigCache' => $configCache,
'Magento\Framework\Config\ReaderInterface' => $this->getMock(
'Magento\Framework\Config\ReaderInterface'
),
'Magento\Framework\Config\ScopeInterface' => $this->getMock('Magento\Framework\Config\ScopeInterface'),
'Magento\Framework\Config\CacheInterface' => $this->getMock('Magento\Framework\Config\CacheInterface'),
'Magento\Framework\Cache\FrontendInterface' =>
$this->getMock('Magento\Framework\Cache\FrontendInterface'),
'Magento\Framework\App\Resource' => $this->getMockBuilder('Magento\Framework\App\Resource')
->disableOriginalConstructor()
->getMock(),
'Magento\Framework\App\Resource\Config' => $this->getMock(
'Magento\Framework\App\Resource\Config',
[],
[],
'',
false
)
],
$sharedInstances,
$primaryLoaderMock
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,20 @@ public function setUpInterceptionConfig($pluginConfig)
$definitions
);
$interceptionDefinitions = new Definition\Runtime();
$sharedInstances = [
'Magento\Framework\Config\CacheInterface' => $cache,
'Magento\Framework\Config\ScopeInterface' => $configScope,
'Magento\Framework\Config\ReaderInterface' => $this->_configReader,
'Magento\Framework\ObjectManager\RelationsInterface' => $relations,
'Magento\Framework\ObjectManager\ConfigInterface' => $config,
'Magento\Framework\Interception\ObjectManager\ConfigInterface' => $config,
'Magento\Framework\ObjectManager\DefinitionInterface' => $definitions,
'Magento\Framework\Interception\DefinitionInterface' => $interceptionDefinitions
];
$this->_objectManager = new \Magento\Framework\ObjectManager\ObjectManager(
$factory,
$config,
[
'Magento\Framework\Config\CacheInterface' => $cache,
'Magento\Framework\Config\ScopeInterface' => $configScope,
'Magento\Framework\Config\ReaderInterface' => $this->_configReader,
'Magento\Framework\ObjectManager\RelationsInterface' => $relations,
'Magento\Framework\ObjectManager\ConfigInterface' => $config,
'Magento\Framework\Interception\ObjectManager\ConfigInterface' => $config,
'Magento\Framework\ObjectManager\DefinitionInterface' => $definitions,
'Magento\Framework\Interception\DefinitionInterface' => $interceptionDefinitions
]
$sharedInstances
);
$factory->setObjectManager($this->_objectManager);
$config->setInterceptionConfig($interceptionConfig);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Framework\App\View\Asset\MaterializationStrategy;

class CopyTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Copy
*/
private $copyPublisher;

public function setUp()
{
$this->copyPublisher = new Copy;
}

public function testPublishFile()
{
$rootDir = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\WriteInterface')
->getMock();
$targetDir = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\WriteInterface')
->getMock();
$sourcePath = 'source/path/file';
$destinationPath = 'destination/path/file';

$rootDir->expects($this->once())
->method('copyFile')
->with(
$sourcePath,
$destinationPath,
$targetDir
)->willReturn(true);

$this->assertTrue($this->copyPublisher->publishFile($rootDir, $targetDir, $sourcePath, $destinationPath));
}

public function testIsSupported()
{
$asset = $this->getMockBuilder('Magento\Framework\View\Asset\LocalInterface')
->getMock();
$this->assertTrue($this->copyPublisher->isSupported($asset));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Framework\App\View\Asset\MaterializationStrategy;

use Magento\Framework\ObjectManagerInterface;

class FactoryTest extends \PHPUnit_Framework_TestCase
{
/**
* @var ObjectManagerInterface | \PHPUnit_Framework_MockObject_MockObject
*/
private $objectManager;

public function setUp()
{
$this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface')
->setMethods([])
->getMock();
}

public function testCreateEmptyStrategies()
{
$asset = $this->getAsset();
$copyStrategy = $this->getMockBuilder('Magento\Framework\App\View\Asset\MaterializationStrategy\Copy')
->setMethods([])
->getMock();
$copyStrategy->expects($this->once())
->method('isSupported')
->with($asset)
->willReturn(true);

$this->objectManager->expects($this->once())
->method('get')
->with(Factory::DEFAULT_STRATEGY)
->willReturn($copyStrategy);

$factory = new Factory($this->objectManager, []);
$this->assertSame($copyStrategy, $factory->create($asset));
}

public function testCreateSupported()
{
$asset = $this->getAsset();
$copyStrategy = $this->getMockBuilder('Magento\Framework\App\View\Asset\MaterializationStrategy\Copy')
->setMethods([])
->getMock();
$copyStrategy->expects($this->once())
->method('isSupported')
->with($asset)
->willReturn(false);

$supportedStrategy = $this->getMockBuilder(
'Magento\Framework\App\View\Asset\MaterializationStrategy\StrategyInterface'
)
->setMethods([])
->getMock();
$supportedStrategy->expects($this->once())
->method('isSupported')
->with($asset)
->willReturn(true);

$factory = new Factory($this->objectManager, [$copyStrategy, $supportedStrategy]);
$this->assertSame($supportedStrategy, $factory->create($asset));
}

public function testCreateException()
{
$asset = $this->getAsset();
$copyStrategy = $this->getMockBuilder('Magento\Framework\App\View\Asset\MaterializationStrategy\Copy')
->setMethods([])
->getMock();
$copyStrategy->expects($this->once())
->method('isSupported')
->with($asset)
->willReturn(false);

$this->objectManager->expects($this->once())
->method('get')
->with(Factory::DEFAULT_STRATEGY)
->willReturn($copyStrategy);

$factory = new Factory($this->objectManager, []);

$this->setExpectedException('LogicException', 'No materialization strategy is supported');
$factory->create($asset);
}

/**
* @return \Magento\Framework\View\Asset\LocalInterface | \PHPUnit_Framework_MockObject_MockObject
*/
private function getAsset()
{
return $this->getMockBuilder('Magento\Framework\View\Asset\LocalInterface')
->setMethods([])
->getMock();
}
}
Loading

0 comments on commit 116d26d

Please sign in to comment.