PluginProbe ʕ •ᴥ•ʔ
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More / 2.10.0
Reviews Feed – Add Testimonials and Customer Reviews From Google Reviews, Yelp, TripAdvisor, and More v2.10.0
2.11.0 2.10.0 2.9.0 2.8.0 2.7.0 2.6.7 2.6.8 2.6.5 2.6.4 2.6.3 2.6.2 2.6.0 2.5.5 2.5.4 2.5.3 2.5.2 trunk 1.0 1.0.1 1.0.2 1.0.3 1.1 1.1.1 1.1.2 1.2.0 2.0 2.1.0 2.1.1 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1
reviews-feed / tests / Unit / Smash1706TripAdvisorPlaceIdTest.php
reviews-feed / tests / Unit Last commit date
Doubles 4 weeks ago Providers 4 weeks ago BulkRearmOnGrowthTest.php 4 weeks ago BulkReviewsUpdateStuckStateTest.php 4 weeks ago ClearCacheRelayResetTest.php 4 weeks ago DeleteSourceRelayFailureTest.php 4 weeks ago ErrorHandlerFalsyOptionTest.php 4 weeks ago FeedCacheUpdateServiceTest.php 4 weeks ago FeedMalformedPayloadTest.php 4 weeks ago ForceKeylessRefetchTest.php 4 weeks ago LicenseDeactivateStaleStateTest.php 4 weeks ago MediaFinderMemoTest.php 4 weeks ago MultiSourceAggregationTest.php 4 weeks ago ReconcileMigratedLicenseRoutineTest.php 4 weeks ago ReconcileRemovalTest.php 4 weeks ago RegisterWebsiteRoutineTest.php 4 weeks ago RemoteRequestMemoTest.php 4 weeks ago ReviewAlertHeaderTotalsTest.php 4 weeks ago ReviewAlertPageTargetingTest.php 4 weeks ago ReviewAlertStarFillTest.php 4 weeks ago ShortcodeNeutralizationTest.php 4 weeks ago SiteMigrationRecoveryTest.php 4 weeks ago Smash1583HeaderParityTest.php 4 weeks ago Smash1631MultiLanguageBulkTest.php 4 weeks ago Smash1631UpdateSingleLangScopeTest.php 4 weeks ago Smash1706TripAdvisorPlaceIdTest.php 4 weeks ago Smash1756SchemaServiceTest.php 4 weeks ago Smash1785AvatarLocalUrlGuardTest.php 4 weeks ago Smash1785AvatarReHealTest.php 4 weeks ago Smash1795ReviewTextXssTest.php 4 weeks ago Smash782BookingHeaderRatingTest.php 4 weeks ago Smash782CountryFlagEmojiTest.php 4 weeks ago Smash782ExternalRefreshCronTest.php 4 weeks ago Smash782ExtrasTemplateTest.php 4 weeks ago Smash782ReviewAlertProviderDataTest.php 4 weeks ago SourceIdLookupTest.php 4 weeks ago WpmlGetCurrentLanguageTest.php 4 weeks ago WpmlLanguageMappingTest.php 4 weeks ago
Smash1706TripAdvisorPlaceIdTest.php
59 lines
1 <?php
2
3 namespace SmashBalloon\Reviews\Tests\Unit;
4
5 use PHPUnit\Framework\TestCase;
6 use SmashBalloon\Reviews\Common\Builder\SBR_Feed_Saver_Manager;
7
8 /**
9 * SMASH-1706 — TripAdvisor "Add Source" sent the full listing URL to the relay
10 * as `place_id` instead of the numeric location id, so the relay's
11 * `location/{placeid}/details` call 404'd (sourceConnectionError).
12 *
13 * Root cause: get_place_id_tripadvisor() only extracted the id when a URL
14 * segment contained ".html" AND matched `/-d+\d{0,10}-/` (a trailing dash).
15 * TripAdvisor's short attraction URL (no ".html"), the ".ca"/".co.uk" domains,
16 * and the bare location id all fell through and returned the full URL unchanged.
17 *
18 * The location id is the `-d<digits>` token, present in every TripAdvisor
19 * listing URL form. This suite pins extraction across all of them, and keeps the
20 * long ".html" form (the shape that historically worked) passing — that is the
21 * backwards-compatibility guard.
22 */
23 final class Smash1706TripAdvisorPlaceIdTest extends TestCase
24 {
25 /**
26 * @dataProvider urlFormProvider
27 */
28 public function test_extracts_location_id_from_every_url_form(string $input, string $expected): void
29 {
30 $this->assertSame(
31 $expected,
32 SBR_Feed_Saver_Manager::get_place_id_tripadvisor($input),
33 "Failed extracting location id from: {$input}"
34 );
35 }
36
37 public static function urlFormProvider(): array
38 {
39 return [
40 // The customer's exact input forms (WPSA 69629) — all must yield 2422991.
41 'full .com (customer)' => ['https://www.tripadvisor.com/Attraction_Review-g154948-d2422991', '2422991'],
42 'short .com' => ['https://tripadvisor.com/Attraction_Review-g154948-d2422991', '2422991'],
43 '.ca domain' => ['https://tripadvisor.ca/Attraction_Review-g154948-d2422991', '2422991'],
44 'bare location id' => ['2422991', '2422991'],
45
46 // Scheme-less pastes (FILTER_VALIDATE_URL rejects these) must still resolve.
47 'scheme-less .com' => ['tripadvisor.com/Attraction_Review-g154948-d2422991', '2422991'],
48 'www. no scheme' => ['www.tripadvisor.com/Attraction_Review-g154948-d2422991', '2422991'],
49
50 // Backwards-compat: the long ".html" review URL that has always worked.
51 'long .html (BC)' => ['https://www.tripadvisor.com/Attraction_Review-g154948-d2422991-Reviews-Whistler_Mountain-Whistler_British_Columbia.html', '2422991'],
52
53 // Other listing types / TLDs TripAdvisor surfaces.
54 'restaurant .html' => ['https://www.tripadvisor.com/Restaurant_Review-g60763-d477942-Reviews-Katz_s_Delicatessen-New_York_City.html', '477942'],
55 'hotel .co.uk .html' => ['https://www.tripadvisor.co.uk/Hotel_Review-g186338-d193089-Reviews-The_Savoy.html', '193089'],
56 ];
57 }
58 }
59