12
12
use Magento \Catalog \Model \Category as CategoryModel ;
13
13
use Magento \Catalog \Model \ResourceModel \Category as CategoryResource ;
14
14
use Magento \Catalog \Model \ResourceModel \Category \Collection as CategoryCollection ;
15
+ use Magento \Catalog \Model \ResourceModel \Category \CollectionFactory as CategoryCollectionFactory ;
15
16
use Magento \Framework \App \Filesystem \DirectoryList ;
16
17
use Magento \Framework \Filesystem ;
17
18
use Magento \Framework \Filesystem \Directory \WriteInterface ;
@@ -64,7 +65,7 @@ protected function setUp(): void
64
65
$ this ->categoryRepository = $ this ->objectManager ->get (CategoryRepositoryInterface::class);
65
66
$ this ->categoryResource = $ this ->objectManager ->get (CategoryResource::class);
66
67
$ this ->storeManager = $ this ->objectManager ->get (StoreManagerInterface::class);
67
- $ this ->categoryCollection = $ this ->objectManager ->get (CategoryCollection ::class);
68
+ $ this ->categoryCollection = $ this ->objectManager ->get (CategoryCollectionFactory ::class)-> create ( );
68
69
$ this ->filesystem = $ this ->objectManager ->get (Filesystem::class);
69
70
$ this ->mediaDirectory = $ this ->filesystem ->getDirectoryWrite (DirectoryList::MEDIA );
70
71
}
@@ -92,8 +93,8 @@ public function testAddImageForCategory(): void
92
93
'type ' => 'image/jpg ' ,
93
94
'tmp_name ' => '/tmp/phpDstnAx ' ,
94
95
'file ' => 'magento_small_image.jpg ' ,
96
+ 'url ' => $ this ->prepareDataImageUrl ('magento_small_image.jpg ' ),
95
97
];
96
- $ this ->prepareDataImageUrl ($ dataImage );
97
98
$ imageRelativePath = self ::BASE_PATH . DIRECTORY_SEPARATOR . $ dataImage ['file ' ];
98
99
$ expectedImage = DIRECTORY_SEPARATOR . $ this ->storeManager ->getStore ()->getBaseMediaDir ()
99
100
. DIRECTORY_SEPARATOR . $ imageRelativePath ;
@@ -116,14 +117,14 @@ public function testAddImageForCategory(): void
116
117
}
117
118
118
119
/**
119
- * Add image url to image data
120
+ * Prepare image url for image data
120
121
*
121
- * @param array $dataImage
122
- * @return void
122
+ * @param string $file
123
+ * @return string
123
124
*/
124
- private function prepareDataImageUrl (array & $ dataImage ): void
125
+ private function prepareDataImageUrl (string $ file ): string
125
126
{
126
- $ dataImage [ ' url ' ] = $ this ->storeManager ->getStore ()->getBaseUrl (UrlInterface::URL_TYPE_MEDIA )
127
- . self ::BASE_TMP_PATH . DIRECTORY_SEPARATOR . $ dataImage [ ' file ' ] ;
127
+ return $ this ->storeManager ->getStore ()->getBaseUrl (UrlInterface::URL_TYPE_MEDIA )
128
+ . self ::BASE_TMP_PATH . DIRECTORY_SEPARATOR . $ file ;
128
129
}
129
130
}
0 commit comments