Skip to content

Commit

Permalink
Merge remote-tracking branch 'folks/checkout' into MAGETWO-30786
Browse files Browse the repository at this point in the history
  • Loading branch information
slavvka committed May 13, 2015
2 parents 120f578 + d14d1a3 commit f8bf104
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 56 deletions.
4 changes: 3 additions & 1 deletion app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,12 @@ protected function getStreetFieldConfig($attributeCode, array $attributeConfig,
// customScope is used to group elements within a single form e.g. they can be validated separately
'customScope' => $dataScopePrefix,
'template' => 'ui/form/field',
'elementTmpl' => 'ui/form/element/input',
'elementTmpl' => 'ui/form/element/input'
],
'dataScope' => $lineIndex,
'provider' => $providerName,
'validation' => $isFirstLine ? ['required-entry' => true] : [],
'additionalClasses' => $isFirstLine ? : 'additional'
];
}
return [
Expand All @@ -220,6 +221,7 @@ protected function getStreetFieldConfig($attributeCode, array $attributeConfig,
'type' => 'group',
'config' => [
'template' => 'ui/group/group',
'additionalClasses' => 'street'
],
'children' => $streetLines,
];
Expand Down
52 changes: 0 additions & 52 deletions app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -790,58 +790,6 @@ public function testPlaceOrder()
$this->assertEquals($orderId, $service->placeOrder($cartId));
}

public function testPlaceOrderCreatingAccount()
{
$cartId = 9549;
$orderId = 2321;
$password = 'SoMeP@ssW0rd';
$customerId = 25;
$customerMock = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface', [], [], '', false);

$this->accountManagementMock->expects($this->once())
->method('createAccount')
->with($customerMock, $password)
->willReturn($customerMock);
$this->quoteRepositoryMock->expects($this->once())
->method('getActive')
->with($cartId)
->willReturn($this->quoteMock);
$this->quoteMock->expects($this->once())->method('assignCustomer')->with($customerMock)->willReturnSelf();
$this->quoteMock->expects($this->once())->method('setCheckoutMethod')->with('register');

/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Quote\Model\QuoteManagement $service */
$service = $this->getMock(
'\Magento\Quote\Model\QuoteManagement',
['placeOrder'],
[
'eventManager' => $this->eventManager,
'quoteValidator' => $this->quoteValidator,
'orderFactory' => $this->orderFactory,
'orderManagement' => $this->orderManagement,
'customerManagement' => $this->customerManagement,
'quoteAddressToOrder' => $this->quoteAddressToOrder,
'quoteAddressToOrderAddress' => $this->quoteAddressToOrderAddress,
'quoteItemToOrderItem' => $this->quoteItemToOrderItem,
'quotePaymentToOrderPayment' => $this->quotePaymentToOrderPayment,
'userContext' => $this->userContextMock,
'quoteRepository' => $this->quoteRepositoryMock,
'customerRepository' => $this->customerRepositoryMock,
'customerModelFactory' => $this->customerFactoryMock,
'dataObjectHelper' => $this->dataObjectHelperMock,
'storeManager' => $this->storeManagerMock,
'checkoutSession' => $this->checkoutSessionMock,
'customerSession' => $this->customerSessionMock,
'accountManagement' => $this->accountManagementMock,
'agreementsValidator' => $this->agreementsValidatorMock,
]
);

$service->expects($this->once())->method('placeOrder')->willReturn($orderId);
$customerMock->expects($this->once())->method('getId')->willReturn($customerId);
$this->customerSessionMock->expects($this->once())->method('loginById')->with($customerId);
$this->assertEquals($orderId, $service->placeOrderCreatingAccount($cartId, $customerMock, $password));
}

/**
* @param $isGuest
* @param $isVirtual
Expand Down
24 changes: 23 additions & 1 deletion app/code/Magento/Ui/view/base/web/js/lib/component/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ define([
parentScope: '<%= $data.getPart(dataScope, -2) %>',
template: 'ui/collection',
containers: [],
_elems: []
_elems: [],
additionalClasses: false
},

initialize: function (options) {
Expand Down Expand Up @@ -217,6 +218,27 @@ define([
property = this.uniqueProp;

this[property](active);
},

/**
* Provides classes of element as object used by knockout's css binding.
*/
getStyles: function() {
var styles = {
required: this.required,
_error: this.error,
_disabled: this.disabled
};
if (typeof this.additionalClasses === 'string') {
var item,
additionalClasses = this.additionalClasses.split(" ");
for (item in additionalClasses) {
if (additionalClasses.hasOwnProperty(item)) {
styles[additionalClasses[item]] = true;
}
}
}
return styles;
}
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See COPYING.txt for license details.
*/
-->
<div class="field" data-bind="visible: visible, attr: {'name': element.dataScope}, css: {'required': element.required, '_disabled': element.disabled, '_error': element.error} ">
<div class="field" data-bind="visible: visible, attr: {'name': element.dataScope}, css: getStyles()">

<!-- ko if: element.label -->
<label class="label" data-bind="attr: { for: element.uid }">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See COPYING.txt for license details.
*/
-->
<div class="field" data-bind="css: {'required': element.required}">
<div class="field" data-bind="css: element.additionalClass, css: getStyles()">
<label class="label">
<span data-bind="text: element.label"></span>
</label>
Expand Down

0 comments on commit f8bf104

Please sign in to comment.