9
9
use Magento \Store \Model \ScopeInterface as Scope ;
10
10
use Magento \Customer \Model \Context as CustomerContext ;
11
11
use Magento \Framework \UrlInterface ;
12
+ use Magento \Catalog \Model \Product \Attribute \Source \Boolean ;
12
13
14
+ /**
15
+ * GiftMessage config provider test
16
+ */
13
17
class GiftMessageConfigProviderTest extends \PHPUnit_Framework_TestCase
14
18
{
15
19
/**
@@ -59,22 +63,22 @@ class GiftMessageConfigProviderTest extends \PHPUnit_Framework_TestCase
59
63
60
64
protected function setUp ()
61
65
{
62
- $ this ->checkoutSessionMock = $ this ->getMock (' Magento\Checkout\Model\Session ' , [], [], '' , false );
63
- $ this ->httpContextMock = $ this ->getMock (' Magento\Framework\App\Http\Context ' , [], [], '' , false );
64
- $ this ->storeManagerMock = $ this ->getMock (' Magento\Store\Model\StoreManagerInterface ' , [], [], '' , false );
65
- $ this ->localeFormatMock = $ this ->getMock (' Magento\Framework\Locale\FormatInterface ' , [], [], '' , false );
66
- $ this ->formKeyMock = $ this ->getMock (' Magento\Framework\Data\Form\FormKey ' , [], [], '' , false );
67
- $ this ->scopeConfigMock = $ this ->getMock (' Magento\Framework\App\Config\ScopeConfigInterface ' , [], [], '' , false );
68
- $ contextMock = $ this ->getMock (' Magento\Framework\App\Helper\Context ' , [], [], '' , false );
66
+ $ this ->checkoutSessionMock = $ this ->getMock (\ Magento \Checkout \Model \Session::class , [], [], '' , false );
67
+ $ this ->httpContextMock = $ this ->getMock (\ Magento \Framework \App \Http \Context::class , [], [], '' , false );
68
+ $ this ->storeManagerMock = $ this ->getMock (\ Magento \Store \Model \StoreManagerInterface::class , [], [], '' , false );
69
+ $ this ->localeFormatMock = $ this ->getMock (\ Magento \Framework \Locale \FormatInterface::class , [], [], '' , false );
70
+ $ this ->formKeyMock = $ this ->getMock (\ Magento \Framework \Data \Form \FormKey::class , [], [], '' , false );
71
+ $ this ->scopeConfigMock = $ this ->getMock (\ Magento \Framework \App \Config \ScopeConfigInterface::class , [], [], '' , false );
72
+ $ contextMock = $ this ->getMock (\ Magento \Framework \App \Helper \Context::class , [], [], '' , false );
69
73
$ this ->cartRepositoryMock = $ this ->getMock (
70
- ' Magento\GiftMessage\Api\CartRepositoryInterface ' ,
74
+ \ Magento \GiftMessage \Api \CartRepositoryInterface::class ,
71
75
[],
72
76
[],
73
77
'' ,
74
78
false
75
79
);
76
80
$ this ->itemRepositoryMock = $ this ->getMock (
77
- ' Magento\GiftMessage\Api\ItemRepositoryInterface ' ,
81
+ \ Magento \GiftMessage \Api \ItemRepositoryInterface::class ,
78
82
[],
79
83
[],
80
84
'' ,
@@ -108,31 +112,26 @@ public function testGetConfig()
108
112
$ formKey = 'ABCDEFGHIJKLMNOP ' ;
109
113
$ isFrontUrlSecure = true ;
110
114
$ baseUrl = 'https://magento.com/ ' ;
111
- $ quoteItemMock = $ this ->getMock (' Magento\Quote\Model\Quote\Item ' , [], [], '' , false );
112
- $ productMock = $ this ->getMock (' Magento\Catalog\Model\Product ' , [], [], '' , false );
115
+ $ quoteItemMock = $ this ->getMock (\ Magento \Quote \Model \Quote \Item::class , [], [], '' , false );
116
+ $ productMock = $ this ->getMock (\ Magento \Catalog \Model \Product::class , [], [], '' , false );
113
117
$ storeMock = $ this ->getMock (
114
- ' Magento\Store\Model\Store ' ,
118
+ \ Magento \Store \Model \Store::class ,
115
119
['isFrontUrlSecure ' , 'getBaseUrl ' , 'getCode ' ],
116
120
[],
117
121
'' ,
118
122
false
119
123
);
120
124
$ quoteMock = $ this ->getMock (
121
- ' Magento\Quote\Model\Quote ' ,
125
+ \ Magento \Quote \Model \Quote::class ,
122
126
['getQuoteCurrencyCode ' , 'getStore ' , 'getIsVirtual ' , 'getAllVisibleItems ' , 'getId ' ],
123
127
[],
124
128
'' ,
125
129
false
126
130
);
127
- $ messageMock = $ this ->getMockForAbstractClass (
128
- 'Magento\GiftMessage\Api\Data\MessageInterface ' ,
129
- [],
130
- '' ,
131
- false ,
132
- false ,
133
- false ,
134
- ['getData ' ]
135
- );
131
+ $ messageMock = $ this ->getMockBuilder (\Magento \GiftMessage \Api \Data \MessageInterface::class)
132
+ ->disableOriginalConstructor ()
133
+ ->setMethods (['getData ' ])
134
+ ->getMockForAbstractClass ();
136
135
137
136
$ this ->scopeConfigMock ->expects ($ this ->atLeastOnce ())->method ('getValue ' )->willReturnMap (
138
137
[
@@ -151,7 +150,7 @@ public function testGetConfig()
151
150
$ quoteMock ->expects ($ this ->once ())->method ('getAllVisibleItems ' )->willReturn ([$ quoteItemMock ]);
152
151
$ quoteItemMock ->expects ($ this ->once ())->method ('getId ' )->willReturn ($ itemId );
153
152
$ quoteItemMock ->expects ($ this ->any ())->method ('getProduct ' )->willReturn ($ productMock );
154
- $ productMock ->expects ($ this ->any ())->method ('getGiftMessageAvailable ' )->willReturn (false );
153
+ $ productMock ->expects ($ this ->any ())->method ('getGiftMessageAvailable ' )->willReturn (Boolean:: VALUE_USE_CONFIG );
155
154
$ this ->itemRepositoryMock ->expects ($ this ->once ())->method ('get ' )->with ($ quoteId , $ itemId )
156
155
->willReturn ($ messageMock );
157
156
$ quoteMock ->expects ($ this ->once ())->method ('getQuoteCurrencyCode ' )->willReturn ($ currencyCode );
@@ -174,7 +173,6 @@ public function testGetConfig()
174
173
'orderLevel ' => $ messageDataMock ,
175
174
'itemLevel ' => [
176
175
$ itemId => [
177
- 'is_available ' => false ,
178
176
'message ' => $ messageDataMock ,
179
177
],
180
178
]
0 commit comments