Skip to content

Commit 6111657

Browse files
author
olysenko
committed
Merge remote-tracking branch 'mainline/2.2-develop' into MAGETWO-71829
2 parents 208b1ef + 15b3b6c commit 6111657

File tree

10 files changed

+194
-2
lines changed

10 files changed

+194
-2
lines changed

app/code/Magento/Customer/etc/events.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<observer name="customer_address_before_save_viv_observer" instance="Magento\Customer\Observer\BeforeAddressSaveObserver" />
1111
</event>
1212
<event name="customer_address_save_after">
13-
<observer name="customer_addres_after_save_viv_observer" instance="Magento\Customer\Observer\AfterAddressSaveObserver" />
13+
<observer name="customer_address_after_save_viv_observer" instance="Magento\Customer\Observer\AfterAddressSaveObserver" />
1414
</event>
1515
<event name="sales_quote_save_after">
1616
<observer name="customer_visitor" instance="Magento\Customer\Observer\Visitor\BindQuoteCreateObserver" />

app/code/Magento/Customer/view/frontend/web/js/password-strength-indicator.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ define([
3131
this.options.cache.label = $(this.options.passwordStrengthMeterLabelSelector, this.element);
3232

3333
// We need to look outside the module for backward compatibility, since someone can already use the module.
34+
// @todo Narrow this selector in 2.3 so it doesn't accidentally finds the the email field from the
35+
// newsletter email field or any other "email" field.
3436
this.options.cache.email = $(this.options.formSelector).find(this.options.emailSelector);
3537
this._bind();
3638
},
@@ -74,7 +76,9 @@ define([
7476
'password-not-equal-to-user-name': this.options.cache.email.val()
7577
});
7678

77-
if (password.toLowerCase() === this.options.cache.email.val().toLowerCase()) {
79+
// We should only perform this check in case there is an email field on screen
80+
if (this.options.cache.email.length &&
81+
password.toLowerCase() === this.options.cache.email.val().toLowerCase()) {
7882
displayScore = 1;
7983
} else {
8084
isValid = $.validator.validateSingleElement(this.options.cache.input);

app/code/Magento/Tax/view/adminhtml/templates/rule/edit.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ require([
111111

112112
TaxRateEditableMultiselect.prototype.init = function () {
113113
var options = {
114+
mselectContainer: '#tax_rate + section.mselect-list',
114115
toggleAddButton:false,
115116
addText: '<?= /* @escapeNotVerified */ __('Add New Tax Rate') ?>',
116117
parse: null,
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
/***
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Variable\Test\Unit\Model\ResourceModel\Variable;
8+
9+
use Magento\Framework\DB\Adapter\AdapterInterface;
10+
use Magento\Framework\DB\Select;
11+
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
12+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
13+
use Magento\Variable\Model\ResourceModel\Variable\Collection;
14+
use PHPUnit\Framework\TestCase;
15+
16+
/**
17+
* Provide tests for Variable collection class.
18+
*/
19+
class CollectionTest extends TestCase
20+
{
21+
/**
22+
* Test Collection::addValuesToResult() build correct query.
23+
*
24+
* @return void
25+
*/
26+
public function testAddValuesToResult()
27+
{
28+
$mainTableName = 'testMainTable';
29+
$tableName = 'variable_value';
30+
$field = 'value_table.store_id';
31+
32+
$select = $this->getMockBuilder(Select::class)
33+
->disableOriginalConstructor()
34+
->getMock();
35+
$select->expects($this->once())
36+
->method('from')
37+
->with($this->identicalTo(['main_table' => $mainTableName]))
38+
->willReturnSelf();
39+
$select->expects($this->once())
40+
->method('join')
41+
->with(
42+
$this->identicalTo(['value_table' => $tableName]),
43+
$this->identicalTo('value_table.variable_id = main_table.variable_id'),
44+
$this->identicalTo(['value_table.plain_value', 'value_table.html_value'])
45+
)->willReturnSelf();
46+
47+
$connection = $this->getMockBuilder(AdapterInterface::class)
48+
->disableOriginalConstructor()
49+
->setMethods(['select', 'prepareSqlCondition', 'quoteIdentifier'])
50+
->getMockForAbstractClass();
51+
$connection->expects($this->any())
52+
->method('select')
53+
->willReturn($select);
54+
$connection->expects($this->once())
55+
->method('quoteIdentifier')
56+
->with($this->identicalTo($field))
57+
->willReturn($field);
58+
$connection->expects($this->once())
59+
->method('prepareSqlCondition')
60+
->with(
61+
$this->identicalTo($field),
62+
$this->identicalTo(['eq' => 0])
63+
)->willReturn('testResultCondition');
64+
65+
$resource = $this->getMockBuilder(AbstractDb::class)
66+
->setMethods(['getTable', 'getMainTable', 'getConnection'])
67+
->disableOriginalConstructor()
68+
->getMockForAbstractClass();
69+
$resource->expects($this->any())
70+
->method('getConnection')
71+
->willReturn($connection);
72+
$resource->expects($this->once())
73+
->method('getMainTable')
74+
->willReturn('testMainTable');
75+
$resource->expects($this->exactly(2))
76+
->method('getTable')
77+
->withConsecutive(
78+
[$mainTableName],
79+
[$tableName]
80+
)->willReturnOnConsecutiveCalls(
81+
$mainTableName,
82+
$tableName
83+
);
84+
85+
$objectManager = new ObjectManager($this);
86+
$collection = $objectManager->getObject(
87+
Collection::class,
88+
[
89+
'resource' => $resource,
90+
]
91+
);
92+
$this->assertInstanceOf(Collection::class, $collection->addValuesToResult());
93+
}
94+
}

lib/internal/Magento/Framework/Event/ObserverInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
/**
1111
* Interface \Magento\Framework\Event\ObserverInterface
1212
*
13+
* @api
1314
*/
1415
interface ObserverInterface
1516
{

lib/internal/Magento/Framework/Module/Test/Unit/DirTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,17 @@ public function testGetDirModuleSubDirUnknown()
5959

6060
$this->_model->getDir('Test_Module', 'unknown');
6161
}
62+
63+
/**
64+
* @expectedException \InvalidArgumentException
65+
* @expectedExceptionMessage Module 'Test Module' is not correctly registered.
66+
*/
67+
public function testGetDirModuleIncorrectlyRegistered()
68+
{
69+
$this->moduleRegistryMock->expects($this->once())
70+
->method('getPath')
71+
->with($this->identicalTo(ComponentRegistrar::MODULE), $this->identicalTo('Test Module'))
72+
->willReturn(null);
73+
$this->_model->getDir('Test Module');
74+
}
6275
}

lib/internal/Magento/Framework/Setup/Lists.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@ class Lists
2121
*/
2222
protected $allowedLocales;
2323

24+
/**
25+
* List of allowed currencies
26+
*
27+
* @var array
28+
*/
29+
protected $allowedCurrencies;
30+
2431
/**
2532
* @param ConfigInterface $localeConfig
2633
*/
2734
public function __construct(ConfigInterface $localeConfig)
2835
{
2936
$this->allowedLocales = $localeConfig->getAllowedLocales();
37+
$this->allowedCurrencies = $localeConfig->getAllowedCurrencies();
3038
}
3139

3240
/**
@@ -64,6 +72,10 @@ public function getCurrencyList()
6472
$currencies = (new CurrencyBundle())->get(Resolver::DEFAULT_LOCALE)['Currencies'];
6573
$list = [];
6674
foreach ($currencies as $code => $data) {
75+
$isAllowedCurrency = array_search($code, $this->allowedCurrencies) !== false;
76+
if (!$isAllowedCurrency) {
77+
continue;
78+
}
6779
$list[$code] = $data[1] . ' (' . $code . ')';
6880
}
6981
asort($list);

pub/static/.htaccess

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ Options -MultiViews
1212
<IfModule mod_rewrite.c>
1313
RewriteEngine On
1414

15+
## you can put here your pub/static folder path relative to web root
16+
#RewriteBase /magento/pub/static/
17+
1518
# Remove signature of the static files that is used to overcome the browser cache
1619
RewriteRule ^version.+?/(.+)$ $1 [L]
1720

setup/src/Magento/Setup/Console/Command/MaintenanceAllowIpsCommand.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class MaintenanceAllowIpsCommand extends AbstractSetupCommand
2424
*/
2525
const INPUT_KEY_IP = 'ip';
2626
const INPUT_KEY_NONE = 'none';
27+
const INPUT_KEY_ADD = 'add';
2728

2829
/**
2930
* @var MaintenanceMode
@@ -69,6 +70,12 @@ protected function configure()
6970
InputOption::VALUE_NONE,
7071
'Clear allowed IP addresses'
7172
),
73+
new InputOption(
74+
self::INPUT_KEY_ADD,
75+
null,
76+
InputOption::VALUE_NONE,
77+
'Add the IP address to existing list'
78+
),
7279
];
7380
$this->setName('maintenance:allow-ips')
7481
->setDescription('Sets maintenance mode exempt IPs')
@@ -91,6 +98,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
9198
}
9299

93100
if (!empty($addresses)) {
101+
if ($input->getOption(self::INPUT_KEY_ADD)) {
102+
$addresses = array_unique(array_merge($this->maintenanceMode->getAddressInfo(), $addresses));
103+
}
94104
$this->maintenanceMode->setAddresses(implode(',', $addresses));
95105
$output->writeln(
96106
'<info>Set exempt IP-addresses: ' . implode(' ', $this->maintenanceMode->getAddressInfo()) .

setup/src/Magento/Setup/Test/Unit/Console/Command/MaintenanceAllowIpsCommandTest.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,33 @@ public function testExecute(array $input, array $validatorMessages, $expectedMes
6666
$this->assertEquals($expectedMessage, $tester->getDisplay());
6767
}
6868

69+
/**
70+
* @param array $addressInfo
71+
* @param array $input
72+
* @param array $validatorMessages
73+
* @param string $expectedMessage
74+
* @dataProvider executeWithAddDataProvider
75+
*/
76+
public function testExecuteWithAdd(array $addressInfo, array $input, array $validatorMessages, $expectedMessage)
77+
{
78+
$newAddressInfo = array_unique(array_merge($addressInfo, $input['ip']));
79+
80+
$this->ipValidator->expects($this->once())->method('validateIps')->willReturn($validatorMessages);
81+
$this->maintenanceMode
82+
->expects($this->once())
83+
->method('setAddresses')
84+
->with(implode(',', $newAddressInfo));
85+
86+
$this->maintenanceMode
87+
->expects($this->exactly(2))
88+
->method('getAddressInfo')
89+
->willReturnOnConsecutiveCalls($addressInfo, $newAddressInfo);
90+
91+
$tester = new CommandTester($this->command);
92+
$tester->execute($input);
93+
$this->assertEquals($expectedMessage, $tester->getDisplay());
94+
}
95+
6996
/**
7097
* return array
7198
*/
@@ -99,4 +126,31 @@ public function executeDataProvider()
99126
]
100127
];
101128
}
129+
130+
/**
131+
* return array
132+
*/
133+
public function executeWithAddDataProvider()
134+
{
135+
return [
136+
[
137+
[],
138+
['ip' => ['127.0.0.1'], '--add' => true],
139+
[],
140+
'Set exempt IP-addresses: 127.0.0.1' . PHP_EOL,
141+
],
142+
[
143+
['127.0.0.1'],
144+
['ip' => ['127.0.0.1'], '--add' => true],
145+
[],
146+
'Set exempt IP-addresses: 127.0.0.1' . PHP_EOL,
147+
],
148+
[
149+
['127.0.0.1'],
150+
['ip' => ['127.0.0.2'], '--add' => true],
151+
[],
152+
'Set exempt IP-addresses: 127.0.0.1 127.0.0.2' . PHP_EOL,
153+
],
154+
];
155+
}
102156
}

0 commit comments

Comments
 (0)