This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bb4700
commit 09544b0
Showing
3 changed files
with
92 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
modules/tide_site_preview/tests/src/Kernel/TideSitePreviewHelperTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace Drupal\Tests\tide_site_preview\Kernel; | ||
|
||
use Drupal\Core\Url; | ||
use Drupal\Tests\token\Kernel\KernelTestBase; | ||
|
||
/** | ||
* Tests the TideSitePreviewHelper | ||
* | ||
* @group tide_site_preview | ||
*/ | ||
class TideSitePreviewHelperTest extends KernelTestBase { | ||
|
||
/** | ||
* The tide_site_preview.helper service. | ||
* | ||
* @var \Drupal\tide_site_preview\TideSitePreviewHelper | ||
*/ | ||
protected $tideSitePreviewHelper; | ||
|
||
/** | ||
* The modules to load to run the test. | ||
* | ||
* @var array | ||
*/ | ||
public static $modules = [ | ||
'tide_site', | ||
'tide_site_preview', | ||
]; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function setUp() { | ||
parent::setUp(); | ||
$this->installConfig(['tide_site_preview']); | ||
$this->tideSitePreviewHelper =\Drupal::service('tide_site_preview.helper'); | ||
} | ||
|
||
/** | ||
* @covers ::getNodeFrontendUrl | ||
* @dataProvider urlDataProvider | ||
*/ | ||
public function testgetNodeFrontendUrl($value, $expected) { | ||
$url = Url::fromUri($value); | ||
$url = $this->tideSitePreviewHelper->getNodeFrontendUrl($url); | ||
$this->assertEquals($expected, $url->toString()); | ||
} | ||
|
||
/** | ||
* Data provider of test dates. | ||
* | ||
* @return array | ||
* Array of values. | ||
*/ | ||
public function urlDataProvider() { | ||
return [ | ||
[ | ||
'value' => 'https://www.vic.gov.au/site-1/hello_world', | ||
'expected' => 'https://www.vic.gov.au/hello_world', | ||
], | ||
[ | ||
'value' => 'https://site-1/hello_world', | ||
'expected' => 'https://hello_world', | ||
], | ||
[ | ||
'value' => 'https://site-1/', | ||
'expected' => 'https://site-1', | ||
], | ||
[ | ||
'value' => 'https://site-1', | ||
'expected' => 'https://site-1', | ||
], | ||
]; | ||
} | ||
|
||
} |