Skip to content

Commit

Permalink
Merge pull request #554 from magento-south/BUGS
Browse files Browse the repository at this point in the history
[SOUTH] Bugfixes
  • Loading branch information
Akimov, Alexander(aakimov) committed Apr 21, 2016
2 parents 1c55514 + 7009584 commit a4dd876
Show file tree
Hide file tree
Showing 30 changed files with 377 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<button attr="{disabled: disabled}"
class="action-secondary"
type="button"
click="addChild.bind($data, false, false)">
click="processingAddChild.bind($data, false, false, false)">
<span text="addButtonLabel"/>
</button>
</div>
Expand Down Expand Up @@ -59,7 +59,7 @@
</tr>
</thead>

<tbody data-bind="foreach: elems">
<tbody>
<tr repeat="foreach: elems, item: '$record'"
class="data-row"
css="'_odd-row': $index % 2">
Expand Down
7 changes: 7 additions & 0 deletions app/code/Magento/Catalog/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,12 @@
</allowed_resources>
</media_storage_configuration>
</system>
<design>
<watermark>
<image_position>stretch</image_position>
<small_image_position>stretch</small_image_position>
<thumbnail_position>stretch</thumbnail_position>
</watermark>
</design>
</default>
</config>
4 changes: 1 addition & 3 deletions app/code/Magento/Catalog/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@
<item name="watermark_image_position" xsi:type="array">
<item name="path" xsi:type="string">design/watermark/image_position</item>
<item name="fieldset" xsi:type="string">other_settings/watermark/image</item>
<item name="default" xsi:type="string">stretch</item>

</item>
<item name="watermark_small_image_size" xsi:type="array">
<item name="path" xsi:type="string">design/watermark/small_image_size</item>
Expand Down Expand Up @@ -658,7 +658,6 @@
<item name="watermark_small_image_position" xsi:type="array">
<item name="path" xsi:type="string">design/watermark/small_image_position</item>
<item name="fieldset" xsi:type="string">other_settings/watermark/small_image</item>
<item name="default" xsi:type="string">stretch</item>
</item>
<item name="watermark_thumbnail_size" xsi:type="array">
<item name="path" xsi:type="string">design/watermark/thumbnail_size</item>
Expand Down Expand Up @@ -686,7 +685,6 @@
<item name="watermark_thumbnail_position" xsi:type="array">
<item name="path" xsi:type="string">design/watermark/thumbnail_position</item>
<item name="fieldset" xsi:type="string">other_settings/watermark/thumbnail</item>
<item name="default" xsi:type="string">stretch</item>
</item>
</argument>
</arguments>
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Checkout/etc/frontend/sections.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<action name="rest/*/V1/carts/*/payment-information">
<section name="cart"/>
<section name="checkout-data"/>
<section name="last-ordered-items"/>
</action>
<action name="rest/*/V1/guest-carts/*/payment-information">
<section name="cart"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="styles"/>
<update handle="editor"/>
<body>
<referenceContainer name="content">
<uiComponent name="cms_block_form"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="editor"/>
<body>
<referenceContainer name="content">
<uiComponent name="cms_page_form"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Customer\Model\ResourceModel\Db\VersionControl;

use Magento\Framework\DataObject;
use Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot;

class AddressSnapshot extends Snapshot
{
/**
* {@inheritdoc}
*/
public function isModified(DataObject $entity)
{
$result = parent::isModified($entity);

if (!$result
&& !$entity->getIsCustomerSaveTransaction()
&& $this->isAddressDefault($entity)
) {
return true;
}

return $result;
}

/**
* Checks if address has chosen as default and has had an id
*
* @param DataObject $entity
* @return bool
*/
private function isAddressDefault(DataObject $entity)
{
return $entity->getId() && ($entity->getIsDefaultBilling() || $entity->getIsDefaultShipping());
}
}
13 changes: 12 additions & 1 deletion app/code/Magento/Customer/Observer/AfterAddressSaveObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\Customer\Api\GroupManagementInterface;
use Magento\Customer\Helper\Address as HelperAddress;
use Magento\Customer\Model\Address\AbstractAddress;
use Magento\Customer\Model\Session as CustomerSession;
use Magento\Framework\App\Area;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\State as AppState;
Expand Down Expand Up @@ -72,6 +73,11 @@ class AfterAddressSaveObserver implements ObserverInterface
*/
protected $escaper;

/**
* @var CustomerSession
*/
private $customerSession;

/**
* @param Vat $customerVat
* @param HelperAddress $customerAddress
Expand All @@ -81,6 +87,7 @@ class AfterAddressSaveObserver implements ObserverInterface
* @param ManagerInterface $messageManager
* @param Escaper $escaper
* @param AppState $appState
* @param CustomerSession $customerSession
*/
public function __construct(
Vat $customerVat,
Expand All @@ -90,7 +97,8 @@ public function __construct(
ScopeConfigInterface $scopeConfig,
ManagerInterface $messageManager,
Escaper $escaper,
AppState $appState
AppState $appState,
CustomerSession $customerSession
) {
$this->_customerVat = $customerVat;
$this->_customerAddress = $customerAddress;
Expand All @@ -100,6 +108,7 @@ public function __construct(
$this->messageManager = $messageManager;
$this->escaper = $escaper;
$this->appState = $appState;
$this->customerSession = $customerSession;
}

/**
Expand Down Expand Up @@ -132,6 +141,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
if (!$customer->getDisableAutoGroupChange() && $customer->getGroupId() != $defaultGroupId) {
$customer->setGroupId($defaultGroupId);
$customer->save();
$this->customerSession->setCustomerGroupId($defaultGroupId);
}
} else {
$result = $this->_customerVat->checkVatNumber(
Expand All @@ -148,6 +158,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
if (!$customer->getDisableAutoGroupChange() && $customer->getGroupId() != $newGroupId) {
$customer->setGroupId($newGroupId);
$customer->save();
$this->customerSession->setCustomerGroupId($newGroupId);
}

$customerAddress->setVatValidationResult($result);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Customer\Test\Unit\Model\ResourceModel\Db\VersionControl;

use Magento\Customer\Model\ResourceModel\Db\VersionControl\AddressSnapshot;

class AddressSnapshotTest extends \PHPUnit_Framework_TestCase
{
/**
* @var AddressSnapshot
*/
private $model;

/**
* @var \Magento\Framework\Model\ResourceModel\Db\VersionControl\Metadata|\PHPUnit_Framework_MockObject_MockObject
*/
private $metadataMock;

protected function setUp()
{
$this->metadataMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\VersionControl\Metadata')
->disableOriginalConstructor()
->getMock();

$this->model = new AddressSnapshot(
$this->metadataMock
);
}

/**
* @param bool $isCustomerSaveTransaction
* @param int $isDefaultBilling
* @param int $isDefaultShipping
* @param bool $expected
* @dataProvider dataProviderIsModified
*/
public function testIsModified(
$isCustomerSaveTransaction,
$isDefaultBilling,
$isDefaultShipping,
$expected
) {
$entityId = 1;

$dataObjectMock = $this->getMockBuilder('Magento\Framework\DataObject')
->disableOriginalConstructor()
->setMethods([
'getId',
'getData',
'getDataByKey',
'getIsDefaultBilling',
'getIsDefaultShipping',
'getIsCustomerSaveTransaction',
])
->getMock();

$dataObjectMock->expects($this->any())
->method('getId')
->willReturn($entityId);
$dataObjectMock->expects($this->once())
->method('getData')
->willReturn(['is_billing_address' => 1]);
$dataObjectMock->expects($this->once())
->method('getDataByKey')
->with('is_billing_address')
->willReturn(1);
$dataObjectMock->expects($this->once())
->method('getIsCustomerSaveTransaction')
->willReturn($isCustomerSaveTransaction);
$dataObjectMock->expects($this->any())
->method('getIsDefaultBilling')
->willReturn($isDefaultBilling);
$dataObjectMock->expects($this->any())
->method('getIsDefaultShipping')
->willReturn($isDefaultShipping);

$this->metadataMock->expects($this->once())
->method('getFields')
->with($dataObjectMock)
->willReturn(['is_billing_address' => null]);

$this->model->registerSnapshot($dataObjectMock);

$this->assertEquals($expected, $this->model->isModified($dataObjectMock));
}

/**
* @return array
*/
public function dataProviderIsModified()
{
return [
[false, 1, 1, true],
[true, 0, 0, false],
[false, 1, 0, true],
[false, 0, 1, true],
];
}

public function testIsModifiedBypass()
{
$dataObjectMock = $this->getMockBuilder('Magento\Framework\DataObject')
->disableOriginalConstructor()
->setMethods([
'getId',
'getData',
])
->getMock();

$dataObjectMock->expects($this->any())
->method('getId')
->willReturn(null);
$dataObjectMock->expects($this->once())
->method('getData')
->willReturn(['is_billing_address' => 1]);

$this->metadataMock->expects($this->once())
->method('getFields')
->with($dataObjectMock)
->willReturn(['is_billing_address' => null]);

$this->model->registerSnapshot($dataObjectMock);

$this->assertEquals(true, $this->model->isModified($dataObjectMock));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ class AfterAddressSaveObserverTest extends \PHPUnit_Framework_TestCase
*/
protected $customerMock;

/**
* @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject
*/
protected $customerSessionMock;

protected function setUp()
{
$this->vat = $this->getMockBuilder('Magento\Customer\Model\Vat')
Expand Down Expand Up @@ -105,6 +110,9 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();

$this->customerSessionMock = $this->getMockBuilder('Magento\Customer\Model\Session')
->disableOriginalConstructor()
->getMock();

$this->model = new AfterAddressSaveObserver(
$this->vat,
Expand All @@ -114,7 +122,8 @@ protected function setUp()
$this->scopeConfig,
$this->messageManager,
$this->escaper,
$this->appState
$this->appState,
$this->customerSessionMock
);
}

Expand Down Expand Up @@ -462,6 +471,11 @@ public function testAfterAddressSaveNewGroup(
->method('save')
->willReturnSelf();

$this->customerSessionMock->expects($this->once())
->method('setCustomerGroupId')
->with($newGroupId)
->willReturnSelf();

$address = $this->getMockBuilder('Magento\Customer\Model\Address')
->disableOriginalConstructor()
->setMethods([
Expand Down
7 changes: 6 additions & 1 deletion app/code/Magento/Customer/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<type name="Magento\Customer\Model\ResourceModel\Address">
<arguments>
<argument name="customerRepository" xsi:type="object">Magento\Customer\Api\CustomerRepositoryInterface\Proxy</argument>
<argument name="entitySnapshot" xsi:type="object">EavVersionControlSnapshot</argument>
<argument name="entitySnapshot" xsi:type="object">CustomerAddressSnapshot</argument>
<argument name="entityRelationComposite" xsi:type="object">CustomerAddressRelationsComposite</argument>
</arguments>
</type>
Expand Down Expand Up @@ -152,6 +152,11 @@
<argument name="metadata" xsi:type="object">Magento\Eav\Model\Entity\VersionControl\Metadata</argument>
</arguments>
</virtualType>
<virtualType name="CustomerAddressSnapshot" type="Magento\Customer\Model\ResourceModel\Db\VersionControl\AddressSnapshot">
<arguments>
<argument name="metadata" xsi:type="object">Magento\Eav\Model\Entity\VersionControl\Metadata</argument>
</arguments>
</virtualType>
<virtualType name="CustomerRelationsComposite" type="Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite">
<arguments>
<argument name="relationProcessors" xsi:type="array">
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Customer/etc/indexer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Indexer/etc/indexer.xsd">
<indexer id="customer_grid" view_id="dummy" class="Magento\Framework\Indexer\Action\Entity" primary="customer">
<indexer id="customer_grid" view_id="customer_dummy" class="Magento\Framework\Indexer\Action\Entity" primary="customer">
<title translate="true">Customer Grid</title>
<description translate="true">Rebuild Customer grid index</description>

Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Customer/etc/mview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Mview/etc/mview.xsd">
<view id="dummy" class="Magento\Customer\Model\Indexer\Mview\Dummy" group="indexer"/>
<view id="customer_dummy" class="Magento\Customer\Model\Indexer\Mview\Dummy" group="indexer"/>
</config>
Loading

0 comments on commit a4dd876

Please sign in to comment.