@@ -352,25 +352,22 @@ public static function submit_test_data(): array
352352 */
353353 public function test_submit ($ form_data , $ expected , $ expected_msg )
354354 {
355- if ($ expected_msg !== 'CONFIG_UPDATED ' )
355+ $ is_success = $ expected_msg === 'CONFIG_UPDATED ' ;
356+
357+ if ($ is_success )
356358 {
357- $ firstCallDone = false ;
359+ $ this ->setExpectedTriggerError (E_USER_NOTICE , 'CONFIG_UPDATED ' );
360+ }
361+ else
362+ {
363+ $ call_count = 0 ;
358364 $ this ->template ->method ('assign_vars ' )
359- ->willReturnCallback (function ($ params ) use (&$ firstCallDone , $ expected_msg ) {
360- if (! $ firstCallDone )
365+ ->willReturnCallback (function ($ params ) use (&$ call_count , $ expected_msg ) {
366+ if (++ $ call_count === 2 )
361367 {
362- $ firstCallDone = true ; //skip first call
368+ $ this -> assertEquals ([ ' S_ERROR ' => true , ' ERROR_MSG ' => $ expected_msg ], $ params );
363369 }
364- else
365- {
366- $ this ->assertEquals ([
367- 'S_ERROR ' => true ,
368- 'ERROR_MSG ' => $ expected_msg ,
369- ], $ params );
370- }
371- return null ;
372- })
373- ;
370+ });
374371 }
375372
376373 $ this ->request ->expects ($ this ->exactly (4 ))
@@ -382,22 +379,25 @@ public function test_submit($form_data, $expected, $expected_msg)
382379 ['pwa_theme_color_2 ' , '' , false , request_interface::REQUEST , $ form_data ['pwa_theme_color_2 ' ]],
383380 ]);
384381
385- try
382+ $ this ->request_submit ('submit ' );
383+
384+ if ($ is_success )
386385 {
387- $ this ->request_submit ('submit ' );
388386 $ this ->call_admin_controller ();
389387 }
390- catch ( Exception $ e )
388+ else
391389 {
392- $ this ->assertEquals ($ expected_msg , $ e ->getMessage ());
390+ try
391+ {
392+ $ this ->call_admin_controller ();
393+ }
394+ catch (Exception $ e )
395+ {
396+ $ this ->assertEquals ($ expected_msg , $ e ->getMessage ());
397+ }
393398 }
394399
395- $ sql = 'SELECT pwa_bg_color, pwa_theme_color
396- FROM ' . STYLES_TABLE . '
397- WHERE style_active = 1
398- ORDER BY style_id ' ;
399- $ result = $ this ->db ->sql_query ($ sql );
400-
400+ $ result = $ this ->db ->sql_query ('SELECT pwa_bg_color, pwa_theme_color FROM ' . STYLES_TABLE . ' WHERE style_active = 1 ORDER BY style_id ' );
401401 $ rows = $ this ->db ->sql_fetchrowset ($ result );
402402 $ this ->db ->sql_freeresult ($ result );
403403
0 commit comments