Skip to content

Commit c044a2d

Browse files
Logvin, Michael(mlogvin)Logvin, Michael(mlogvin)
Logvin, Michael(mlogvin)
authored and
Logvin, Michael(mlogvin)
committed
Merge pull request #179 from magento-firedrakes/MAGETWO-44191
[Firedrakes && South] Bugfixes
2 parents ca97943 + 63cd8a3 commit c044a2d

File tree

8 files changed

+289
-39
lines changed

8 files changed

+289
-39
lines changed

app/code/Magento/Customer/Model/CustomerExtractor.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,10 @@ public function __construct(
6565
public function extract($formCode, RequestInterface $request)
6666
{
6767
$customerForm = $this->formFactory->create('customer', $formCode);
68-
68+
$customerData = $customerForm->extractData($request);
6969
$allowedAttributes = $customerForm->getAllowedAttributes();
70-
$isGroupIdEmpty = true;
71-
$customerData = [];
72-
foreach ($allowedAttributes as $attribute) {
73-
$attributeCode = $attribute->getAttributeCode();
74-
if ($attributeCode == 'group_id') {
75-
$isGroupIdEmpty = false;
76-
}
77-
$customerData[$attributeCode] = $request->getParam($attributeCode);
78-
}
70+
$isGroupIdEmpty = isset($allowedAttributes['group_id']);
71+
7972
$customerDataObject = $this->customerFactory->create();
8073
$this->dataObjectHelper->populateWithArray(
8174
$customerDataObject,
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Customer\Test\Unit\Model;
7+
8+
use Magento\Customer\Model\CustomerExtractor;
9+
10+
class CustomerExtractorTest extends \PHPUnit_Framework_TestCase
11+
{
12+
/** @var CustomerExtractor */
13+
protected $customerExtractor;
14+
15+
/** @var \Magento\Customer\Model\Metadata\FormFactory|\PHPUnit_Framework_MockObject_MockObject */
16+
protected $formFactory;
17+
18+
/** @var \Magento\Customer\Api\Data\CustomerInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject */
19+
protected $customerFactory;
20+
21+
/** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
22+
protected $storeManager;
23+
24+
/** @var \Magento\Customer\Api\GroupManagementInterface|\PHPUnit_Framework_MockObject_MockObject */
25+
protected $customerGroupManagement;
26+
27+
/** @var \Magento\Framework\Api\DataObjectHelper|\PHPUnit_Framework_MockObject_MockObject */
28+
protected $dataObjectHelper;
29+
30+
/** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */
31+
protected $request;
32+
33+
/** @var \Magento\Customer\Model\Metadata\Form|\PHPUnit_Framework_MockObject_MockObject */
34+
protected $customerForm;
35+
36+
/** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject */
37+
protected $customerData;
38+
39+
/** @var \Magento\Store\Api\Data\StoreInterface|\PHPUnit_Framework_MockObject_MockObject */
40+
protected $store;
41+
42+
/** @var \Magento\Customer\Api\Data\GroupInterface|\PHPUnit_Framework_MockObject_MockObject */
43+
protected $customerGroup;
44+
45+
public function setUp()
46+
{
47+
$this->formFactory = $this->getMockForAbstractClass(
48+
'Magento\Customer\Model\Metadata\FormFactory',
49+
[],
50+
'',
51+
false,
52+
false,
53+
true,
54+
['create']
55+
);
56+
$this->customerFactory = $this->getMockForAbstractClass(
57+
'Magento\Customer\Api\Data\CustomerInterfaceFactory',
58+
[],
59+
'',
60+
false,
61+
false,
62+
true,
63+
['create']
64+
);
65+
$this->storeManager = $this->getMockForAbstractClass(
66+
'Magento\Store\Model\StoreManagerInterface',
67+
[],
68+
'',
69+
false
70+
);
71+
$this->customerGroupManagement = $this->getMockForAbstractClass(
72+
'Magento\Customer\Api\GroupManagementInterface',
73+
[],
74+
'',
75+
false
76+
);
77+
$this->dataObjectHelper = $this->getMock('Magento\Framework\Api\DataObjectHelper', [], [], '', false);
78+
$this->request = $this->getMockForAbstractClass('Magento\Framework\App\RequestInterface', [], '', false);
79+
$this->customerForm = $this->getMock('Magento\Customer\Model\Metadata\Form', [], [], '', false);
80+
$this->customerData = $this->getMockForAbstractClass(
81+
'Magento\Customer\Api\Data\CustomerInterface',
82+
[],
83+
'',
84+
false
85+
);
86+
$this->store = $this->getMockForAbstractClass(
87+
'Magento\Store\Api\Data\StoreInterface',
88+
[],
89+
'',
90+
false
91+
);
92+
$this->customerGroup = $this->getMockForAbstractClass(
93+
'Magento\Customer\Api\Data\GroupInterface',
94+
[],
95+
'',
96+
false
97+
);
98+
$this->customerExtractor = new CustomerExtractor(
99+
$this->formFactory,
100+
$this->customerFactory,
101+
$this->storeManager,
102+
$this->customerGroupManagement,
103+
$this->dataObjectHelper
104+
);
105+
}
106+
107+
public function testExtract()
108+
{
109+
$customerData = [
110+
'firstname' => 'firstname',
111+
'lastname' => 'firstname',
112+
'email' => 'email.example.com',
113+
];
114+
115+
$this->formFactory->expects($this->once())
116+
->method('create')
117+
->with('customer', 'form-code')
118+
->willReturn($this->customerForm);
119+
$this->customerForm->expects($this->once())
120+
->method('extractData')
121+
->with($this->request)
122+
->willReturn($customerData);
123+
$this->customerForm->expects($this->once())
124+
->method('getAllowedAttributes')
125+
->willReturn(['group_id' => 'attribute object']);
126+
$this->customerFactory->expects($this->once())
127+
->method('create')
128+
->willReturn($this->customerData);
129+
$this->dataObjectHelper->expects($this->once())
130+
->method('populateWithArray')
131+
->with($this->customerData, $customerData, '\Magento\Customer\Api\Data\CustomerInterface')
132+
->willReturn($this->customerData);
133+
$this->storeManager->expects($this->once())
134+
->method('getStore')
135+
->willReturn($this->store);
136+
$this->store->expects($this->exactly(2))
137+
->method('getId')
138+
->willReturn(1);
139+
$this->customerGroupManagement->expects($this->once())
140+
->method('getDefaultGroup')
141+
->with(1)
142+
->willReturn($this->customerGroup);
143+
$this->customerGroup->expects($this->once())
144+
->method('getId')
145+
->willReturn(1);
146+
$this->customerData->expects($this->once())
147+
->method('setGroupId')
148+
->with(1);
149+
$this->store->expects($this->once())
150+
->method('getWebsiteId')
151+
->willReturn(1);
152+
$this->customerData->expects($this->once())
153+
->method('setWebsiteId')
154+
->with(1);
155+
$this->customerData->expects($this->once())
156+
->method('setStoreId')
157+
->with(1);
158+
159+
$this->assertSame($this->customerData, $this->customerExtractor->extract('form-code', $this->request));
160+
}
161+
}

app/code/Magento/Customer/view/adminhtml/ui_component/customer_online_grid.xml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,6 @@
135135
</item>
136136
</argument>
137137
</column>
138-
<!-- <column name="remote_addr">
139-
<argument name="data" xsi:type="array">
140-
<item name="config" xsi:type="array">
141-
<item name="label" xsi:type="string" translate="true">IP Address</item>
142-
</item>
143-
</argument>
144-
</column> -->
145-
<column name="first_visit_at" class="Magento\Ui\Component\Listing\Columns\Date">
146-
<argument name="data" xsi:type="array">
147-
<item name="config" xsi:type="array">
148-
<item name="filter" xsi:type="string">dateRange</item>
149-
<item name="dataType" xsi:type="string">date</item>
150-
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
151-
<item name="label" xsi:type="string" translate="true">Session Start Time</item>
152-
</item>
153-
</argument>
154-
</column>
155138
<column name="last_visit_at" class="Magento\Ui\Component\Listing\Columns\Date">
156139
<argument name="data" xsi:type="array">
157140
<item name="config" xsi:type="array">
@@ -173,12 +156,5 @@
173156
</item>
174157
</argument>
175158
</column>
176-
<!-- <column name="last_url">
177-
<argument name="data" xsi:type="array">
178-
<item name="config" xsi:type="array">
179-
<item name="label" xsi:type="string" translate="true">Last URL</item>
180-
</item>
181-
</argument>
182-
</column> -->
183159
</columns>
184160
</listing>

app/code/Magento/Sales/Block/Adminhtml/Order/Create/Totals.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,14 @@ protected function _construct()
8383
*/
8484
public function getTotals()
8585
{
86-
return $this->getQuote()->getTotals();
86+
$this->getQuote()->setTotalsCollectedFlag(false);
87+
$this->getQuote()->collectTotals();
88+
if ($this->getQuote()->isVirtual()) {
89+
$totals = $this->getQuote()->getBillingAddress()->getTotals();
90+
} else {
91+
$totals = $this->getQuote()->getShippingAddress()->getTotals();
92+
}
93+
return $totals;
8794
}
8895

8996
/**
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sales\Test\Unit\Block\Order\Create;
8+
9+
/**
10+
* Class TotalsTest
11+
*/
12+
class TotalsTest extends \PHPUnit_Framework_TestCase
13+
{
14+
/**
15+
* @var \PHPUnit_Framework_MockObject_MockObject
16+
*/
17+
protected $shippingAddressMock;
18+
19+
/**
20+
* @var \PHPUnit_Framework_MockObject_MockObject
21+
*/
22+
protected $billingAddressMock;
23+
24+
/**
25+
* @var \Magento\Sales\Block\Adminhtml\Order\Create\Totals
26+
*/
27+
protected $totals;
28+
29+
/**
30+
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
31+
*/
32+
protected $helperManager;
33+
34+
/**
35+
* @var \Magento\Backend\Model\Session\Quote|\PHPUnit_Framework_MockObject_MockObject
36+
*/
37+
protected $sessionQuoteMock;
38+
39+
/**
40+
* @var \Magento\Quote\Model\Quote|\PHPUnit_Framework_MockObject_MockObject
41+
*/
42+
protected $quoteMock;
43+
44+
/**
45+
* Init
46+
*/
47+
protected function setUp()
48+
{
49+
$this->helperManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
50+
$this->sessionQuoteMock = $this->getMockBuilder('Magento\Backend\Model\Session\Quote')
51+
->disableOriginalConstructor()
52+
->getMock();
53+
$this->quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote')
54+
->disableOriginalConstructor()
55+
->setMethods([
56+
'setTotalsCollectedFlag',
57+
'collectTotals',
58+
'getTotals',
59+
'isVirtual',
60+
'getBillingAddress',
61+
'getShippingAddress'
62+
])
63+
->getMock();
64+
$this->shippingAddressMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address')
65+
->disableOriginalConstructor()
66+
->getMock();
67+
$this->billingAddressMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Address')
68+
->disableOriginalConstructor()
69+
->getMock();
70+
71+
$this->quoteMock->expects($this->any())
72+
->method('getBillingAddress')
73+
->willreturn($this->billingAddressMock);
74+
$this->quoteMock->expects($this->any())
75+
->method('getShippingAddress')
76+
->willreturn($this->shippingAddressMock);
77+
$this->sessionQuoteMock->expects($this->any())->method('getQuote')->willReturn($this->quoteMock);
78+
$this->totals = $this->helperManager->getObject(
79+
'Magento\Sales\Block\Adminhtml\Order\Create\Totals',
80+
['sessionQuote' => $this->sessionQuoteMock]
81+
);
82+
}
83+
84+
/**
85+
* @dataProvider totalsDataProvider
86+
*/
87+
public function testGetTotals($isVirtual)
88+
{
89+
$expected = 'expected';
90+
$this->quoteMock->expects($this->at(0))->method('setTotalsCollectedFlag')->with(false);
91+
$this->quoteMock->expects($this->at(1))->method('collectTotals');
92+
$this->quoteMock->expects($this->once())->method('isVirtual')->willreturn($isVirtual);
93+
if ($isVirtual) {
94+
$this->billingAddressMock->expects($this->once())->method('getTotals')->willReturn($expected);
95+
} else {
96+
$this->shippingAddressMock->expects($this->once())->method('getTotals')->willReturn($expected);
97+
}
98+
$this->assertEquals($expected, $this->totals->getTotals());
99+
}
100+
101+
/**
102+
* @return array
103+
*/
104+
public function totalsDataProvider()
105+
{
106+
return [
107+
[true],
108+
[false]
109+
];
110+
}
111+
}

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3628,7 +3628,7 @@ protected function _prepareSqlDateCondition($condition, $key)
36283628
$result = $this->formatDate($condition[$key]);
36293629
}
36303630
} else {
3631-
$result = $this->formatDate($condition[$key]);
3631+
$result = $this->formatDate($condition[$key], false);
36323632
}
36333633

36343634
return $result;

lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616
* To aid in security, the cookie manager will make it possible for the application to indicate if the cookie contains
1717
* sensitive data so that extra protection can be added to the contents of the cookie as well as how the browser
1818
* stores the cookie.
19+
*
20+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1921
*/
2022
class PhpCookieManager implements CookieManagerInterface
2123
{
2224
/**#@+
2325
* Constants for Cookie manager.
2426
* RFC 2109 - Page 15
25-
* http://www.ietf.org/rfc/rfc2109.txt
27+
* http://www.ietf.org/rfc/rfc6265.txt
2628
*/
27-
const MAX_NUM_COOKIES = 20;
29+
const MAX_NUM_COOKIES = 50;
2830
const MAX_COOKIE_SIZE = 4096;
2931
const EXPIRE_NOW_TIME = 1;
3032
const EXPIRE_AT_END_OF_SESSION_TIME = 0;

lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class PhpCookieManagerTest extends \PHPUnit_Framework_TestCase
4343
const COOKIE_HTTP_ONLY = true;
4444
const COOKIE_NOT_HTTP_ONLY = false;
4545
const COOKIE_EXPIRE_END_OF_SESSION = 0;
46-
const MAX_NUM_COOKIES = 20;
46+
const MAX_NUM_COOKIES = 50;
4747
const MAX_COOKIE_SIZE = 4096;
4848

4949
/**

0 commit comments

Comments
 (0)