@@ -82,37 +82,59 @@ public function testGetImagesJson()
82
82
['file_1.jpg ' , 'catalog/product/image_1.jpg ' ],
83
83
['file_2.jpg ' , 'catalog/product/image_2.jpg ' ]
84
84
];
85
- // @codingStandardsIgnoreStart
86
- $ encodedString = '[{"value_id":"1","file":"image_1.jpg","media_type":"image","url":"http:\/\/magento2.dev\/pub\/media\/catalog\/product\/image_1.jpg","size":879394},{"value_id":"2","file":"image_2.jpg","media_type":"image","url":"http:\/\/magento2.dev\/pub\/media\/catalog\/product\/image`_2.jpg","size":399659}] ' ;
87
- // @codingStandardsIgnoreEnd
85
+
86
+ $ sizeMap = [
87
+ ['catalog/product/image_1.jpg ' , ['size ' => 399659 ]],
88
+ ['catalog/product/image_2.jpg ' , ['size ' => 879394 ]]
89
+ ];
90
+
91
+ $ imagesResult = [
92
+ [
93
+ 'value_id ' => '2 ' ,
94
+ 'file ' => 'file_2.jpg ' ,
95
+ 'media_type ' => 'image ' ,
96
+ 'position ' => '0 ' ,
97
+ 'url ' => 'url_to_the_image/image_2.jpg ' ,
98
+ 'size ' => 879394
99
+ ],
100
+ [
101
+ 'value_id ' => '1 ' ,
102
+ 'file ' => 'file_1.jpg ' ,
103
+ 'media_type ' => 'image ' ,
104
+ 'position ' => '1 ' ,
105
+ 'url ' => 'url_to_the_image/image_1.jpg ' ,
106
+ 'size ' => 399659
107
+ ]
108
+ ];
109
+
88
110
$ images = [
89
111
'images ' => [
90
112
[
91
113
'value_id ' => '1 ' ,
92
114
'file ' => 'file_1.jpg ' ,
93
115
'media_type ' => 'image ' ,
116
+ 'position ' => '1 '
94
117
] ,
95
118
[
96
119
'value_id ' => '2 ' ,
97
120
'file ' => 'file_2.jpg ' ,
98
121
'media_type ' => 'image ' ,
122
+ 'position ' => '0 '
99
123
]
100
124
]
101
125
];
102
- $ firstStat = ['size ' => 879394 ];
103
- $ secondStat = ['size ' => 399659 ];
126
+
104
127
$ this ->content ->setElement ($ this ->galleryMock );
105
- $ this ->galleryMock ->expects ($ this ->any ())->method ('getImages ' )->willReturn ($ images );
128
+ $ this ->galleryMock ->expects ($ this ->once ())->method ('getImages ' )->willReturn ($ images );
106
129
$ this ->fileSystemMock ->expects ($ this ->once ())->method ('getDirectoryRead ' )->willReturn ($ this ->readMock );
107
130
108
131
$ this ->mediaConfigMock ->expects ($ this ->any ())->method ('getMediaUrl ' )->willReturnMap ($ url );
109
- $ this ->mediaConfigMock ->expects ($ this ->any ())->method ('getMediaPath ' )->willReturn ($ mediaPath );
132
+ $ this ->mediaConfigMock ->expects ($ this ->any ())->method ('getMediaPath ' )->willReturnMap ($ mediaPath );
110
133
111
- $ this ->readMock ->expects ($ this ->at (0 ))->method ('stat ' )->willReturn ($ firstStat );
112
- $ this ->readMock ->expects ($ this ->at (1 ))->method ('stat ' )->willReturn ($ secondStat );
113
- $ this ->jsonEncoderMock ->expects ($ this ->once ())->method ('encode ' )->willReturn ($ encodedString );
134
+ $ this ->readMock ->expects ($ this ->any ())->method ('stat ' )->willReturnMap ($ sizeMap );
135
+ $ this ->jsonEncoderMock ->expects ($ this ->once ())->method ('encode ' )->willReturnCallback ('json_encode ' );
114
136
115
- $ this ->assertSame ($ encodedString , $ this ->content ->getImagesJson ());
137
+ $ this ->assertSame (json_encode ( $ imagesResult ) , $ this ->content ->getImagesJson ());
116
138
}
117
139
118
140
public function testGetImagesJsonWithoutImages ()
0 commit comments