10
10
use Magento \Framework \Composer \ComposerInformation ;
11
11
use Magento \Setup \Model \PackagesData ;
12
12
use PHPUnit_Framework_MockObject_MockObject as MockObject ;
13
- use Magento \Setup \Model \Grid \TypeMapper ;
14
13
15
14
/**
16
15
* Tests Magento\Setup\Model\PackagesData
@@ -23,44 +22,9 @@ class PackagesDataTest extends \PHPUnit_Framework_TestCase
23
22
*/
24
23
private $ packagesData ;
25
24
26
- /**
27
- * @var ComposerInformation|MockObject
28
- */
29
- private $ composerInformation ;
30
-
31
25
public function setUp ()
32
26
{
33
- $ this ->composerInformation = $ this ->getMock (ComposerInformation::class, [], [], '' , false );
34
- $ this ->composerInformation ->expects ($ this ->any ())->method ('getInstalledMagentoPackages ' )->willReturn (
35
- [
36
- 'magento/package-1 ' => [
37
- 'name ' => 'magento/package-1 ' ,
38
- 'type ' => 'magento2-module ' ,
39
- 'version ' => '1.0.0 '
40
- ],
41
- 'magento/package-2 ' => [
42
- 'name ' => 'magento/package-2 ' ,
43
- 'type ' => 'magento2-module ' ,
44
- 'version ' => '1.0.1 '
45
- ]
46
- ]
47
- );
48
-
49
- $ this ->composerInformation ->expects ($ this ->any ())->method ('getRootRepositories ' )
50
- ->willReturn (['repo1 ' , 'repo2 ' ]);
51
- $ this ->composerInformation ->expects ($ this ->any ())->method ('getPackagesTypes ' )
52
- ->willReturn (['magento2-module ' ]);
53
- $ rootPackage = $ this ->getMock (RootPackage::class, [], ['magento/project ' , '2.1.0 ' , '2 ' ]);
54
- $ rootPackage ->expects ($ this ->any ())
55
- ->method ('getRequires ' )
56
- ->willReturn ([
57
- 'magento/package-1 ' => '1.0.0 ' ,
58
- 'magento/package-2 ' => '1.0.1 '
59
- ]);
60
- $ this ->composerInformation
61
- ->expects ($ this ->any ())
62
- ->method ('getRootPackage ' )
63
- ->willReturn ($ rootPackage );
27
+ $ composerInformation = $ this ->getComposerInformation ();
64
28
$ timeZoneProvider = $ this ->getMock (\Magento \Setup \Model \DateTime \TimeZoneProvider::class, [], [], '' , false );
65
29
$ timeZone = $ this ->getMock (\Magento \Framework \Stdlib \DateTime \Timezone::class, [], [], '' , false );
66
30
$ timeZoneProvider ->expects ($ this ->any ())->method ('get ' )->willReturn ($ timeZone );
@@ -117,18 +81,17 @@ public function setUp()
117
81
. '}}} '
118
82
);
119
83
120
- $ typeMapper = $ this ->getMockBuilder (TypeMapper::class)
84
+ $ typeMapper = $ this ->getMockBuilder (\ Magento \ Setup \ Model \ Grid \ TypeMapper::class)
121
85
->disableOriginalConstructor ()
122
86
->getMock ();
123
87
$ typeMapper ->expects (static ::any ())
124
88
->method ('map ' )
125
89
->willReturnMap ([
126
- [ComposerInformation::MODULE_PACKAGE_TYPE , TypeMapper::MODULE_PACKAGE_TYPE ],
90
+ [ComposerInformation::MODULE_PACKAGE_TYPE , \ Magento \ Setup \ Model \ Grid \ TypeMapper::MODULE_PACKAGE_TYPE ],
127
91
]);
128
92
129
-
130
93
$ this ->packagesData = new PackagesData (
131
- $ this -> composerInformation ,
94
+ $ composerInformation ,
132
95
$ timeZoneProvider ,
133
96
$ packagesAuth ,
134
97
$ filesystem ,
@@ -137,6 +100,45 @@ public function setUp()
137
100
);
138
101
}
139
102
103
+ /**
104
+ * @return ComposerInformation|MockObject
105
+ */
106
+ private function getComposerInformation ()
107
+ {
108
+ $ composerInformation = $ this ->getMock (ComposerInformation::class, [], [], '' , false );
109
+ $ composerInformation ->expects ($ this ->any ())->method ('getInstalledMagentoPackages ' )->willReturn (
110
+ [
111
+ 'magento/package-1 ' => [
112
+ 'name ' => 'magento/package-1 ' ,
113
+ 'type ' => 'magento2-module ' ,
114
+ 'version ' => '1.0.0 '
115
+ ],
116
+ 'magento/package-2 ' => [
117
+ 'name ' => 'magento/package-2 ' ,
118
+ 'type ' => 'magento2-module ' ,
119
+ 'version ' => '1.0.1 '
120
+ ]
121
+ ]
122
+ );
123
+
124
+ $ composerInformation ->expects ($ this ->any ())->method ('getRootRepositories ' )
125
+ ->willReturn (['repo1 ' , 'repo2 ' ]);
126
+ $ composerInformation ->expects ($ this ->any ())->method ('getPackagesTypes ' )
127
+ ->willReturn (['magento2-module ' ]);
128
+ $ rootPackage = $ this ->getMock (RootPackage::class, [], ['magento/project ' , '2.1.0 ' , '2 ' ]);
129
+ $ rootPackage ->expects ($ this ->any ())
130
+ ->method ('getRequires ' )
131
+ ->willReturn ([
132
+ 'magento/package-1 ' => '1.0.0 ' ,
133
+ 'magento/package-2 ' => '1.0.1 '
134
+ ]);
135
+ $ composerInformation ->expects ($ this ->any ())
136
+ ->method ('getRootPackage ' )
137
+ ->willReturn ($ rootPackage );
138
+
139
+ return $ composerInformation ;
140
+ }
141
+
140
142
public function testSyncPackagesData ()
141
143
{
142
144
$ latestData = $ this ->packagesData ->syncPackagesData ();
0 commit comments