public function testBeforeSave() { $value = 'filename.jpg'; $tmpMediaPath = 'tmp/design/file/' . $value; $this->fileBackend->setScope('store'); $this->fileBackend->setScopeId(1); $this->fileBackend->setValue([['url' => 'http://magento2.com/pub/media/tmp/image/' . $value, 'file' => $value, 'size' => 234234]]); $this->fileBackend->setFieldConfig(['upload_dir' => ['value' => 'value', 'config' => 'system/filesystem/media']]); $this->mediaDirectory->expects($this->once())->method('copyFile')->with($tmpMediaPath, '/' . $value)->willReturn(true); $this->mediaDirectory->expects($this->once())->method('delete')->with($tmpMediaPath); $this->fileBackend->beforeSave(); $this->assertEquals('filename.jpg', $this->fileBackend->getValue()); }