@@ -99,28 +99,11 @@ public function testBeforeDispatchOutOfDateNoErrors()
99
99
$ this ->plugin ->beforeDispatch ($ this ->frontControllerMock , $ this ->requestMock );
100
100
}
101
101
102
- public function testBeforeDispatchOutOfDateWithErrors ()
102
+ /**
103
+ * @dataProvider beforeDispatchOutOfDateWithErrorsDataProvider
104
+ */
105
+ public function testBeforeDispatchOutOfDateWithErrors (array $ errors , string $ expectedMessage )
103
106
{
104
- $ errors = [
105
- [
106
- DbVersionInfo::KEY_MODULE => 'Magento_Module1 ' ,
107
- DbVersionInfo::KEY_TYPE => 'schema ' ,
108
- DbVersionInfo::KEY_CURRENT => '3.3.3 ' ,
109
- DbVersionInfo::KEY_REQUIRED => '4.4.4 '
110
- ],
111
- [
112
- DbVersionInfo::KEY_MODULE => 'Magento_Module2 ' ,
113
- DbVersionInfo::KEY_TYPE => 'data ' ,
114
- DbVersionInfo::KEY_CURRENT => '2.8.7 ' ,
115
- DbVersionInfo::KEY_REQUIRED => '5.1.6 '
116
- ]
117
- ];
118
- $ message = 'Please upgrade your database: '
119
- . "Run \"bin/magento setup:upgrade \" from the Magento root directory. \n"
120
- . "The following modules are outdated: \n"
121
- . "Magento_Module1 schema: current version - 3.3.3, required version - 4.4.4 \n"
122
- . "Magento_Module2 data: current version - 2.8.7, required version - 5.1.6 " ;
123
-
124
107
$ this ->cacheMock ->expects (static ::any ())
125
108
->method ('load ' )
126
109
->with ('db_is_up_to_date ' )
@@ -131,7 +114,76 @@ public function testBeforeDispatchOutOfDateWithErrors()
131
114
$ this ->cacheMock ->expects (static ::never ())
132
115
->method ('save ' );
133
116
134
- $ this ->expectException (LocalizedException::class, $ message );
117
+ $ this ->expectException (LocalizedException::class, $ expectedMessage );
118
+ $ this ->expectExceptionMessage ($ expectedMessage );
135
119
$ this ->plugin ->beforeDispatch ($ this ->frontControllerMock , $ this ->requestMock );
136
120
}
121
+
122
+ public static function beforeDispatchOutOfDateWithErrorsDataProvider ()
123
+ {
124
+ return [
125
+ 'module versions too low ' => [
126
+ 'errors ' => [
127
+ [
128
+ DbVersionInfo::KEY_MODULE => 'Magento_Module1 ' ,
129
+ DbVersionInfo::KEY_TYPE => 'schema ' ,
130
+ DbVersionInfo::KEY_CURRENT => 'none ' ,
131
+ DbVersionInfo::KEY_REQUIRED => '4.4.4 '
132
+ ],
133
+ [
134
+ DbVersionInfo::KEY_MODULE => 'Magento_Module2 ' ,
135
+ DbVersionInfo::KEY_TYPE => 'data ' ,
136
+ DbVersionInfo::KEY_CURRENT => '2.8.7 ' ,
137
+ DbVersionInfo::KEY_REQUIRED => '5.1.6 '
138
+ ],
139
+ ],
140
+ 'expectedMessage ' => 'Please upgrade your database: '
141
+ . "Run \"bin/magento setup:upgrade \" from the Magento root directory. \n"
142
+ . "The following modules are outdated: \n"
143
+ . "Magento_Module1 schema: current version - none, required version - 4.4.4 \n"
144
+ . "Magento_Module2 data: current version - 2.8.7, required version - 5.1.6 "
145
+ ],
146
+ 'module versions too high ' => [
147
+ 'errors ' => [
148
+ [
149
+ DbVersionInfo::KEY_MODULE => 'Magento_Module3 ' ,
150
+ DbVersionInfo::KEY_TYPE => 'schema ' ,
151
+ DbVersionInfo::KEY_CURRENT => '2.0.0 ' ,
152
+ DbVersionInfo::KEY_REQUIRED => '1.0.0 '
153
+ ],
154
+ [
155
+ DbVersionInfo::KEY_MODULE => 'Magento_Module4 ' ,
156
+ DbVersionInfo::KEY_TYPE => 'data ' ,
157
+ DbVersionInfo::KEY_CURRENT => '1.0.1 ' ,
158
+ DbVersionInfo::KEY_REQUIRED => '1.0.0 '
159
+ ],
160
+ ],
161
+ 'expectedMessage ' => "Please update your modules: "
162
+ . "Run \"composer install \" from the Magento root directory. \n"
163
+ . "The following modules are outdated: \n"
164
+ . "Magento_Module3 schema: code version - 1.0.0, database version - 2.0.0 \n"
165
+ . "Magento_Module4 data: code version - 1.0.0, database version - 1.0.1 " ,
166
+ ],
167
+ 'some versions too high, some too low ' => [
168
+ 'errors ' => [
169
+ [
170
+ DbVersionInfo::KEY_MODULE => 'Magento_Module1 ' ,
171
+ DbVersionInfo::KEY_TYPE => 'schema ' ,
172
+ DbVersionInfo::KEY_CURRENT => '2.0.0 ' ,
173
+ DbVersionInfo::KEY_REQUIRED => '1.0.0 '
174
+ ],
175
+ [
176
+ DbVersionInfo::KEY_MODULE => 'Magento_Module2 ' ,
177
+ DbVersionInfo::KEY_TYPE => 'schema ' ,
178
+ DbVersionInfo::KEY_CURRENT => '1.0.0 ' ,
179
+ DbVersionInfo::KEY_REQUIRED => '2.0.0 '
180
+ ],
181
+ ],
182
+ 'expectedMessage ' => "Please update your modules: "
183
+ . "Run \"composer install \" from the Magento root directory. \n"
184
+ . "The following modules are outdated: \n"
185
+ . "Magento_Module1 schema: code version - 1.0.0, database version - 2.0.0 "
186
+ ]
187
+ ];
188
+ }
137
189
}
0 commit comments