File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
dev/tests/static/testsuite/Magento/Test/Legacy
lib/internal/Magento/Framework/App/Response/Http Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 10
10
*/
11
11
namespace Magento \Test \Legacy ;
12
12
13
+ use Magento \Framework \Test \Utility \Files ;
14
+
13
15
class ObsoleteCodeTest extends \PHPUnit_Framework_TestCase
14
16
{
15
17
/**
@@ -129,6 +131,7 @@ function ($file) {
129
131
$ this ->_testObsoleteActions ($ content );
130
132
$ this ->_testObsoleteConstants ($ content );
131
133
$ this ->_testObsoletePropertySkipCalculate ($ content );
134
+ $ this ->checkLibraryDependence ($ content , $ file );
132
135
},
133
136
\Magento \TestFramework \Utility \ChangedFiles::getPhpFiles (__DIR__ . '/_files/changed_files* ' )
134
137
);
@@ -491,6 +494,25 @@ protected function _testObsoletePropertySkipCalculate($content)
491
494
);
492
495
}
493
496
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
+
494
516
/**
495
517
* Analyze contents to determine whether this is declaration of specified class/interface
496
518
*
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ public function create(
67
67
$ isFile = true ;
68
68
$ file = $ content ['value ' ];
69
69
if (!$ dir ->isFile ($ file )) {
70
- throw new \Exception (__ ('File not found ' ));
70
+ throw new \Exception (( string ) new \ Magento \ Framework \ Phrase ('File not found ' ));
71
71
}
72
72
$ contentLength = $ dir ->stat ($ file )['size ' ];
73
73
}
You can’t perform that action at this time.
0 commit comments