21 private $connectorMock;
26 private $configWriterMock;
31 private $flagManagerMock;
36 private $reinitableConfigMock;
41 private $analyticsTokenMock;
50 $this->connectorMock = $this->getMockBuilder(Connector::class)
51 ->disableOriginalConstructor()
53 $this->configWriterMock = $this->getMockBuilder(WriterInterface::class)
54 ->disableOriginalConstructor()
56 $this->flagManagerMock = $this->getMockBuilder(FlagManager::class)
57 ->disableOriginalConstructor()
59 $this->reinitableConfigMock = $this->getMockBuilder(ReinitableConfigInterface::class)
60 ->disableOriginalConstructor()
62 $this->analyticsTokenMock = $this->getMockBuilder(AnalyticsToken::class)
63 ->disableOriginalConstructor()
66 $this->update =
new Update(
68 $this->configWriterMock,
69 $this->reinitableConfigMock,
70 $this->flagManagerMock,
71 $this->analyticsTokenMock
80 $this->flagManagerMock
81 ->method(
'getFlagData')
85 ->expects($this->once())
89 $this->analyticsTokenMock
90 ->expects($this->once())
91 ->method(
'isTokenExist')
93 $this->addFinalOutputAsserts();
94 $this->assertFalse($this->update->execute());
100 private function addFinalOutputAsserts(
bool $isExecuted =
true)
102 $this->flagManagerMock
103 ->expects($this->exactly(2 * $isExecuted))
104 ->method(
'deleteFlag')
109 $this->configWriterMock
110 ->expects($this->exactly((
int)$isExecuted))
113 $this->reinitableConfigMock
114 ->expects($this->exactly((
int)$isExecuted))
126 $this->flagManagerMock
127 ->method(
'getFlagData')
129 ->willReturn($counterData);
131 ->expects($this->never())
135 $this->analyticsTokenMock
136 ->method(
'isTokenExist')
138 $this->addFinalOutputAsserts();
139 $this->assertFalse($this->update->execute());
166 bool $finalConditionsIsExpected,
169 $this->flagManagerMock
170 ->method(
'getFlagData')
172 ->willReturn($reverseCount);
174 ->expects($this->once())
177 ->willReturn($commandResult);
178 $this->analyticsTokenMock
179 ->method(
'isTokenExist')
181 $this->addFinalOutputAsserts($finalConditionsIsExpected);
182 $this->assertSame($functionResult, $this->update->execute());
191 'The last attempt with command execution result False' => [
192 'Reverse count' => 1,
193 'Command result' =>
false,
194 'Executed final output conditions' =>
true,
195 'Function result' =>
false,
197 'Not the last attempt with command execution result False' => [
198 'Reverse count' => 10,
199 'Command result' =>
false,
200 'Executed final output conditions' =>
false,
201 'Function result' =>
false,
203 'Command execution result True' => [
204 'Reverse count' => 10,
205 'Command result' =>
true,
206 'Executed final output conditions' =>
true,
207 'Function result' =>
true,
testExecuteWithoutToken()
testExecuteWithEmptyReverseCounter($counterData)
executeWithEmptyReverseCounterDataProvider()
testExecuteRegularScenario(int $reverseCount, bool $commandResult, bool $finalConditionsIsExpected, bool $functionResult)
const PREVIOUS_BASE_URL_FLAG_CODE
const SUBSCRIPTION_UPDATE_REVERSE_COUNTER_FLAG_CODE
executeRegularScenarioDataProvider()
const UPDATE_CRON_STRING_PATH