Skip to content

Commit

Permalink
Merge pull request #1104 from magento-engcom/2.1-develop-prs
Browse files Browse the repository at this point in the history
Public Pull Requests: 
 - #9571
 - #9524
 - #9590
  • Loading branch information
Oleksii Korshenko authored May 15, 2017
2 parents 8a84178 + f7f6c1f commit c605e5d
Show file tree
Hide file tree
Showing 14 changed files with 163 additions and 32 deletions.
3 changes: 3 additions & 0 deletions app/code/Magento/Config/Model/Config/Backend/Email/Logo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
*/
namespace Magento\Config\Model\Config\Backend\Email;

/**
* @deprecated
*/
class Logo extends \Magento\Config\Model\Config\Backend\Image
{
/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Email/Model/AbstractTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ protected function getLogoUrl($store)
$store
);
if ($fileName) {
$uploadDir = \Magento\Config\Model\Config\Backend\Email\Logo::UPLOAD_DIR;
$uploadDir = \Magento\Email\Model\Design\Backend\Logo::UPLOAD_DIR;
$mediaDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA);
if ($mediaDirectory->isFile($uploadDir . '/' . $fileName)) {
return $this->storeManager->getStore()->getBaseUrl(
Expand Down
33 changes: 33 additions & 0 deletions app/code/Magento/Email/Model/Design/Backend/Logo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Email\Model\Design\Backend;

use Magento\Theme\Model\Design\Backend\Logo as DesignLogo;

class Logo extends DesignLogo
{
/**
* The tail part of directory path for uploading
*/
const UPLOAD_DIR = 'email/logo';

/**
* Upload max file size in kilobytes
*
* @var int
*/
protected $maxFileSize = 2048;

/**
* Getter for allowed extensions of uploaded files
*
* @return string[]
*/
public function getAllowedExtensions()
{
return ['jpg', 'jpeg', 'gif', 'png'];
}
}
1 change: 1 addition & 0 deletions app/code/Magento/Email/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "N/A",
"require": {
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"magento/module-theme": "100.1.*",
"magento/module-config": "100.1.*",
"magento/module-store": "100.1.*",
"magento/module-cms": "101.0.*",
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Email/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<item name="email_logo" xsi:type="array">
<item name="path" xsi:type="string">design/email/logo</item>
<item name="fieldset" xsi:type="string">other_settings/email</item>
<item name="backend_model" xsi:type="string">Magento\Theme\Model\Design\Backend\Logo</item>
<item name="backend_model" xsi:type="string">Magento\Email\Model\Design\Backend\Logo</item>
<item name="base_url" xsi:type="array">
<item name="type" xsi:type="string">media</item>
<item name="scope_info" xsi:type="string">1</item>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Theme/Model/Design/Backend/Logo.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Logo extends Image
*/
protected function _getUploadDir()
{
return $this->_mediaDirectory->getRelativePath($this->_appendScopeInfo(self::UPLOAD_DIR));
return $this->_mediaDirectory->getRelativePath($this->_appendScopeInfo(static::UPLOAD_DIR));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@ class ConfigurableProduct extends FinalPrice implements ConfiguredPriceInterface
*/
public function getValue()
{
$result = 0.;
/** @var \Magento\Wishlist\Model\Item\Option $customOption */
$customOption = $this->getProduct()->getCustomOption('simple_product');
if ($customOption) {
/** @var \Magento\Framework\Pricing\PriceInfoInterface $priceInfo */
$priceInfo = $customOption->getProduct()->getPriceInfo();
$result = $priceInfo->getPrice(self::PRICE_CODE)->getValue();
}
return max(0, $result);
$product = $customOption ? $customOption->getProduct() : $this->getProduct();
$price = $product->getPriceInfo()->getPrice(self::PRICE_CODE)->getValue();

return max(0, $price);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,30 @@
*/
namespace Magento\Wishlist\Test\Unit\Pricing\ConfiguredPrice;

use Magento\Framework\Pricing\Adjustment\CalculatorInterface;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\Pricing\PriceInfoInterface;
use Magento\Framework\Pricing\SaleableInterface;
use Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct;

class ConfigurableProductTest extends \PHPUnit_Framework_TestCase
{
/**
* @var SaleableInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Pricing\SaleableInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $saleableItem;

/**
* @var CalculatorInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Pricing\Adjustment\CalculatorInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $calculator;

/**
* @var PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $priceCurrency;

/**
* @var ConfigurableProduct
* @var \Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct
*/
private $model;

/**
* @var PriceInfoInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Pricing\PriceInfoInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $priceInfoMock;

Expand All @@ -49,17 +43,14 @@ protected function setUp()
'getCustomOption',
])
->getMockForAbstractClass();
$this->saleableItem->expects($this->once())
->method('getPriceInfo')
->willReturn($this->priceInfoMock);

$this->calculator = $this->getMockBuilder('Magento\Framework\Pricing\Adjustment\CalculatorInterface')
->getMockForAbstractClass();

$this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')
->getMockForAbstractClass();

$this->model = new ConfigurableProduct(
$this->model = new \Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct(
$this->saleableItem,
null,
$this->calculator,
Expand All @@ -82,7 +73,7 @@ public function testGetValue()
->getMock();
$this->priceInfoMock->expects($this->once())
->method('getPrice')
->with(ConfigurableProduct::PRICE_CODE)
->with(\Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct::PRICE_CODE)
->willReturn($priceMock);

$productMock = $this->getMockBuilder('Magento\Catalog\Model\Product')
Expand All @@ -109,11 +100,28 @@ public function testGetValue()

public function testGetValueWithNoCustomOption()
{
$priceValue = 100;

$priceMock = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class)
->getMockForAbstractClass();
$priceMock->expects($this->once())
->method('getValue')
->willReturn($priceValue);

$this->saleableItem->expects($this->once())
->method('getCustomOption')
->with('simple_product')
->willReturn(null);

$this->assertEquals(0, $this->model->getValue());
$this->saleableItem->expects($this->once())
->method('getPriceInfo')
->willReturn($this->priceInfoMock);

$this->priceInfoMock->expects($this->once())
->method('getPrice')
->with(\Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct::PRICE_CODE)
->willReturn($priceMock);

$this->assertEquals(100, $this->model->getValue());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Wishlist\Test\Constraint;

class AssertProductPriceIsNotZero extends \Magento\Mtf\Constraint\AbstractConstraint
{
/**
* Assert that product price is not zero in default wishlist.
*
* @param \Magento\Cms\Test\Page\CmsIndex $cmsIndex
* @param \Magento\Customer\Test\Page\CustomerAccountIndex $customerAccountIndex
* @param \Magento\Wishlist\Test\Page\WishlistIndex $wishlistIndex
* @param \Magento\Mtf\Fixture\InjectableFixture $product
*
* @return void
*/
public function processAssert(
\Magento\Cms\Test\Page\CmsIndex $cmsIndex,
\Magento\Customer\Test\Page\CustomerAccountIndex $customerAccountIndex,
\Magento\Wishlist\Test\Page\WishlistIndex $wishlistIndex,
\Magento\Mtf\Fixture\InjectableFixture $product
) {
$cmsIndex->getLinksBlock()->openLink('My Account');
$customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Wish List');
$wishlistItem = $wishlistIndex->getWishlistBlock()->getProductItemsBlock()->getItemProduct($product);

\PHPUnit_Framework_Assert::assertNotEquals(
'0.00',
$wishlistItem->getPrice(),
$product->getName() . ' has zero price on Wish List page.'
);
}

/**
* Returns a string representation of the object.
*
* @return string
*/
public function toString()
{
return 'Product price is not zero in default Wish List.';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ public function __prepare(Customer $customer)
*
* @param Customer $customer
* @param string $product
* @param bool $configure
* @return array
*/
public function test(Customer $customer, $product)
public function test(Customer $customer, $product, $configure = true)
{
$product = $this->createProducts($product)[0];

// Steps:
$this->loginCustomer($customer);
$this->addToWishlist([$product], true);
$this->addToWishlist([$product], $configure);

return ['product' => $product];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,12 @@
<constraint name="Magento\Wishlist\Test\Constraint\AssertProductDetailsInWishlist" />
<constraint name="Magento\Wishlist\Test\Constraint\AssertProductIsPresentInCustomerBackendWishlist" />
</variation>
<variation name="AddProductToWishlistEntityTestVariation8">
<data name="product/0" xsi:type="string">configurableProduct::default</data>
<data name="configure" xsi:type="boolean">false</data>
<constraint name="Magento\Wishlist\Test\Constraint\AssertAddProductToWishlistSuccessMessage" />
<constraint name="Magento\Wishlist\Test\Constraint\AssertProductIsPresentInWishlist" />
<constraint name="Magento\Wishlist\Test\Constraint\AssertProductPriceIsNotZero" />
</variation>
</testCase>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ public function getConstructorArguments(\ReflectionClass $class, $groupByPositio
/**
* Skip native PHP types, classes without constructor
*/
if (!$class->getFileName() || false == $class->hasMethod(
'__construct'
) || !$inherited && $class->getConstructor()->class != $class->getName()
if ($class->isInterface() ||
!$class->getFileName() ||
false == $class->hasMethod('__construct') ||
!$inherited &&
$class->getConstructor()->class != $class->getName()
) {
return $output;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ public function testGetConstructorArgumentsClassWithoutOwnConstructorInheritedFa
$this->assertEquals([], $actualResult);
}

public function testGetConstructorArgumentsWhenInputTypeIsInterfaceWithParam()
{
$class = new \ReflectionClass('InterfaceTypeWithConstructorMethodAndParams');
$actualResult = $this->_model->getConstructorArguments($class);
$this->assertEquals([], $actualResult);
}

public function testGetConstructorArgumentsWhenInputTypeIsInterfaceWithoutParam()
{
$class = new \ReflectionClass('InterfaceTypeWithConstructorMethodWithoutParams');
$actualResult = $this->_model->getConstructorArguments($class);
$this->assertEquals([], $actualResult);
}

public function testGetConstructorArgumentsClassWithoutOwnConstructorInheritedTrue()
{
$expectedResult = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,21 @@ public function __construct(\stdClass $stdClassObject, \ClassExtendsDefaultPhpTy
$this->argumentTwo = $secondClass;
}
}

interface InterfaceTypeWithConstructorMethodAndParams
{
/**
* We do not expect that this is valid case. There is no need to declare interface with method __construct
*
* @param $paramOne
* @param $paramTwo
*/
public function __construct($paramOne, $paramTwo);
}
interface InterfaceTypeWithConstructorMethodWithoutParams
{
/**
* We do not expect that this is valid case. There is no need to declare interface with method __construct
*/
public function __construct();
}

0 comments on commit c605e5d

Please sign in to comment.