File tree Expand file tree Collapse file tree 2 files changed +12
-19
lines changed
Test/Unit/Module/Di/Code/Reader Expand file tree Collapse file tree 2 files changed +12
-19
lines changed Original file line number Diff line number Diff line change @@ -33,28 +33,16 @@ class ClassesScanner implements ClassesScannerInterface
33
33
* @param string $generationDirectory
34
34
*/
35
35
36
- public function __construct (array $ excludePatterns = [], $ generationDirectory = null )
36
+ public function __construct (array $ excludePatterns = [], DirectoryList $ directoryList = null )
37
37
{
38
38
$ this ->excludePatterns = $ excludePatterns ;
39
- $ this ->generationDirectory = $ generationDirectory ;
40
- }
41
-
42
- /**
43
- * Retrieves the fully qualified path for var/generation.
44
- *
45
- * @return string
46
- */
47
-
48
- public function getGenerationDirectory ()
49
- {
50
- if ($ this ->generationDirectory === null ) {
39
+ if (!$ directoryList instanceof DirectoryList) {
51
40
$ directoryList = ObjectManager::getInstance ()->get (DirectoryList::class);
52
- /* @var $directoryList DirectoryList */
53
- $ this ->generationDirectory = $ directoryList ->getPath (DirectoryList::GENERATION );
54
41
}
55
- return $ this ->generationDirectory ;
42
+ $ this ->generationDirectory = $ directoryList -> getPath (DirectoryList:: GENERATION ) ;
56
43
}
57
44
45
+
58
46
/**
59
47
* Adds exclude patterns
60
48
*
@@ -75,8 +63,7 @@ public function addExcludePatterns(array $excludePatterns)
75
63
76
64
public function isGeneration ($ path )
77
65
{
78
- $ generation = $ this ->getGenerationDirectory ();
79
- return strpos ($ path , $ generation ) === 0 ;
66
+ return strpos ($ path , $ this ->generationDirectory ) === 0 ;
80
67
}
81
68
82
69
/**
Original file line number Diff line number Diff line change 5
5
*/
6
6
namespace Magento \Setup \Test \Unit \Module \Di \Code \Reader ;
7
7
8
+ use Magento \Framework \App \Filesystem \DirectoryList ;
9
+
8
10
class ClassesScannerTest extends \PHPUnit_Framework_TestCase
9
11
{
10
12
/**
@@ -23,7 +25,11 @@ class ClassesScannerTest extends \PHPUnit_Framework_TestCase
23
25
protected function setUp ()
24
26
{
25
27
$ this ->generation = realpath (__DIR__ . '/../../_files/var/generation ' );
26
- $ this ->model = new \Magento \Setup \Module \Di \Code \Reader \ClassesScanner ([], $ this ->generation );
28
+ $ mock = $ this ->getMockBuilder (DirectoryList::class)->disableOriginalConstructor ()->setMethods (
29
+ ['getPath ' ]
30
+ )->getMock ();
31
+ $ mock ->method ('getPath ' )->willReturn ($ this ->generation );
32
+ $ this ->model = new \Magento \Setup \Module \Di \Code \Reader \ClassesScanner ([], $ mock );
27
33
}
28
34
29
35
public function testGetList ()
You can’t perform that action at this time.
0 commit comments