Skip to content

Commit

Permalink
Merge remote-tracking branch 'main-ce/develop' into MAGETWO-57876
Browse files Browse the repository at this point in the history
  • Loading branch information
magicbunneh committed Sep 2, 2016
2 parents d519423 + 8536677 commit 26b0658
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 68 deletions.
8 changes: 1 addition & 7 deletions app/code/Magento/Backend/Block/Store/Switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

/**
* Store switcher block
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Switcher extends \Magento\Backend\Block\Template
{
Expand Down Expand Up @@ -152,11 +150,7 @@ public function getWebsites()
{
$websites = $this->_storeManager->getWebsites();
if ($websiteIds = $this->getWebsiteIds()) {
foreach (array_keys($websites) as $websiteId) {
if (!in_array($websiteId, $websiteIds)) {
unset($websites[$websiteId]);
}
}
$websites = array_intersect_key($websites, array_flip($websiteIds));
}
return $websites;
}
Expand Down
53 changes: 53 additions & 0 deletions app/code/Magento/Backend/Test/Unit/Block/Store/SwitcherTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Backend\Test\Unit\Block\Store;

class SwitcherTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Magento\Backend\Block\Store\Switcher
*/
private $switcherBlock;

private $storeManagerMock;

protected function setUp()
{
$this->storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManagerInterface::class);
$objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$context = $objectHelper->getObject(
\Magento\Backend\Block\Template\Context::class,
[
'storeManager' => $this->storeManagerMock,
]
);

$this->switcherBlock = $objectHelper->getObject(
\Magento\Backend\Block\Store\Switcher::class,
['context' => $context]
);
}

public function testGetWebsites()
{
$websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false);
$websites = [0 => $websiteMock, 1 => $websiteMock];
$this->storeManagerMock->expects($this->once())->method('getWebsites')->will($this->returnValue($websites));
$this->assertEquals($websites, $this->switcherBlock->getWebsites());
}

public function testGetWebsitesIfSetWebsiteIds()
{
$websiteMock = $this->getMock(\Magento\Store\Model\Website::class, [], [], '', false);
$websites = [0 => $websiteMock, 1 => $websiteMock];
$this->storeManagerMock->expects($this->once())->method('getWebsites')->will($this->returnValue($websites));

$this->switcherBlock->setWebsiteIds([1]);
$expected = [1 => $websiteMock];
$this->assertEquals($expected, $this->switcherBlock->getWebsites());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ class Content extends \Magento\Backend\Block\Widget
*/
private $imageHelper;

/**
* @var \Magento\Framework\View\Asset\Repository
*/
private $assetRepo;

/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
Expand Down Expand Up @@ -147,13 +142,8 @@ public function getImagesJson()
$fileHandler = $mediaDir->stat($this->_mediaConfig->getMediaPath($image['file']));
$image['size'] = $fileHandler['size'];
} catch (FileSystemException $e) {
$staticDir = $this->_filesystem->getDirectoryRead(DirectoryList::STATIC_VIEW);
$image['url'] = $this->getImageHelper()->getDefaultPlaceholderUrl('thumbnail');
$fileHandler = $staticDir->stat(
$this->getAssetRepo()
->createAsset($this->getImageHelper()->getPlaceholder('thumbnail'))->getPath()
);
$image['size'] = $fileHandler['size'];
$image['url'] = $this->getImageHelper()->getDefaultPlaceholderUrl('small_image');
$image['size'] = 0;
$this->_logger->warning($e);
}
}
Expand Down Expand Up @@ -262,18 +252,4 @@ private function getImageHelper()
}
return $this->imageHelper;
}

/**
* @return \Magento\Framework\View\Asset\Repository
* @deprecated
*/
private function getAssetRepo()
{
if ($this->assetRepo === null) {
$this->assetRepo = \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\View\Asset\Repository::class);
}

return $this->assetRepo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ class ContentTest extends \PHPUnit_Framework_TestCase
*/
protected $imageHelper;

/**
* @var \Magento\Framework\View\Asset\Repository|\PHPUnit_Framework_MockObject_MockObject
*/
protected $assetRepo;

/**
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
*/
Expand Down Expand Up @@ -171,12 +166,7 @@ public function testGetImagesJsonWithException()
{
$this->imageHelper = $this->getMockBuilder(\Magento\Catalog\Helper\Image::class)
->disableOriginalConstructor()
->setMethods(['getDefaultPlaceholderUrl', 'getPlaceholder'])
->getMock();

$this->assetRepo = $this->getMockBuilder(\Magento\Framework\View\Asset\Repository::class)
->disableOriginalConstructor()
->setMethods(['createAsset', 'getPath'])
->setMethods(['getDefaultPlaceholderUrl'])
->getMock();

$this->objectManager->setBackwardCompatibleProperty(
Expand All @@ -185,32 +175,24 @@ public function testGetImagesJsonWithException()
$this->imageHelper
);

$this->objectManager->setBackwardCompatibleProperty(
$this->content,
'assetRepo',
$this->assetRepo
);

$placeholderUrl = 'url_to_the_placeholder/placeholder.jpg';

$sizePlaceholder = ['size' => 399659];

$imagesResult = [
[
'value_id' => '2',
'file' => 'file_2.jpg',
'media_type' => 'image',
'position' => '0',
'url' => 'url_to_the_placeholder/placeholder.jpg',
'size' => 399659
'size' => 0
],
[
'value_id' => '1',
'file' => 'file_1.jpg',
'media_type' => 'image',
'position' => '1',
'url' => 'url_to_the_placeholder/placeholder.jpg',
'size' => 399659
'size' => 0
]
];

Expand Down Expand Up @@ -238,18 +220,13 @@ public function testGetImagesJsonWithException()
$this->mediaConfigMock->expects($this->any())->method('getMediaPath');
$this->readMock->expects($this->any())->method('stat')->willReturnOnConsecutiveCalls(
$this->throwException(
new \Magento\Framework\Exception\FileSystemException(new \Magento\Framework\Phrase('test'))
new \Magento\Framework\Exception\FileSystemException(new Phrase('test'))
),
$sizePlaceholder,
$this->throwException(
new \Magento\Framework\Exception\FileSystemException(new \Magento\Framework\Phrase('test'))
),
$sizePlaceholder
new \Magento\Framework\Exception\FileSystemException(new Phrase('test'))
)
);
$this->imageHelper->expects($this->any())->method('getDefaultPlaceholderUrl')->willReturn($placeholderUrl);
$this->imageHelper->expects($this->any())->method('getPlaceholder');
$this->assetRepo->expects($this->any())->method('createAsset')->willReturnSelf();
$this->assetRepo->expects($this->any())->method('getPath');
$this->jsonEncoderMock->expects($this->once())->method('encode')->willReturnCallback('json_encode');

$this->assertSame(json_encode($imagesResult), $this->content->getImagesJson());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
'jquery',
'priceBox'
], function($){
var priceBoxes = $('[data-role=priceBox]');
var dataPriceBoxSelector = '[data-role=priceBox]',
dataProductIdSelector = '[data-product-id=<?php echo $block->escapeHtml($_product->getId())?>]',
priceBoxes = $(dataPriceBoxSelector + dataProductIdSelector);

priceBoxes = priceBoxes.filter(function(index, elem){
return !$(elem).find('.price-from').length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
?>

<?php $_options = $block->decorateArray($block->getOptions()) ?>
<?php $_productId = $block->getProduct()->getId() ?>
<?php if (count($_options)):?>
<script type="text/x-magento-init">
{
"#product_addtocart_form": {
"priceOptions": {
"optionConfig": <?php /* @escapeNotVerified */ echo $block->getJsonConfig()?>,
"controlContainer": ".field",
"priceHolderSelector": "[data-role=priceBox]"
"priceHolderSelector": "[data-product-id='<?php echo $block->escapeHtml($_productId)?>'][data-role=priceBox]"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
<span><?php /* @escapeNotVerified */ echo __('View Order') ?></span>
</a>
<?php if ($this->helper('Magento\Sales\Helper\Reorder')->canReorder($_order->getEntityId())) : ?>
<a href="<?php /* @escapeNotVerified */ echo $block->getReorderUrl($_order) ?>" class="action order">
<a href="#" data-post='<?php /* @escapeNotVerified */ echo
$this->helper(\Magento\Framework\Data\Helper\PostHelper::class)
->getPostData($block->getReorderUrl($_order))
?>' class="action order">
<span><?php /* @escapeNotVerified */ echo __('Reorder') ?></span>
</a>
<?php endif ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
<div class="actions">
<?php $_order = $block->getOrder() ?>
<?php if ($this->helper('Magento\Sales\Helper\Reorder')->canReorder($_order->getEntityId())) : ?>
<a class="action reorder" href="<?php /* @escapeNotVerified */ echo $block->getReorderUrl($_order) ?>">
<a href="#" data-post='<?php /* @escapeNotVerified */ echo
$this->helper(\Magento\Framework\Data\Helper\PostHelper::class)
->getPostData($block->getReorderUrl($_order))
?>' class="action order">
<span><?php /* @escapeNotVerified */ echo __('Reorder') ?></span>
</a>
<?php endif ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
<span><?php /* @escapeNotVerified */ echo __('View Order') ?></span>
</a>
<?php if ($this->helper('Magento\Sales\Helper\Reorder')->canReorder($_order->getEntityId())) : ?>
<a href="<?php /* @escapeNotVerified */ echo $block->getReorderUrl($_order) ?>" class="action order">
<a href="#" data-post='<?php /* @escapeNotVerified */ echo
$this->helper(\Magento\Framework\Data\Helper\PostHelper::class)
->getPostData($block->getReorderUrl($_order))
?>' class="action order">
<span><?php /* @escapeNotVerified */ echo __('Reorder') ?></span>
</a>
<?php endif ?>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Magento_Swatches::css/swatches.css"/>
</head>
<body>
<referenceBlock name="category.product.type.details.renderers">
<block class="Magento\Swatches\Block\Product\Renderer\Listing\Configurable" as="configurable" template="Magento_Swatches::product/listing/renderer.phtml" />
</referenceBlock>
</body>
</page>
1 change: 1 addition & 0 deletions lib/web/tiny_mce/plugins/advimage/js/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ var ImageDialog = {
tinyMCEPopup.editor.execCommand('mceRepaint');
tinyMCEPopup.editor.focus();
tinyMCEPopup.close();
ed.onChange.dispatch(ed);
},

getAttrib : function(e, at) {
Expand Down
2 changes: 1 addition & 1 deletion setup/performance-toolkit/benchmark.jmx
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ if (1 == Integer.parseInt(vars.get("category_name_counter"))) {
} else {
categoryNamesList = props.get("category_names_list");
}
log.info("category name: " + vars.get("category_name"));

categoryNamesList.add(vars.get("category_name"));</stringProp>
<stringProp name="BeanShellSampler.filename"/>
<stringProp name="BeanShellSampler.parameters"/>
Expand Down

0 comments on commit 26b0658

Please sign in to comment.