Skip to content

Commit

Permalink
Merge pull request #97 from magento-nord/MAGETWO-53170
Browse files Browse the repository at this point in the history
[NORD] Bug fixes
  • Loading branch information
kandy authored Jun 11, 2016
2 parents 6a38dd7 + 015a299 commit 1ea57c2
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 1 deletion.
12 changes: 12 additions & 0 deletions app/code/Magento/CatalogUrlRewrite/etc/adminhtml/events.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="catalog_product_to_website_change">
<observer name="catalog_product_to_website_change" instance="Magento\CatalogUrlRewrite\Observer\ProductToWebsiteChangeObserver"/>
</event>
</config>
2 changes: 2 additions & 0 deletions app/code/Magento/Checkout/CustomerData/DefaultItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ protected function doGetItemData()
'configure_url' => $this->getConfigureUrl(),
'is_visible_in_site_visibility' => $this->item->getProduct()->isVisibleInSiteVisibility(),
'product_name' => $this->item->getProduct()->getName(),
'product_sku' => $this->item->getProduct()->getSku(),
'product_url' => $this->getProductUrl(),
'product_has_url' => $this->hasProductUrl(),
'product_price' => $this->checkoutHelper->formatPrice($this->item->getCalculationPrice()),
'product_price_value' => $this->item->getCalculationPrice(),
'product_image' => [
'src' => $imageHelper->getUrl(),
'alt' => $imageHelper->getLabel(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Checkout\Test\Unit\CustomerData;

class DefaultItemTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Magento\Checkout\CustomerData\DefaultItem
*/
protected $model;

/**
* @var \Magento\Catalog\Helper\Image
*/
private $imageHelper;

/**
* @var \Magento\Catalog\Helper\Product\ConfigurationPool
*/
private $configurationPool;

protected function setUp()
{
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->imageHelper = $this->getMockBuilder(\Magento\Catalog\Helper\Image::class)
->disableOriginalConstructor()
->getMock();
$this->configurationPool = $this->getMockBuilder(\Magento\Catalog\Helper\Product\ConfigurationPool::class)
->setMethods([])
->disableOriginalConstructor()
->getMock();
$checkoutHelper = $this->getMockBuilder(\Magento\Checkout\Helper\Data::class)
->setMethods(['formatPrice'])->disableOriginalConstructor()->getMock();
$checkoutHelper->expects($this->any())->method('formatPrice')->willReturn(5);
$this->model = $objectManager->getObject(
\Magento\Checkout\CustomerData\DefaultItem::class,
[
'imageHelper' => $this->imageHelper,
'configurationPool' => $this->configurationPool,
'checkoutHelper' => $checkoutHelper
]
);
}

public function testGetItemData()
{
$urlModel = $this->getMockBuilder(\Magento\Catalog\Model\Product\Url::class)
->disableOriginalConstructor()
->getMock();
$product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
->setMethods(['getUrlModel', 'isVisibleInSiteVisibility', 'getSku'])
->disableOriginalConstructor()
->getMock();
$product->expects($this->any())->method('getUrlModel')->willReturn($urlModel);
$product->expects($this->any())->method('isVisibleInSiteVisibility')->willReturn(true);
$product->expects($this->any())->method('getSku')->willReturn('simple');
/** @var \Magento\Quote\Model\Quote\Item $item */
$item = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item::class)
->setMethods(['getProductType', 'getProduct', 'getCalculationPrice'])
->disableOriginalConstructor()
->getMock();
$item->expects($this->any())->method('getProduct')->willReturn($product);
$item->expects($this->any())->method('getProductType')->willReturn('simple');
$item->expects($this->any())->method('getCalculationPrice')->willReturn(5);

$this->imageHelper->expects($this->any())->method('init')->with($product)->willReturnSelf();
$this->imageHelper->expects($this->any())->method('getUrl')->willReturn('url');
$this->imageHelper->expects($this->any())->method('getLabel')->willReturn('label');
$this->imageHelper->expects($this->any())->method('getWidth')->willReturn(100);
$this->imageHelper->expects($this->any())->method('getHeight')->willReturn(100);
$this->configurationPool->expects($this->any())->method('getByProductType')->willReturn($product);

$itemData = $this->model->getItemData($item);
$this->assertArrayHasKey('options', $itemData);
$this->assertArrayHasKey('qty', $itemData);
$this->assertArrayHasKey('item_id', $itemData);
$this->assertArrayHasKey('configure_url', $itemData);
$this->assertArrayHasKey('is_visible_in_site_visibility', $itemData);
$this->assertArrayHasKey('product_type', $itemData);
$this->assertArrayHasKey('product_name', $itemData);
$this->assertArrayHasKey('product_sku', $itemData);
$this->assertArrayHasKey('product_url', $itemData);
$this->assertArrayHasKey('product_has_url', $itemData);
$this->assertArrayHasKey('product_price', $itemData);
$this->assertArrayHasKey('product_price_value', $itemData);
$this->assertArrayHasKey('product_image', $itemData);
$this->assertArrayHasKey('canApplyMsrp', $itemData);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
<input data-bind="attr: {
id: 'cart-item-'+item_id+'-qty',
'data-cart-item': item_id,
'data-item-qty': qty
'data-item-qty': qty,
'data-cart-item-id': product_sku
}, value: qty"
type="number"
size="4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ class View extends AbstractConfigureBlock
*/
protected $baseImage = '[data-gallery-role="gallery"] img.fotorama__img.fotorama__img';

/**
* @var string
*/
protected $galleryLoader = '.fotorama__spinner--show';

/**
* Video Container selector
*
Expand Down Expand Up @@ -499,6 +504,7 @@ public function waitLoader()
*/
public function isGalleryVisible()
{
$this->waitForElementNotVisible($this->galleryLoader);
return $this->_rootElement->find($this->mediaGallery)->isVisible();
}

Expand All @@ -509,6 +515,7 @@ public function isGalleryVisible()
*/
public function isFullImageVisible()
{
$this->waitForElementNotVisible($this->galleryLoader);
return $this->browser->find($this->fullImage)->isVisible();
}

Expand Down

0 comments on commit 1ea57c2

Please sign in to comment.