File tree Expand file tree Collapse file tree 2 files changed +22
-22
lines changed
dev/tests/static/testsuite/Magento/Test Expand file tree Collapse file tree 2 files changed +22
-22
lines changed Original file line number Diff line number Diff line change 6
6
namespace Magento \Test \Integrity \Library ;
7
7
8
8
use Magento \Framework \Test \Utility \Files ;
9
+ use Magento \Framework \Test \Utility \AggregateInvoker ;
9
10
use Magento \TestFramework \Integrity \Library \Injectable ;
10
11
use Magento \TestFramework \Integrity \Library \PhpParser \ParserFactory ;
11
12
use Magento \TestFramework \Integrity \Library \PhpParser \Tokens ;
@@ -67,6 +68,27 @@ function ($file) {
67
68
);
68
69
}
69
70
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
+
70
92
/**
71
93
* @inheritdoc
72
94
*/
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
-
15
13
class ObsoleteCodeTest extends \PHPUnit_Framework_TestCase
16
14
{
17
15
/**
@@ -131,7 +129,6 @@ function ($file) {
131
129
$ this ->_testObsoleteActions ($ content );
132
130
$ this ->_testObsoleteConstants ($ content );
133
131
$ this ->_testObsoletePropertySkipCalculate ($ content );
134
- $ this ->checkLibraryDependence ($ content , $ file );
135
132
},
136
133
\Magento \TestFramework \Utility \ChangedFiles::getPhpFiles (__DIR__ . '/_files/changed_files* ' )
137
134
);
@@ -494,25 +491,6 @@ protected function _testObsoletePropertySkipCalculate($content)
494
491
);
495
492
}
496
493
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
-
516
494
/**
517
495
* Analyze contents to determine whether this is declaration of specified class/interface
518
496
*
You can’t perform that action at this time.
0 commit comments