@@ -59,7 +59,7 @@ protected function setUp(): void
5959
6060 global $ phpbb_root_path , $ phpEx , $ user ;
6161
62- $ db = $ this ->new_dbal ();
62+ $ this -> db = $ this ->new_dbal ();
6363
6464 $ lang_loader = new \phpbb \language \language_file_loader ($ phpbb_root_path , $ phpEx );
6565 $ lang_loader ->set_extension_manager (new \phpbb_mock_extension_manager ($ phpbb_root_path ));
@@ -73,7 +73,7 @@ protected function setUp(): void
7373 $ this ->user ->data ['user_form_salt ' ] = '' ;
7474 $ this ->user ->data ['is_bot ' ] = false ;
7575 $ this ->user ->data ['user_type ' ] = USER_NORMAL ;
76- $ user_loader = new \phpbb \user_loader ($ db , $ phpbb_root_path , $ phpEx , 'phpbb_users ' );
76+ $ user_loader = new \phpbb \user_loader ($ this -> db , $ phpbb_root_path , $ phpEx , 'phpbb_users ' );
7777
7878 $ this ->controller_helper = $ this ->getMockBuilder ('\phpbb\controller\helper ' )
7979 ->disableOriginalConstructor ()
@@ -109,7 +109,7 @@ protected function setUp(): void
109109
110110 $ this ->notification_method_webpush = new \phpbb \webpushnotifications \notification \method \webpush (
111111 $ this ->config ,
112- $ db ,
112+ $ this -> db ,
113113 new \phpbb \log \dummy (),
114114 $ user_loader ,
115115 $ this ->user ,
@@ -123,6 +123,29 @@ protected function setUp(): void
123123 $ this ->root_path = $ phpbb_root_path ;
124124 }
125125
126+ /**
127+ * Remove entries from subscriptions table to avoid conflicts with other tests
128+ * that have fixtures with the same table name
129+ *
130+ * @return void
131+ */
132+ protected function tearDown (): void
133+ {
134+ $ sql_layer = $ this ->db ->get_sql_layer ();
135+ $ query = ($ sql_layer === 'sqlite3 ' )
136+ ? 'DELETE FROM phpbb_wpn_push_subscriptions '
137+ : 'TRUNCATE TABLE phpbb_wpn_push_subscriptions ' ;
138+
139+ $ this ->db ->sql_query ($ query );
140+
141+ if ($ sql_layer === 'postgres ' )
142+ {
143+ $ this ->db ->sql_query ('ALTER SEQUENCE phpbb_wpn_push_subscriptions_seq RESTART WITH 1 ' );
144+ }
145+
146+ parent ::tearDown ();
147+ }
148+
126149 protected function set_listener ()
127150 {
128151 $ this ->listener = new \phpbb \webpushnotifications \event \listener (
0 commit comments