| 202 | |
| 203 | /** |
| 204 | * The function should respect the user locale settings when the site uses the default locale. |
| 205 | * |
| 206 | * @since 5.2.0 |
| 207 | * @ticket 46056 |
| 208 | * @group l10n |
| 209 | */ |
| 210 | public function test_should_send_personal_data_export_email_in_user_locale() { |
| 211 | update_user_meta( self::$request_user->ID, 'locale', 'es_ES' ); |
| 212 | |
| 213 | wp_privacy_send_personal_data_export_email( self::$request_id ); |
| 214 | |
| 215 | $mailer = tests_retrieve_phpmailer_instance(); |
| 216 | |
| 217 | $this->assertContains( 'Exportación de datos personales', $mailer->get_sent()->subject ); |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * The function should respect the user locale settings when the site does not use en_US, the administrator |
| 222 | * uses the site's default locale, and the user has a different locale. |
| 223 | * |
| 224 | * @since 5.2.0 |
| 225 | * @ticket 46056 |
| 226 | * @group l10n |
| 227 | */ |
| 228 | public function test_should_send_personal_data_export_email_in_user_locale_when_site_is_not_en_us() { |
| 229 | update_option( 'WPLANG', 'es_ES' ); |
| 230 | switch_to_locale( 'es_ES' ); |
| 231 | |
| 232 | update_user_meta( self::$request_user->ID, 'locale', 'de_DE' ); |
| 233 | wp_set_current_user( self::$admin_user->ID ); |
| 234 | |
| 235 | wp_privacy_send_personal_data_export_email( self::$request_id ); |
| 236 | |
| 237 | $mailer = tests_retrieve_phpmailer_instance(); |
| 238 | |
| 239 | $this->assertContains( 'Export personenbezogener Daten', $mailer->get_sent()->subject ); |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * The function should respect the user locale settings when the site is not en_US, the administrator |
| 244 | * has a different selected locale, and the user uses the site's default locale. |
| 245 | * |
| 246 | * @since 5.2.0 |
| 247 | * @ticket 46056 |
| 248 | * @group l10n |
| 249 | */ |
| 250 | public function test_should_send_personal_data_export_email_in_user_locale_when_admin_and_site_have_different_locales() { |
| 251 | update_option( 'WPLANG', 'es_ES' ); |
| 252 | switch_to_locale( 'es_ES' ); |
| 253 | |
| 254 | update_user_meta( self::$admin_user->ID, 'locale', 'de_DE' ); |
| 255 | wp_set_current_user( self::$admin_user->ID ); |
| 256 | |
| 257 | wp_privacy_send_personal_data_export_email( self::$request_id ); |
| 258 | |
| 259 | $mailer = tests_retrieve_phpmailer_instance(); |
| 260 | |
| 261 | $this->assertContains( 'Exportación de datos personales', $mailer->get_sent()->subject ); |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * The function should respect the user locale settings when the site is not en_US and both the |
| 266 | * administrator and the user use different locales. |
| 267 | * |
| 268 | * @since 5.2.0 |
| 269 | * @ticket 46056 |
| 270 | * @group l10n |
| 271 | */ |
| 272 | public function test_should_send_personal_data_export_email_in_user_locale_when_both_have_different_locales_than_site() { |
| 273 | update_option( 'WPLANG', 'es_ES' ); |
| 274 | switch_to_locale( 'es_ES' ); |
| 275 | |
| 276 | update_user_meta( self::$admin_user->ID, 'locale', 'en_US' ); |
| 277 | update_user_meta( self::$request_user->ID, 'locale', 'de_DE' ); |
| 278 | |
| 279 | wp_set_current_user( self::$admin_user->ID ); |
| 280 | |
| 281 | wp_privacy_send_personal_data_export_email( self::$request_id ); |
| 282 | |
| 283 | $mailer = tests_retrieve_phpmailer_instance(); |
| 284 | |
| 285 | $this->assertContains( 'Export personenbezogener Daten', $mailer->get_sent()->subject ); |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * The function should respect the site's locale when the request is for an unregistered user and the |
| 290 | * administrator does not use the site's locale. |
| 291 | * |
| 292 | * @since 5.2.0 |
| 293 | * @ticket 46056 |
| 294 | * @group l10n |
| 295 | */ |
| 296 | public function test_should_send_personal_data_export_email_in_site_locale() { |
| 297 | update_user_meta( self::$admin_user->ID, 'locale', 'es_ES' ); |
| 298 | wp_set_current_user( self::$admin_user->ID ); |
| 299 | |
| 300 | $request_id = wp_create_user_request( 'export-user-not-registered@example.com', 'export_personal_data' ); |
| 301 | |
| 302 | _wp_privacy_account_request_confirmed( self::$request_id ); |
| 303 | wp_privacy_send_personal_data_export_email( $request_id ); |
| 304 | |
| 305 | $mailer = tests_retrieve_phpmailer_instance(); |
| 306 | |
| 307 | $this->assertContains( 'Personal Data Export', $mailer->get_sent()->subject ); |
| 308 | } |
| 309 | |
| 310 | /** |
| 311 | * The function should respect the site's locale when it is not en_US, the request is for an |
| 312 | * unregistered user, and the administrator does not use the site's default locale. |
| 313 | * |
| 314 | * @since 5.2.0 |
| 315 | * @ticket 46056 |
| 316 | * @group l10n |
| 317 | */ |
| 318 | public function test_should_send_personal_data_export_email_in_site_locale_when_not_en_us_and_admin_has_different_locale() { |
| 319 | update_option( 'WPLANG', 'es_ES' ); |
| 320 | switch_to_locale( 'es_ES' ); |
| 321 | |
| 322 | update_user_meta( self::$admin_user->ID, 'locale', 'de_DE' ); |
| 323 | wp_set_current_user( self::$admin_user->ID ); |
| 324 | |
| 325 | $request_id = wp_create_user_request( 'export-user-not-registered@example.com', 'export_personal_data' ); |
| 326 | |
| 327 | _wp_privacy_account_request_confirmed( self::$request_id ); |
| 328 | wp_privacy_send_personal_data_export_email( $request_id ); |
| 329 | |
| 330 | $mailer = tests_retrieve_phpmailer_instance(); |
| 331 | |
| 332 | $this->assertContains( 'Exportación de datos personales', $mailer->get_sent()->subject ); |
| 333 | } |