Skip to content

Commit

Permalink
Tests to cover the wildcard + query param combos
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparsd committed Apr 24, 2020
1 parent a00e5d7 commit 8d27fd5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/php/WidgetContextTargetByUrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,20 @@ public function testUrlQueryStrings() {
);
}

public function testQueryStringsWithWildcards() {
$this->assertTrue(
$this->plugin->match_path( 'categoria-producte/cosmetica/?pwb-brand-filter=clarins', '*pwb-brand-filter=*' ),
'Matching query param key with wrapping wildcards'
);

$this->assertTrue(
$this->plugin->match_path( 'producte/cosmetica?pwb-brand-filter=clarins', '*/cosmetica/?pwb-brand-filter=*' ),
'Ignore trailing slashes on rule paths'
);
}

public function testUrlSpecial() {
// Disregard things like utm_source and other tracking parameters.
$this->assertTrue(
$this->plugin->match_path( 'campaigns?cc=automotive', 'campaigns/' ),
'Ignore query string because no rules use it'
Expand Down
6 changes: 6 additions & 0 deletions tests/php/WidgetContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public function testRequestPathResolver() {
'path-to-a/url.html',
$this->plugin->path_from_uri( 'path-to-a/url.html' )
);

$this->assertEquals(
'producte/cosmetica?pwb-brand-filter=clarins',
$this->plugin->path_from_uri( 'producte/cosmetica/?pwb-brand-filter=clarins' ),
'Normalize the path by removing the trailing slash'
);
}

}

0 comments on commit 8d27fd5

Please sign in to comment.