Skip to content

Commit 643187a

Browse files
author
Yuri Kovsher
committed
MAGETWO-33063: Replace usage of __() to Phrase object in library
1 parent 6540495 commit 643187a

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

dev/tests/static/testsuite/Magento/Test/Integrity/Library/DependencyTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Test\Integrity\Library;
77

88
use Magento\Framework\Test\Utility\Files;
9+
use Magento\Framework\Test\Utility\AggregateInvoker;
910
use Magento\TestFramework\Integrity\Library\Injectable;
1011
use Magento\TestFramework\Integrity\Library\PhpParser\ParserFactory;
1112
use Magento\TestFramework\Integrity\Library\PhpParser\Tokens;
@@ -67,6 +68,27 @@ function ($file) {
6768
);
6869
}
6970

71+
public function testAppCodeUsage()
72+
{
73+
$files = Files::init();
74+
$path = $files->getPathToSource();
75+
$invoker = new AggregateInvoker($this);
76+
$invoker(
77+
function ($file) use ($path) {
78+
$content = file_get_contents($file);
79+
if (strpos($file, $path . '/lib/') === 0) {
80+
$this->assertSame(
81+
0,
82+
preg_match('~(?<![a-z\\d_:]|->|function\\s)__\\s*\\(~iS', $content),
83+
'Function __() is defined outside of the library and must not be used there. ' .
84+
'Replacement suggestion: new \\Magento\\Framework\\Phrase()'
85+
);
86+
}
87+
},
88+
$files->getPhpFiles(false, true, false)
89+
);
90+
}
91+
7092
/**
7193
* @inheritdoc
7294
*/

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
*/
1111
namespace Magento\Test\Legacy;
1212

13-
use Magento\Framework\Test\Utility\Files;
14-
1513
class ObsoleteCodeTest extends \PHPUnit_Framework_TestCase
1614
{
1715
/**
@@ -131,7 +129,6 @@ function ($file) {
131129
$this->_testObsoleteActions($content);
132130
$this->_testObsoleteConstants($content);
133131
$this->_testObsoletePropertySkipCalculate($content);
134-
$this->checkLibraryDependence($content, $file);
135132
},
136133
\Magento\TestFramework\Utility\ChangedFiles::getPhpFiles(__DIR__ . '/_files/changed_files*')
137134
);
@@ -494,25 +491,6 @@ protected function _testObsoletePropertySkipCalculate($content)
494491
);
495492
}
496493

497-
/**
498-
* Checks that library is not using app defined code
499-
*
500-
* @param string $content
501-
* @param string $file
502-
*/
503-
protected function checkLibraryDependence($content, $file)
504-
{
505-
$path = Files::init()->getPathToSource();
506-
if (strpos($file, $path . '/lib/') === 0) {
507-
$this->_assertNotRegexp(
508-
'~(?<![a-z\\d_:]|->|function\\s)__\\s*\\(~iS',
509-
$content,
510-
'Function __() is defined outside of the library and must not be used there. ' .
511-
'Replacement suggestion: new \\Magento\\Framework\\Phrase()'
512-
);
513-
}
514-
}
515-
516494
/**
517495
* Analyze contents to determine whether this is declaration of specified class/interface
518496
*

0 commit comments

Comments
 (0)