@@ -119,9 +119,7 @@ public function createMediaDocuments(TableNode $table): void {
119119 // Retrieve the url table from the test scenario.
120120 $ files = $ table ->getColumnsHash ();
121121 foreach ($ files as $ properties ) {
122- $ file_name = basename ($ properties ['file ' ]);
123- $ file_path = strpos ($ properties ['file ' ], '/ ' ) ? dirname ($ properties ['file ' ]) . '/ ' : '' ;
124- $ file = $ this ->createFileEntity ($ file_name , $ file_path );
122+ $ file = $ this ->createFileEntity ($ properties ['file ' ]);
125123 $ media = \Drupal::entityTypeManager ()
126124 ->getStorage ('media ' )->create ([
127125 'bundle ' => 'document ' ,
@@ -157,9 +155,7 @@ public function createMediaImages(TableNode $table): void {
157155 // Retrieve the url table from the test scenario.
158156 $ files = $ table ->getColumnsHash ();
159157 foreach ($ files as $ properties ) {
160- $ file_name = basename ($ properties ['file ' ]);
161- $ file_path = strpos ($ properties ['file ' ], '/ ' ) ? dirname ($ properties ['file ' ]) . '/ ' : '' ;
162- $ file = $ this ->createFileEntity ($ file_name , $ file_path );
158+ $ file = $ this ->createFileEntity ($ properties ['file ' ]);
163159 $ media = \Drupal::entityTypeManager ()
164160 ->getStorage ('media ' )->create ([
165161 'bundle ' => 'image ' ,
@@ -268,14 +264,12 @@ protected function getConfigContext(): ConfigContext {
268264 *
269265 * @param string $file_name
270266 * File name, relative to Mink 'files_path' location.
271- * @param string $path
272- * The relative file path.
273267 *
274268 * @return \Drupal\file\FileInterface
275269 * File entity object.
276270 */
277- protected function createFileEntity (string $ file_name, string $ path = '' ): FileInterface {
278- $ file = file_save_data (file_get_contents ($ this ->getMinkParameter ('files_path ' ) . $ path . $ file_name ), 'public:// ' . $ file_name );
271+ protected function createFileEntity (string $ file_name ): FileInterface {
272+ $ file = file_save_data (file_get_contents ($ this ->getMinkParameter ('files_path ' ) . $ file_name ), 'public:// ' . basename ( $ file_name) );
279273 $ file ->setPermanent ();
280274 $ file ->save ();
281275
0 commit comments