Skip to content

Commit

Permalink
Merge remote-tracking branch 'vanilla/develop' into MAGETWO-32170--JS-51
Browse files Browse the repository at this point in the history
  • Loading branch information
guz-anton committed Oct 14, 2015
2 parents 602094d + 9ae5bba commit 6e6bad7
Show file tree
Hide file tree
Showing 49 changed files with 1,616 additions and 364 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
$element = $block->getElement();
$note = $element->getNote() ? '<div class="note" id="' . $element->getId() . '-note">' . $element->getNote() . '</div>' : '';
$elementBeforeLabel = $element->getExtType() == 'checkbox admin__control-checkbox' || $element->getExtType() == 'radio admin__control-radio';
$addOn = $element->getBeforeElementHtml() || $element->getAfterElementHtml();
$addOn = ($element->getBeforeElementHtml() || $element->getAfterElementHtml()) && !$element->getNoWrapAsAddon();
$fieldId = ($element->getHtmlContainerId()) ? ' id="' . $element->getHtmlContainerId() . '"' : '';
$fieldClass = "admin__field field field-{$element->getId()} {$element->getCssClass()}";
$fieldClass .= ($elementBeforeLabel) ? ' choice' : '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Main" name="adminhtml.catalog.product.set.edit" template="catalog/product/attribute/set/main.phtml"/>
<container name="adminhtml.catalog.product.set.edit.wrapper" htmlTag="div" htmlClass="admin__scope-old"><!-- @todo ui: remove arguments within .admin__scope-old -->
<block class="Magento\Catalog\Block\Adminhtml\Product\Attribute\Set\Main" name="adminhtml.catalog.product.set.edit" template="catalog/product/attribute/set/main.phtml"/>
</container>
</referenceContainer>
</body>
</page>
Original file line number Diff line number Diff line change
Expand Up @@ -1803,7 +1803,7 @@ protected function _saveMediaGallery(array $mediaGalleryData)
'value' => $insertValue['value'],
];
$valueToProductId[$insertValue['value']] = $productId;
$imageNames = $insertValue['value'];
$imageNames[] = $insertValue['value'];
$multiInsertData[] = $valueArr;
$insertedGalleryImgs[] = $insertValue['value'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,6 @@
</div>
</fieldset>
</div>

<button type="button"
class="action-close"
data-role="close-panel"
title="<?= $block->escapeHtml(__('Close panel')) ?>">
<span><?= /* @escapeNotVerified */ __('Close panel') ?></span>
</button>
<div class="image-pointer"></div>
</div>
</script>

Expand Down Expand Up @@ -441,14 +433,6 @@
</div>
</fieldset>
</div>

<button type="button"
class="action-close"
data-role="close-panel"
title="<?= $block->escapeHtml(__('Close panel')) ?>">
<span><?= /* @escapeNotVerified */ __('Close panel') ?></span>
</button>
<div class="image-pointer"></div>
</div>
</script>

Expand Down
32 changes: 1 addition & 31 deletions app/code/Magento/Customer/Block/CustomerData.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,14 @@

class CustomerData extends \Magento\Framework\View\Element\Template
{
/**
* Sections that can not be cached on frontend-side
*
* @var array
*/
protected $nonCachedSections = [];

/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param array $data
* @param array $nonCachedSections
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
array $data = [],
array $nonCachedSections = []
array $data = []
) {
$this->nonCachedSections = $nonCachedSections;
parent::__construct($context, $data);
}

Expand All @@ -50,24 +40,4 @@ public function getCustomerDataUrl($route)
{
return $this->getUrl($route, ['_secure' => $this->getRequest()->isSecure()]);
}

/**
* Get sections that can not be cached on frontend-side
*
* @return array
*/
public function getNotCachedSections()
{
return $this->nonCachedSections;
}

/**
* Get keys of sections that can not be cached on frontend-side
*
* @return array
*/
public function getNonCachedSectionKeys()
{
return array_keys($this->nonCachedSections);
}
}
164 changes: 164 additions & 0 deletions app/code/Magento/Customer/Test/Unit/Ui/Component/DataProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Customer\Test\Unit\Ui\Component;

use Magento\Customer\Api\Data\AttributeMetadataInterface;
use Magento\Customer\Ui\Component\DataProvider;
use Magento\Customer\Ui\Component\Listing\AttributeRepository;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\Search\SearchCriteriaInterface;
use Magento\Framework\View\Element\UiComponent\DataProvider\Reporting;

class DataProviderTest extends \PHPUnit_Framework_TestCase
{
const TEST_REQUEST_NAME = 'test_request_name';

/**
* @var DataProvider
*/
protected $model;

/**
* @var Reporting | \PHPUnit_Framework_MockObject_MockObject
*/
protected $reporting;

/**
* @var SearchCriteriaInterface | \PHPUnit_Framework_MockObject_MockObject
*/
protected $searchCriteria;

/**
* @var \Magento\Framework\App\RequestInterface | \PHPUnit_Framework_MockObject_MockObject
*/
protected $request;

/**
* @var FilterBuilder | \PHPUnit_Framework_MockObject_MockObject
*/
protected $filterBuilder;

/**
* @var AttributeRepository | \PHPUnit_Framework_MockObject_MockObject
*/
protected $attributeRepository;

public function setUp()
{
$this->reporting = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\DataProvider\Reporting')
->disableOriginalConstructor()
->getMock();

$searchCriteriaBuilder = $this->mockSearchCriteria();

$this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface')
->getMockForAbstractClass();

$this->filterBuilder = $this->getMockBuilder('Magento\Framework\Api\FilterBuilder')
->disableOriginalConstructor()
->getMock();

$this->attributeRepository = $this->getMockBuilder('Magento\Customer\Ui\Component\Listing\AttributeRepository')
->disableOriginalConstructor()
->getMock();

$this->model = new DataProvider(
self::TEST_REQUEST_NAME,
'',
'',
$this->reporting,
$searchCriteriaBuilder,
$this->request,
$this->filterBuilder,
$this->attributeRepository
);
}

public function testGetData()
{
$attributeCode = 'attribute_code';
$attributeValue = [
AttributeMetadataInterface::OPTIONS => [
[
'label' => 'opt1_label',
'value' => 'opt1_value',
],
],
];

$expected = [
[
'attribute_code' => ['opt1_value'],
],
];

$attributeMock = $this->getMockBuilder('Magento\Framework\Api\AttributeInterface')
->getMockForAbstractClass();
$attributeMock->expects($this->once())
->method('getAttributeCode')
->willReturn($attributeCode);
$attributeMock->expects($this->once())
->method('getValue')
->willReturn('opt1_value');

$searchDocumentMock = $this->getMockBuilder('Magento\Framework\Api\Search\DocumentInterface')
->getMockForAbstractClass();
$searchDocumentMock->expects($this->once())
->method('getCustomAttributes')
->willReturn([$attributeMock]);

$searchResultMock = $this->getMockBuilder('Magento\Framework\Api\Search\SearchResultInterface')
->getMockForAbstractClass();
$searchResultMock->expects($this->once())
->method('getTotalCount')
->willReturn(1);
$searchResultMock->expects($this->once())
->method('getItems')
->willReturn([$searchDocumentMock]);

$this->searchCriteria->expects($this->once())
->method('setRequestName')
->with(self::TEST_REQUEST_NAME)
->willReturnSelf();

$this->reporting->expects($this->once())
->method('search')
->with($this->searchCriteria)
->willReturn($searchResultMock);

$this->attributeRepository->expects($this->once())
->method('getList')
->willReturn([$attributeCode => $attributeValue]);

$result = $this->model->getData();

$this->assertTrue(is_array($result));
$this->assertArrayHasKey('totalRecords', $result);
$this->assertEquals(1, $result['totalRecords']);
$this->assertArrayHasKey('items', $result);
$this->assertTrue(is_array($result['items']));
$this->assertEquals($result['items'], $expected);
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject
*/
protected function mockSearchCriteria()
{
$this->searchCriteria = $this->getMockBuilder('Magento\Framework\Api\Search\SearchCriteriaInterface')
->getMockForAbstractClass();

$searchCriteriaBuilder = $this->getMockBuilder('Magento\Framework\Api\Search\SearchCriteriaBuilder')
->disableOriginalConstructor()
->getMock();

$searchCriteriaBuilder->expects($this->any())
->method('create')
->willReturn($this->searchCriteria);

return $searchCriteriaBuilder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
'*' => ['Magento_Customer/js/customer-data' => [
'sectionLoadUrl' => $block->getCustomerDataUrl('customer/section/load'),
'cookieLifeTime' => $block->getCookieLifeTime(),
'nonCachedSections' => $block->getNonCachedSectionKeys(),
]],
]);
?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ define([
storage.removeAll();
var date = new Date(Date.now() + parseInt(options.cookieLifeTime, 10) * 1000);
$.localStorage.set('mage-cache-timeout', date);
} else {
invalidateNonCachedSections(options);
}
};

Expand All @@ -35,12 +33,6 @@ define([
}
};

var invalidateNonCachedSections = function(options) {
_.each(options.nonCachedSections, function (sectionName) {
storageInvalidation.set(sectionName, true);
});
}

var dataProvider = {
getFromStorage: function (sectionNames) {
var result = {};
Expand Down
22 changes: 0 additions & 22 deletions app/code/Magento/SampleData/Model/BlackHole.php

This file was deleted.

20 changes: 0 additions & 20 deletions app/code/Magento/SampleData/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,4 @@
</argument>
</arguments>
</type>
<virtualType name="Magento\SampleData\Model\BlackHoleFactory" type="\Magento\Framework\Mail\TransportInterfaceFactory">
<arguments>
<argument name="instanceName" xsi:type="string">Magento\SampleData\Model\BlackHole</argument>
</arguments>
</virtualType>
<virtualType name="blackHoleTransportBuilder" type="Magento\Framework\Mail\Template\TransportBuilder">
<arguments>
<argument name="mailTransportFactory" xsi:type="object" >Magento\SampleData\Model\BlackHoleFactory</argument>
</arguments>
</virtualType>
<virtualType name="sampleDataAccountManagement" type="Magento\Customer\Model\AccountManagement">
<arguments>
<argument name="transportBuilder" xsi:type="object">blackHoleTransportBuilder</argument>
</arguments>
</virtualType>
<type name="Magento\SampleData\Module\Customer\Setup\Customer">
<arguments>
<argument name="accountManagement" xsi:type="object">sampleDataAccountManagement</argument>
</arguments>
</type>
</config>
Loading

0 comments on commit 6e6bad7

Please sign in to comment.