@@ -46,6 +46,11 @@ class BackendTemplateTest extends \PHPUnit\Framework\TestCase
46
46
*/
47
47
private $ serializerMock ;
48
48
49
+ /**
50
+ * @var \Magento\MediaStorage\Helper\File\Storage\Database|\PHPUnit_Framework_MockObject_MockObject
51
+ */
52
+ private $ databaseHelperMock ;
53
+
49
54
protected function setUp ()
50
55
{
51
56
$ helper = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
@@ -56,6 +61,7 @@ protected function setUp()
56
61
$ this ->structureMock = $ this ->createMock (\Magento \Config \Model \Config \Structure::class);
57
62
$ this ->structureMock ->expects ($ this ->any ())->method ('getFieldPathsByAttribute ' )->willReturn (['path ' => 'test ' ]);
58
63
64
+ $ this ->databaseHelperMock = $ this ->createMock (\Magento \MediaStorage \Helper \File \Storage \Database::class);
59
65
$ this ->resourceModelMock = $ this ->createMock (\Magento \Email \Model \ResourceModel \Template::class);
60
66
$ this ->resourceModelMock ->expects ($ this ->any ())
61
67
->method ('getSystemConfigByPathsAndTemplateId ' )
@@ -64,8 +70,18 @@ protected function setUp()
64
70
$ objectManagerMock = $ this ->createMock (\Magento \Framework \ObjectManagerInterface::class);
65
71
$ objectManagerMock ->expects ($ this ->any ())
66
72
->method ('get ' )
67
- ->with (\Magento \Email \Model \ResourceModel \Template::class)
68
- ->will ($ this ->returnValue ($ this ->resourceModelMock ));
73
+ ->willReturnCallback (
74
+ function ($ value ) {
75
+ switch ($ value ) {
76
+ case \Magento \MediaStorage \Helper \File \Storage \Database::class:
77
+ return ($ this ->databaseHelperMock );
78
+ case \Magento \Email \Model \ResourceModel \Template::class:
79
+ return ($ this ->resourceModelMock );
80
+ default :
81
+ return (NULL );
82
+ }
83
+ }
84
+ );
69
85
70
86
\Magento \Framework \App \ObjectManager::setInstance ($ objectManagerMock );
71
87
0 commit comments