Doubles
1 month ago
Providers
1 month ago
BulkRearmOnGrowthTest.php
1 month ago
BulkReviewsUpdateStuckStateTest.php
1 month ago
ClearCacheRelayResetTest.php
1 month ago
DeleteSourceRelayFailureTest.php
1 month ago
ErrorHandlerFalsyOptionTest.php
1 month ago
FeedCacheUpdateServiceTest.php
1 month ago
FeedMalformedPayloadTest.php
1 month ago
ForceKeylessRefetchTest.php
1 month ago
LicenseDeactivateStaleStateTest.php
1 month ago
MediaFinderMemoTest.php
1 month ago
MultiSourceAggregationTest.php
1 month ago
ReconcileMigratedLicenseRoutineTest.php
1 month ago
ReconcileRemovalTest.php
1 month ago
RegisterWebsiteRoutineTest.php
1 month ago
RemoteRequestMemoTest.php
1 month ago
ReviewAlertHeaderTotalsTest.php
1 month ago
ReviewAlertPageTargetingTest.php
1 month ago
ReviewAlertStarFillTest.php
1 month ago
ShortcodeNeutralizationTest.php
1 month ago
SiteMigrationRecoveryTest.php
1 month ago
Smash1583HeaderParityTest.php
1 month ago
Smash1631MultiLanguageBulkTest.php
1 month ago
Smash1631UpdateSingleLangScopeTest.php
1 month ago
Smash1706TripAdvisorPlaceIdTest.php
1 month ago
Smash782BookingHeaderRatingTest.php
1 month ago
Smash782CountryFlagEmojiTest.php
1 month ago
Smash782ExternalRefreshCronTest.php
1 month ago
Smash782ExtrasTemplateTest.php
1 month ago
Smash782ReviewAlertProviderDataTest.php
1 month ago
SourceIdLookupTest.php
1 month ago
WpmlGetCurrentLanguageTest.php
1 month ago
WpmlLanguageMappingTest.php
1 month ago
WpmlGetCurrentLanguageTest.php
55 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SmashBalloon\Reviews\Tests\Unit; |
| 4 | |
| 5 | use PHPUnit\Framework\TestCase; |
| 6 | use SmashBalloon\Reviews\Pro\Helpers\SBR_WPML; |
| 7 | |
| 8 | /** |
| 9 | * Pins SBR_WPML::get_current_language() — the WPML side of SMASH-1617. The old code |
| 10 | * returned the literal string `'wpml'` when WPML's language code wasn't an exact |
| 11 | * match in Google's list, so Google received `language=wpml` and left reviews |
| 12 | * untranslated. It must now map via Util::map_wpml_to_google_language() and fall |
| 13 | * back to a real code (or 'default') — NEVER 'wpml'. |
| 14 | * |
| 15 | * The mapping itself is covered exhaustively by WpmlLanguageMappingTest; here we |
| 16 | * pin the wrapper's branches (non-WPML passthrough + the WPML fallback chain). |
| 17 | */ |
| 18 | final class WpmlGetCurrentLanguageTest extends TestCase |
| 19 | { |
| 20 | /** |
| 21 | * When WPML isn't active (ICL_SITEPRESS_VERSION undefined) or the localization |
| 22 | * isn't 'wpml', the value passes through unchanged. |
| 23 | */ |
| 24 | public function test_non_wpml_localization_passes_through(): void |
| 25 | { |
| 26 | $this->assertSame('es-419', SBR_WPML::get_current_language('es-419')); |
| 27 | $this->assertSame('en', SBR_WPML::get_current_language('en')); |
| 28 | $this->assertSame('default', SBR_WPML::get_current_language('default')); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * With WPML active and localization 'wpml', an unresolvable WPML language must |
| 33 | * fall back to 'default' — the literal 'wpml' must never reach the API. Run in a |
| 34 | * separate process so defining ICL_SITEPRESS_VERSION doesn't leak to other tests. |
| 35 | * |
| 36 | * (The bootstrap's apply_filters stub returns the passed value, so |
| 37 | * wpml_current_language / wpml_default_language resolve to null here, exercising |
| 38 | * the final fallback.) |
| 39 | * |
| 40 | * @runInSeparateProcess |
| 41 | * @preserveGlobalState disabled |
| 42 | */ |
| 43 | public function test_wpml_fallback_never_returns_literal_wpml(): void |
| 44 | { |
| 45 | if (! defined('ICL_SITEPRESS_VERSION')) { |
| 46 | define('ICL_SITEPRESS_VERSION', '4.9.5'); |
| 47 | } |
| 48 | |
| 49 | $resolved = SBR_WPML::get_current_language('wpml'); |
| 50 | |
| 51 | $this->assertSame('default', $resolved); |
| 52 | $this->assertNotSame('wpml', $resolved); |
| 53 | } |
| 54 | } |
| 55 |