Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
change the structure of test module
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-gao committed Dec 7, 2021
1 parent f4cb0e9 commit 5ba2d3e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
10 changes: 7 additions & 3 deletions modules/tide_site_preview/src/TideSitePreviewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public function __construct(TideSiteHelper $site_helper) {
*
* @param \Drupal\node\NodeInterface $node
* The node.
* @param \Drupal\Core\Url $url
* The url.
* @param \Drupal\taxonomy\TermInterface $site
* The site of the preview link.
* @param \Drupal\taxonomy\TermInterface|null $section
Expand Down Expand Up @@ -85,19 +87,20 @@ public function buildFrontendPreviewLink(NodeInterface $node, Url $url, TermInte
* Get the frontend URL of a node.
*
* @param \Drupal\Core\Url $url
* The node.
* The url.
* @param string $site_base_url
* The base URL of the frontend.
* @param array $url_options
* The extra options.
*
* @return \Drupal\Core\Url|string
* The Url.
*/
public function getNodeFrontendUrl(Url $url, string $site_base_url = '', array $url_options = []) {
try {
$path = $url->toString();
$path = rtrim($path, '/');
$clean_url = preg_replace('/\/site\-(\d+)\//', '/', $path,1);
$clean_url = preg_replace('/\/site\-(\d+)\//', '/', $path, 1);
if ((strpos($clean_url, '/') !== 0) && (strpos($clean_url, '#') !== 0) && (strpos($clean_url, '?') !== 0)) {
return $clean_url ? Url::fromUri($clean_url, $url_options) : $url;
}
Expand All @@ -106,7 +109,8 @@ public function getNodeFrontendUrl(Url $url, string $site_base_url = '', array $
return $clean_url ? Url::fromUri($clean_url, $url_options) : $url;
}
return $clean_url ? Url::fromUserInput($clean_url, $url_options) : $url;
} catch (Exception $exception) {
}
catch (Exception $exception) {
watchdog_exception('tide_site_preview', $exception);
}
return '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Drupal\taxonomy\Entity\Term;

/**
* Tests the TideSitePreviewHelper
* Tests the TideSitePreviewHelper.
*
* @group tide_site_preview
*/
Expand Down Expand Up @@ -99,6 +99,12 @@ public function testBuildFrontendPreviewLink($node_values, $url, $term_values, $
$this->assertEquals($expected, $url);
}

/**
* Data provider of test dates.
*
* @return array
* Array of values.
*/
public function buildFrontendPreviewLinkDataProvider() {
return [
[
Expand Down

0 comments on commit 5ba2d3e

Please sign in to comment.