Skip to content

Commit

Permalink
MAGETWO-70277: Merge branch 'develop' of github.com:magento/magento2c…
Browse files Browse the repository at this point in the history
…e into MAGETWO-70277-PR-10062
  • Loading branch information
ishakhsuvarov committed Jun 27, 2017
2 parents 5eced8e + 68a79d9 commit 1798d26
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function initializeFromData(\Magento\Catalog\Model\Product $product, arra
} else {
$productOptions = [];
}

$productData['tier_price'] = isset($productData['tier_price']) ? $productData['tier_price'] : [];
$product->addData($productData);

if ($wasLockedMedia) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,19 @@ protected function setUp()
* @param array $links
* @param array $linkTypes
* @param array $expectedLinks
* @param array|null $tierPrice
* @dataProvider initializeDataProvider
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testInitialize($isSingleStore, $websiteIds, $expWebsiteIds, $links, $linkTypes, $expectedLinks)
{
public function testInitialize(
$isSingleStore,
$websiteIds,
$expWebsiteIds,
$links,
$linkTypes,
$expectedLinks,
$tierPrice = null
) {
$this->linkTypeProviderMock->expects($this->once())
->method('getItems')
->willReturn($this->assembleLinkTypes($linkTypes));
Expand All @@ -184,6 +192,9 @@ public function testInitialize($isSingleStore, $websiteIds, $expWebsiteIds, $lin
'options' => $optionsData,
'website_ids' => $websiteIds
];
if (!empty($tierPrice)) {
$productData = array_merge($productData, ['tier_price' => $tierPrice]);
}
$attributeNonDate = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class)
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -270,10 +281,11 @@ public function testInitialize($isSingleStore, $websiteIds, $expWebsiteIds, $lin
$this->assertTrue('sku' == $option2->getData('product_sku'));

$productLinks = $this->productMock->getProductLinks();

$this->assertCount(count($expectedLinks), $productLinks);
$resultLinks = [];

$this->assertEquals($tierPrice ?: [], $this->productMock->getData('tier_price'));

foreach ($productLinks as $link) {
$this->assertInstanceOf(ProductLink::class, $link);
$this->assertEquals('sku', $link->getSku());
Expand All @@ -297,6 +309,7 @@ public function initializeDataProvider()
'links' => [],
'linkTypes' => ['related', 'upsell', 'crosssell'],
'expected_links' => [],
'tierPrice' => [1, 2, 3],
],
[
'single_store' => false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@
<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date" component="Magento_Ui/js/grid/columns/date">
<settings>
<filter>dateRange</filter>
<dateFormat>MMM dd, YYYY, H:mm:ss A</dateFormat>
<dataType>date</dataType>
<label translate="true">Purchase Date</label>
</settings>
Expand Down
20 changes: 20 additions & 0 deletions app/code/Magento/Swatches/etc/acl.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_attributes">
<resource id="Magento_Swatches::iframe" title="Swatches" translate="title" sortOrder="70" />
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@ public function testSetValidationFilter($couponCode, $expectedItems)
$items = array_values($collection->setValidationFilter(1, 0, $couponCode)->getItems());

$ids = [];

$this->assertEquals(
count($expectedItems),
count($items),
'Invalid number of items in the result collection'
);

foreach ($items as $key => $item) {
$this->assertEquals($expectedItems[$key], $item->getName());
if (in_array($item->getId(), $ids)) {
$this->fail('Item should be unique in result collection');
}
$this->assertFalse(
in_array($item->getId(), $ids),
'Item should be unique in result collection'
);
$ids[] = $item->getId();
}
}
Expand Down
20 changes: 15 additions & 5 deletions dev/tests/integration/testsuite/Magento/SalesRule/_files/rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
'1'
)->setCustomerGroupIds(
'0'
)->setDiscountStep(0)
)->setDiscountStep(
0
)->setSortOrder(1)
->save();

/** @var \Magento\SalesRule\Model\Rule $rule */
Expand All @@ -43,7 +45,9 @@
'1'
)->setCustomerGroupIds(
'0'
)->setDiscountStep(0)
)->setDiscountStep(
0
)->setSortOrder(2)
->save();

/** @var \Magento\SalesRule\Model\Rule $rule */
Expand All @@ -64,7 +68,9 @@
'1'
)->setCustomerGroupIds(
'0'
)->setDiscountStep(0)
)->setDiscountStep(
0
)->setSortOrder(3)
->save();

/** @var \Magento\SalesRule\Model\Rule $rule */
Expand All @@ -85,7 +91,9 @@
'1'
)->setCustomerGroupIds(
'0'
)->setDiscountStep(0)
)->setDiscountStep(
0
)->setSortOrder(4)
->save();

/** @var \Magento\SalesRule\Model\Rule $rule */
Expand All @@ -106,5 +114,7 @@
'1'
)->setCustomerGroupIds(
'0'
)->setDiscountStep(0)
)->setDiscountStep(
0
)->setSortOrder(5)
->save();
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Swatches\Controller\Adminhtml\Iframe;

/**
* @magentoAppArea adminhtml
*/
class ShowTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
/**
* Check Swatch Acl Access
*/
public function testAclAccess()
{
/** @var $acl \Magento\Framework\Acl */
$acl = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->get(\Magento\Framework\Acl\Builder::class)
->getAcl();

$acl->allow(null, \Magento\Swatches\Controller\Adminhtml\Iframe\Show::ADMIN_RESOURCE);

$this->dispatch('backend/swatches/iframe/show/');

$this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
$this->assertNotContains('Access denied', $this->getResponse()->getBody());
}

/**
* Check Swatch Acl Access Denied
*/
public function testAclAccessDenied()
{
/** @var $acl \Magento\Framework\Acl */
$acl = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->get(\Magento\Framework\Acl\Builder::class)
->getAcl();

$acl->deny(null, \Magento\Swatches\Controller\Adminhtml\Iframe\Show::ADMIN_RESOURCE);

$this->dispatch('backend/swatches/iframe/show/');

$this->assertEquals(403, $this->getResponse()->getHttpResponseCode());
$this->assertContains('Access denied', $this->getResponse()->getBody());
}
}

0 comments on commit 1798d26

Please sign in to comment.