@@ -43,25 +43,10 @@ class ReportUrlProviderTest extends TestCase
43
43
*/
44
44
private $ flagManagerMock ;
45
45
46
- /**
47
- * @var ObjectManagerHelper
48
- */
49
- private $ objectManagerHelper ;
50
-
51
46
/**
52
47
* @var ReportUrlProvider
53
48
*/
54
- private $ reportUrlProvider ;
55
-
56
- /**
57
- * @var string
58
- */
59
- private $ urlReportConfigPath = 'path/url/report ' ;
60
-
61
- /**
62
- * @var string
63
- */
64
- private $ urlReportDocConfigPath = 'analytics/url/documentation ' ;
49
+ private $ model ;
65
50
66
51
/**
67
52
* @return void
@@ -76,52 +61,36 @@ protected function setUp(): void
76
61
77
62
$ this ->flagManagerMock = $ this ->createMock (FlagManager::class);
78
63
79
- $ this ->objectManagerHelper = new ObjectManagerHelper ($ this );
80
-
81
- $ this ->reportUrlProvider = $ this ->objectManagerHelper ->getObject (
82
- ReportUrlProvider::class,
83
- [
84
- 'config ' => $ this ->configMock ,
85
- 'analyticsToken ' => $ this ->analyticsTokenMock ,
86
- 'otpRequest ' => $ this ->otpRequestMock ,
87
- 'flagManager ' => $ this ->flagManagerMock ,
88
- 'urlReportConfigPath ' => $ this ->urlReportConfigPath ,
89
- ]
90
- );
64
+ $ objectManagerHelper = new ObjectManagerHelper ($ this );
91
65
92
- $ this ->reportUrlProvider = $ this -> objectManagerHelper ->getObject (
66
+ $ this ->model = $ objectManagerHelper ->getObject (
93
67
ReportUrlProvider::class,
94
68
[
95
69
'config ' => $ this ->configMock ,
96
70
'analyticsToken ' => $ this ->analyticsTokenMock ,
97
71
'otpRequest ' => $ this ->otpRequestMock ,
98
72
'flagManager ' => $ this ->flagManagerMock ,
99
- 'urlReportDocConfigPath ' => $ this ->urlReportDocConfigPath ,
100
73
]
101
74
);
102
75
}
103
76
104
77
/**
105
78
* @param bool $isTokenExist
106
79
* @param string|null $otp If null OTP was not received.
80
+ * @param string $configPath
81
+ * @return void
107
82
*
108
- * @throws SubscriptionUpdateException
109
83
* @dataProvider getUrlDataProvider
110
84
*/
111
- public function testGetUrl ($ isTokenExist , $ otp)
85
+ public function testGetUrl (bool $ isTokenExist , ? string $ otp, string $ configPath ): void
112
86
{
113
87
$ reportUrl = 'https://example.com/report ' ;
114
88
$ url = '' ;
115
89
116
90
$ this ->configMock
117
91
->expects ($ this ->once ())
118
92
->method ('getValue ' )
119
- ->with ($ this ->urlReportConfigPath )
120
- ->willReturn ($ reportUrl );
121
- $ this ->configMock
122
- ->expects ($ this ->once ())
123
- ->method ('getValue ' )
124
- ->with ($ this ->urlReportDocConfigPath )
93
+ ->with ($ configPath )
125
94
->willReturn ($ reportUrl );
126
95
$ this ->analyticsTokenMock
127
96
->expects ($ this ->once ())
@@ -136,24 +105,24 @@ public function testGetUrl($isTokenExist, $otp)
136
105
if ($ isTokenExist && $ otp ) {
137
106
$ url = $ reportUrl . '? ' . http_build_query (['otp ' => $ otp ], '' , '& ' );
138
107
}
139
- $ this ->assertSame ($ url ?: $ reportUrl , $ this ->reportUrlProvider ->getUrl ());
108
+
109
+ $ this ->assertSame ($ url ?: $ reportUrl , $ this ->model ->getUrl ());
140
110
}
141
111
142
112
/**
143
113
* @return array
144
114
*/
145
- public function getUrlDataProvider ()
115
+ public function getUrlDataProvider (): array
146
116
{
147
117
return [
148
- 'TokenDoesNotExist ' => [false , null ],
149
- 'TokenExistAndOtpEmpty ' => [true , null ],
150
- 'TokenExistAndOtpValid ' => [true , '249e6b658877bde2a77bc4ab ' ],
118
+ 'TokenDoesNotExist ' => [false , null , ' analytics/url/documentation ' ],
119
+ 'TokenExistAndOtpEmpty ' => [true , null , ' analytics/url/report ' ],
120
+ 'TokenExistAndOtpValid ' => [true , '249e6b658877bde2a77bc4ab ' , ' analytics/url/report ' ],
151
121
];
152
122
}
153
123
154
124
/**
155
125
* @return void
156
- * @throws SubscriptionUpdateException
157
126
*/
158
127
public function testGetUrlWhenSubscriptionUpdateRunning ()
159
128
{
@@ -163,6 +132,6 @@ public function testGetUrlWhenSubscriptionUpdateRunning()
163
132
->with (SubscriptionUpdateHandler::PREVIOUS_BASE_URL_FLAG_CODE )
164
133
->willReturn ('http://store.com ' );
165
134
$ this ->expectException (SubscriptionUpdateException::class);
166
- $ this ->reportUrlProvider ->getUrl ();
135
+ $ this ->model ->getUrl ();
167
136
}
168
137
}
0 commit comments