Skip to content

Commit 35e643f

Browse files
author
Logvin, Michael(mlogvin)
committed
Merge pull request #126 from magento-firedrakes/MAGETWO-14674
[Firedrakes] Optimized JS i18n
2 parents 437bbaa + 31bc2fd commit 35e643f

File tree

62 files changed

+2667
-838
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2667
-838
lines changed
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Checkout\Test\Unit\Controller\Cart;
7+
8+
use Magento\Checkout\Controller\Cart\Index;
9+
10+
/**
11+
* Class IndexTest
12+
*/
13+
class IndexTest extends \PHPUnit_Framework_TestCase
14+
{
15+
/**
16+
* @var Index
17+
*/
18+
protected $controller;
19+
20+
/**
21+
* @var \Magento\Checkout\Model\Session | \PHPUnit_Framework_MockObject_MockObject
22+
*/
23+
protected $checkoutSession;
24+
25+
/**
26+
* @var \Magento\Framework\App\Request\Http | \PHPUnit_Framework_MockObject_MockObject
27+
*/
28+
protected $request;
29+
30+
/**
31+
* @var \Magento\Framework\App\Response\Http | \PHPUnit_Framework_MockObject_MockObject
32+
*/
33+
protected $response;
34+
35+
/**
36+
* @var \Magento\Quote\Model\Quote | \PHPUnit_Framework_MockObject_MockObject
37+
*/
38+
protected $quote;
39+
40+
/**
41+
* @var \Magento\Framework\Event\Manager | \PHPUnit_Framework_MockObject_MockObject
42+
*/
43+
protected $eventManager;
44+
45+
/**
46+
* @var \Magento\Framework\Event\Manager | \PHPUnit_Framework_MockObject_MockObject
47+
*/
48+
protected $objectManagerMock;
49+
50+
/**
51+
* @var \PHPUnit_Framework_MockObject_MockObject
52+
*/
53+
protected $cart;
54+
55+
/**
56+
* @var \PHPUnit_Framework_MockObject_MockObject
57+
*/
58+
protected $scopeConfig;
59+
60+
/**
61+
* @var \PHPUnit_Framework_MockObject_MockObject
62+
*/
63+
protected $messageManager;
64+
65+
/**
66+
* @var \PHPUnit_Framework_MockObject_MockObject
67+
*/
68+
protected $resultPageFactory;
69+
70+
/**
71+
* @return void
72+
*/
73+
public function setUp()
74+
{
75+
$this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false);
76+
$this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false);
77+
$this->quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false);
78+
$this->eventManager = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false);
79+
$this->checkoutSession = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false);
80+
81+
$this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false);
82+
83+
$this->messageManager = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface')
84+
->disableOriginalConstructor()
85+
->getMock();
86+
87+
$context = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false);
88+
$context->expects($this->once())
89+
->method('getObjectManager')
90+
->willReturn($this->objectManagerMock);
91+
$context->expects($this->once())
92+
->method('getRequest')
93+
->willReturn($this->request);
94+
$context->expects($this->once())
95+
->method('getResponse')
96+
->willReturn($this->response);
97+
$context->expects($this->once())
98+
->method('getEventManager')
99+
->willReturn($this->eventManager);
100+
$context->expects($this->once())
101+
->method('getMessageManager')
102+
->willReturn($this->messageManager);
103+
104+
$this->cart = $this->getMockBuilder('Magento\Checkout\Model\Cart')
105+
->disableOriginalConstructor()
106+
->getMock();
107+
$this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface')
108+
->disableOriginalConstructor()
109+
->getMock();
110+
$this->resultPageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory')
111+
->disableOriginalConstructor()
112+
->setMethods(['create'])
113+
->getMock();
114+
115+
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
116+
117+
$this->controller = $objectManagerHelper->getObject(
118+
'Magento\Checkout\Controller\Cart\Index',
119+
[
120+
'context' => $context,
121+
'checkoutSession' => $this->checkoutSession,
122+
'cart' => $this->cart,
123+
'scopeConfig' => $this->scopeConfig,
124+
'resultPageFactory' => $this->resultPageFactory
125+
]
126+
);
127+
}
128+
129+
/**
130+
* @return void
131+
*/
132+
public function testExecuteWithMessages()
133+
{
134+
$layout = $this->getMockBuilder('Magento\Framework\View\Layout')
135+
->disableOriginalConstructor()
136+
->getMock();
137+
$layout->expects($this->once())
138+
->method('initMessages');
139+
140+
$title = $this->getMockBuilder('Magento\Framework\View\Page\Title')
141+
->disableOriginalConstructor()
142+
->getMock();
143+
$title->expects($this->once())
144+
->method('set')
145+
->with('Shopping Cart');
146+
147+
$config = $this->getMockBuilder('Magento\Framework\View\Page\Config')
148+
->disableOriginalConstructor()
149+
->getMock();
150+
$config->expects($this->once())
151+
->method('getTitle')
152+
->willReturn($title);
153+
154+
$page = $this->getMockBuilder('Magento\Framework\View\Result\Page')
155+
->disableOriginalConstructor()
156+
->getMock();
157+
$page->expects($this->once())
158+
->method('getLayout')
159+
->willReturn($layout);
160+
$page->expects($this->once())
161+
->method('getConfig')
162+
->willReturn($config);
163+
164+
$this->resultPageFactory->expects($this->once())
165+
->method('create')
166+
->willReturn($page);
167+
$result = $this->controller->execute();
168+
$this->assertInstanceOf('Magento\Framework\View\Result\Page', $result);
169+
}
170+
}

app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,9 @@ define([
234234
if (msg) {
235235
if (Array.isArray(msg)) {
236236
msg = msg.reduce(function (str, chunk) {
237-
str += '\n' + $.mage.__(chunk);
237+
str += '\n' + chunk;
238238
return str;
239239
}, '');
240-
} else {
241-
msg = $.mage.__(msg);
242240
}
243241

244242
$(this.options.countrySelector).trigger('change');

app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ define([
198198

199199
$(this.options.countrySelector).trigger('change');
200200

201-
alert($.mage.__(msg));
201+
alert(msg);
202202
} else {
203-
alert($.mage.__(response.error));
203+
alert(response.error);
204204
}
205205

206206
return;

app/code/Magento/Core/etc/di.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,25 @@
5252
<argument name="scopeType" xsi:type="const">Magento\Store\Model\ScopeInterface::SCOPE_STORE</argument>
5353
</arguments>
5454
</type>
55+
<type name="Magento\Framework\View\Asset\PreProcessor\Pool">
56+
<arguments>
57+
<argument name="preProcessors" xsi:type="array">
58+
<item name="less" xsi:type="array">
59+
<item name="css" xsi:type="array">
60+
<item name="less_css" xsi:type="string">Magento\Framework\Css\PreProcessor\Less</item>
61+
<item name="module_notation" xsi:type="string">Magento\Framework\View\Asset\PreProcessor\ModuleNotation</item>
62+
</item>
63+
<item name="less" xsi:type="array">
64+
<item name="magento_import" xsi:type="string">Magento\Framework\Less\PreProcessor\Instruction\MagentoImport</item>
65+
<item name="import" xsi:type="string">Magento\Framework\Less\PreProcessor\Instruction\Import</item>
66+
</item>
67+
</item>
68+
<item name="css" xsi:type="array">
69+
<item name="css" xsi:type="array">
70+
<item name="module_notation" xsi:type="string">Magento\Framework\View\Asset\PreProcessor\ModuleNotation</item>
71+
</item>
72+
</item>
73+
</argument>
74+
</arguments>
75+
</type>
5576
</config>

0 commit comments

Comments
 (0)