11
11
use Magento \Analytics \Model \Connector ;
12
12
use Magento \Framework \App \Config \ReinitableConfigInterface ;
13
13
use Magento \Framework \App \Config \Storage \WriterInterface ;
14
+ use Magento \Framework \Exception \NotFoundException ;
14
15
use Magento \Framework \FlagManager ;
15
16
16
17
class UpdateTest extends \PHPUnit \Framework \TestCase
@@ -45,6 +46,9 @@ class UpdateTest extends \PHPUnit\Framework\TestCase
45
46
*/
46
47
private $ update ;
47
48
49
+ /**
50
+ * @inheritDoc
51
+ */
48
52
protected function setUp ()
49
53
{
50
54
$ this ->connectorMock = $ this ->getMockBuilder (Connector::class)
@@ -74,6 +78,7 @@ protected function setUp()
74
78
75
79
/**
76
80
* @return void
81
+ * @throws NotFoundException
77
82
*/
78
83
public function testExecuteWithoutToken ()
79
84
{
@@ -82,12 +87,12 @@ public function testExecuteWithoutToken()
82
87
->with (SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE )
83
88
->willReturn (10 );
84
89
$ this ->connectorMock
85
- ->expects ($ this ->once ())
90
+ ->expects ($ this ->never ())
86
91
->method ('execute ' )
87
92
->with ('update ' )
88
93
->willReturn (false );
89
94
$ this ->analyticsTokenMock
90
- ->expects ($ this ->once ())
95
+ ->expects ($ this ->any ())
91
96
->method ('isTokenExist ' )
92
97
->willReturn (false );
93
98
$ this ->addFinalOutputAsserts ();
@@ -120,6 +125,7 @@ private function addFinalOutputAsserts(bool $isExecuted = true)
120
125
* @param $counterData
121
126
* @return void
122
127
* @dataProvider executeWithEmptyReverseCounterDataProvider
128
+ * @throws NotFoundException
123
129
*/
124
130
public function testExecuteWithEmptyReverseCounter ($ counterData )
125
131
{
@@ -159,6 +165,7 @@ public function executeWithEmptyReverseCounterDataProvider()
159
165
* @param bool $functionResult
160
166
* @return void
161
167
* @dataProvider executeRegularScenarioDataProvider
168
+ * @throws NotFoundException
162
169
*/
163
170
public function testExecuteRegularScenario (
164
171
int $ reverseCount ,
@@ -170,6 +177,10 @@ public function testExecuteRegularScenario(
170
177
->method ('getFlagData ' )
171
178
->with (SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE )
172
179
->willReturn ($ reverseCount );
180
+ $ this ->flagManagerMock
181
+ ->expects ($ this ->once ())
182
+ ->method ('saveFlag ' )
183
+ ->with (SubscriptionUpdateHandler::SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE , $ reverseCount - 1 );
173
184
$ this ->connectorMock
174
185
->expects ($ this ->once ())
175
186
->method ('execute ' )
0 commit comments