13
13
use Magento \Framework \App \Config \ScopeConfigInterface ;
14
14
use Magento \Framework \Data \Collection \AbstractDb ;
15
15
use Magento \Framework \Filesystem ;
16
- use Magento \Framework \Filesystem \Io \File ;
16
+ use Magento \Framework \Filesystem \Io \File as IoFile ;
17
17
use Magento \Framework \Model \Context ;
18
18
use Magento \Framework \Model \ResourceModel \AbstractResource ;
19
19
use Magento \Framework \Registry ;
20
20
use Magento \Framework \UrlInterface ;
21
21
use Magento \MediaStorage \Helper \File \Storage \Database ;
22
22
use Magento \MediaStorage \Model \File \UploaderFactory ;
23
23
use Magento \Theme \Model \Design \Backend \Image ;
24
- use PHPUnit_Framework_MockObject_MockObject ;
24
+ use Magento \ Framework \ Filesystem \ Directory \ ReadFactory ;
25
25
26
26
/**
27
27
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -31,9 +31,14 @@ class ImageTest extends \PHPUnit\Framework\TestCase
31
31
/** @var Image */
32
32
private $ imageBackend ;
33
33
34
- /** @var File */
34
+ /** @var IoFile */
35
35
private $ ioFileSystem ;
36
36
37
+ /**
38
+ * @var ReadFactory||\PHPUnit_Framework_MockObject_MockObject
39
+ */
40
+ private $ tmpDirectory ;
41
+
37
42
/**
38
43
* @inheritdoc
39
44
*/
@@ -50,7 +55,9 @@ public function setUp()
50
55
$ databaseHelper = $ this ->getMockObject (Database::class);
51
56
$ abstractResource = $ this ->getMockObject (AbstractResource::class);
52
57
$ abstractDb = $ this ->getMockObject (AbstractDb::class);
53
- $ this ->ioFileSystem = $ this ->getMockObject (File::class);
58
+ $ this ->ioFileSystem = $ this ->getMockObject (IoFile::class);
59
+ $ this ->tmpDirectory = $ this ->getMockObject (ReadFactory::class);
60
+
54
61
$ this ->imageBackend = new Image (
55
62
$ context ,
56
63
$ registry ,
@@ -64,7 +71,8 @@ public function setUp()
64
71
$ abstractDb ,
65
72
[],
66
73
$ databaseHelper ,
67
- $ this ->ioFileSystem
74
+ $ this ->ioFileSystem ,
75
+ $ this ->tmpDirectory
68
76
);
69
77
}
70
78
@@ -79,9 +87,9 @@ public function tearDown()
79
87
/**
80
88
* @param string $class
81
89
* @param array $methods
82
- * @return PHPUnit_Framework_MockObject_MockObject
90
+ * @return \ PHPUnit_Framework_MockObject_MockObject
83
91
*/
84
- private function getMockObject (string $ class , array $ methods = []): PHPUnit_Framework_MockObject_MockObject
92
+ protected function getMockObject ($ class , $ methods = [])
85
93
{
86
94
$ builder = $ this ->getMockBuilder ($ class )
87
95
->disableOriginalConstructor ();
@@ -95,7 +103,7 @@ private function getMockObject(string $class, array $methods = []): PHPUnit_Fram
95
103
* Test for beforeSave method with invalid file extension.
96
104
*
97
105
* @expectedException \Magento\Framework\Exception\LocalizedException
98
- * @expectedExceptionMessage Something is wrong with the file upload settings .
106
+ * @expectedExceptionMessage Invalid file provided .
99
107
*/
100
108
public function testBeforeSaveWithInvalidExtensionFile ()
101
109
{
0 commit comments