Skip to content

Commit a591602

Browse files
committed
MC-17868: Break jQuery UI into widgets and make a prototype
- Fix code style for static tests;
1 parent 114b4e0 commit a591602

File tree

3 files changed

+38
-22
lines changed

3 files changed

+38
-22
lines changed

dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteCodeTest.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,11 @@ public function testJsFiles()
184184
function ($file) {
185185
$content = file_get_contents($file);
186186
$this->_testObsoletePropertySkipCalculate($content);
187-
if (!strpos($file, 'requirejs-config.js')
188-
&& (strpos($file, '/view/frontend/web/') || strpos($file, '/view/base/web/'))
187+
if (strpos($file, 'requirejs-config.js') === false
188+
&& (
189+
strpos($file, '/view/frontend/web/') !== false
190+
|| strpos($file, '/view/base/web/') !== false
191+
)
189192
) {
190193
$this->_testJqueryUiLibraryIsNotUsedInJs($content);
191194
}
@@ -708,14 +711,16 @@ private function _checkCompletePathOfClass(
708711
}
709712
$pathWithConstParts = explode('\\', $pathWithConst);
710713
$pathInUseNamespace = trim($matchClassString['classPath'], '\\');
711-
$pathInUseNamespaceTruncated = trim(trim(
712-
preg_replace(
713-
'/' . preg_quote($pathWithConstParts[0]) . '$/',
714-
'',
715-
$pathInUseNamespace
716-
),
717-
'\\'
718-
));
714+
$pathInUseNamespaceTruncated = trim(
715+
trim(
716+
preg_replace(
717+
'/' . preg_quote($pathWithConstParts[0]) . '$/',
718+
'',
719+
$pathInUseNamespace
720+
),
721+
'\\'
722+
)
723+
);
719724
if ($this->_checkClasspathProperDivisionNoConstantPath(
720725
$pathInUseNamespaceTruncated,
721726
$pathInUseNamespace,
@@ -963,7 +968,10 @@ private function _testJqueryUiLibraryIsNotUsedInJs($fileContent)
963968
$this->_assertNotRegexp(
964969
'/(["\'])jquery\/ui\1/',
965970
$fileContent,
966-
$this->_suggestReplacement(sprintf("Dependency '%s' is redundant.", 'jquery/ui'), 'Use separate jquery ui widget instead of all library.')
971+
$this->_suggestReplacement(
972+
sprintf("Dependency '%s' is redundant.", 'jquery/ui'),
973+
'Use separate jquery ui widget instead of all library.'
974+
)
967975
);
968976
}
969977
}

dev/tests/static/testsuite/Magento/Test/Legacy/PhtmlTemplateTest.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*/
88
namespace Magento\Test\Legacy;
99

10+
/**
11+
* Static test for phtml template files.
12+
*/
1013
class PhtmlTemplateTest extends \PHPUnit\Framework\TestCase
1114
{
1215
public function testBlockVariableInsteadOfThis()
@@ -19,7 +22,7 @@ public function testBlockVariableInsteadOfThis()
1922
* @param string $file
2023
*/
2124
function ($file) {
22-
$this->assertNotRegExp(
25+
self::assertNotRegExp(
2326
'/this->(?!helper)\S*/iS',
2427
file_get_contents($file),
2528
'Access to members and methods of Block class through $this is ' .
@@ -46,7 +49,7 @@ public function testObsoleteBlockMethods()
4649
* @param string $file
4750
*/
4851
function ($file) {
49-
$this->assertNotRegexp(
52+
self::assertNotRegexp(
5053
'/block->_[^_]+\S*\(/iS',
5154
file_get_contents($file),
5255
'Access to protected and private members of Block class is ' .
@@ -68,7 +71,7 @@ public function testObsoleteJavascriptAttributeType()
6871
* @param string $file
6972
*/
7073
function ($file) {
71-
$this->assertNotRegexp(
74+
self::assertNotRegexp(
7275
'/type="text\/javascript"/',
7376
file_get_contents($file),
7477
'Please do not use "text/javascript" type attribute.'
@@ -82,15 +85,17 @@ public function testJqueryUiLibraryIsNotUsedInTemplates()
8285
{
8386
$invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
8487
$invoker(
85-
/**
86-
* 'jquery/ui' library is not obligatory to use in phtml files.
87-
* It's better to use needed jquery ui widget instead.
88-
*
89-
* @param string $file
90-
*/
88+
/**
89+
* 'jquery/ui' library is not obligatory to use in phtml files.
90+
* It's better to use needed jquery ui widget instead.
91+
*
92+
* @param string $file
93+
*/
9194
function ($file) {
92-
if (strpos($file, '/view/frontend/templates/') || strpos($file, '/view/base/templates/')) {
93-
$this->assertNotRegexp(
95+
if (strpos($file, '/view/frontend/templates/') !== false
96+
|| strpos($file, '/view/base/templates/') !== false
97+
) {
98+
self::assertNotRegexp(
9499
'/(["\'])jquery\/ui\1/',
95100
file_get_contents($file),
96101
'Please do not use "jquery/ui" library in templates. Use needed jquery ui widget instead.'

lib/internal/Magento/Framework/Data/Form/Element/Editablemultiselect.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
use Magento\Framework\Escaper;
1717

18+
/**
19+
* Form editable multiselect element.
20+
*/
1821
class Editablemultiselect extends \Magento\Framework\Data\Form\Element\Multiselect
1922
{
2023
/**

0 commit comments

Comments
 (0)