6
6
7
7
namespace Magento \Setup \Test \Unit \Model ;
8
8
9
- use \Magento \Setup \Model \PathBuilder ;
9
+ use \Magento \Setup \Model \BasePackageInfo ;
10
10
11
- class PathBuilderTest extends \PHPUnit_Framework_TestCase
11
+ /**
12
+ * Tests BasePackageInfo
13
+ *
14
+ */
15
+ class BasePackageInfoTest extends \PHPUnit_Framework_TestCase
12
16
{
13
17
/**
14
18
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\FileSystem\Directory\ReadFactory
@@ -21,9 +25,9 @@ class PathBuilderTest extends \PHPUnit_Framework_TestCase
21
25
private $ readerMock ;
22
26
23
27
/**
24
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Model\PathBuilder
28
+ * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Model\BasePackageInfo
25
29
*/
26
- private $ pathBuilder ;
30
+ private $ basePackageInfo ;
27
31
28
32
public function setup ()
29
33
{
@@ -41,43 +45,43 @@ public function setup()
41
45
false
42
46
);
43
47
$ this ->readFactoryMock ->expects ($ this ->once ())->method ('create ' )->willReturn ($ this ->readerMock );
44
- $ this ->pathBuilder = new PathBuilder ($ this ->readFactoryMock );
48
+ $ this ->basePackageInfo = new BasePackageInfo ($ this ->readFactoryMock );
45
49
}
46
50
47
51
// Error scenario: magento/magento2-base/composer.json not found
48
- public function testBuildComposerJsonFileNotFound ()
52
+ public function testBaseComposerJsonFileNotFound ()
49
53
{
50
54
$ this ->readerMock ->expects ($ this ->once ())->method ('isExist ' )->willReturn (false );
51
55
$ this ->readerMock ->expects ($ this ->never ())->method ('isReadable ' );
52
56
$ this ->readerMock ->expects ($ this ->never ())->method ('readFile ' );
53
57
$ this ->setExpectedException (
54
58
'Magento\Setup\Exception ' ,
55
- sprintf ('Could not locate %s file. ' , PathBuilder ::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE )
59
+ sprintf ('Could not locate %s file. ' , BasePackageInfo ::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE )
56
60
);
57
- $ this ->pathBuilder -> build ();
61
+ $ this ->basePackageInfo -> getPaths ();
58
62
}
59
63
60
64
// Error scenario: magento/magento2-base/composer.json file could not be read
61
- public function testBuildComposerJsonFileNotReadable ()
65
+ public function testBaseComposerJsonFileNotReadable ()
62
66
{
63
67
$ this ->readerMock ->expects ($ this ->once ())->method ('isExist ' )->willReturn (true );
64
68
$ this ->readerMock ->expects ($ this ->once ())->method ('isReadable ' )->willReturn (false );
65
69
$ this ->readerMock ->expects ($ this ->never ())->method ('readFile ' );
66
70
$ this ->setExpectedException (
67
71
'Magento\Setup\Exception ' ,
68
- sprintf ('Could not read %s file. ' , PathBuilder ::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE )
72
+ sprintf ('Could not read %s file. ' , BasePackageInfo ::MAGENTO_BASE_PACKAGE_COMPOSER_JSON_FILE )
69
73
);
70
- $ this ->pathBuilder -> build ();
74
+ $ this ->basePackageInfo -> getPaths ();
71
75
}
72
76
73
77
// Scenario: ["extra"]["map"] is absent within magento/magento2-base/composer.json file
74
- public function testBuildNoExtraMapSectionInComposerJsonFile ()
78
+ public function testBaseNoExtraMapSectionInComposerJsonFile ()
75
79
{
76
80
$ this ->readerMock ->expects ($ this ->once ())->method ('isExist ' )->willReturn (true );
77
81
$ this ->readerMock ->expects ($ this ->once ())->method ('isReadable ' )->willReturn (true );
78
82
$ jsonData = json_encode (
79
83
[
80
- PathBuilder ::COMPOSER_KEY_EXTRA =>
84
+ BasePackageInfo ::COMPOSER_KEY_EXTRA =>
81
85
[
82
86
__FILE__ ,
83
87
__FILE__
@@ -86,20 +90,20 @@ public function testBuildNoExtraMapSectionInComposerJsonFile()
86
90
);
87
91
$ this ->readerMock ->expects ($ this ->once ())->method ('readFile ' )->willReturn ($ jsonData );
88
92
$ expectedList = [];
89
- $ actualList = $ this ->pathBuilder -> build ();
93
+ $ actualList = $ this ->basePackageInfo -> getPaths ();
90
94
$ this ->assertEquals ($ expectedList , $ actualList );
91
95
}
92
96
93
97
// Success scenario
94
- public function testBuild ()
98
+ public function testBasePackageInfo ()
95
99
{
96
100
$ this ->readerMock ->expects ($ this ->once ())->method ('isExist ' )->willReturn (true );
97
101
$ this ->readerMock ->expects ($ this ->once ())->method ('isReadable ' )->willReturn (true );
98
102
$ jsonData = json_encode (
99
103
[
100
- PathBuilder ::COMPOSER_KEY_EXTRA =>
104
+ BasePackageInfo ::COMPOSER_KEY_EXTRA =>
101
105
[
102
- PathBuilder ::COMPOSER_KEY_MAP =>
106
+ BasePackageInfo ::COMPOSER_KEY_MAP =>
103
107
[
104
108
[
105
109
__FILE__ ,
@@ -115,7 +119,7 @@ public function testBuild()
115
119
);
116
120
$ this ->readerMock ->expects ($ this ->once ())->method ('readFile ' )->willReturn ($ jsonData );
117
121
$ expectedList = [__FILE__ , __DIR__ ];
118
- $ actualList = $ this ->pathBuilder -> build ();
122
+ $ actualList = $ this ->basePackageInfo -> getPaths ();
119
123
$ this ->assertEquals ($ expectedList , $ actualList );
120
124
}
121
125
}
0 commit comments