Skip to content

Commit 7c61a58

Browse files
committed
FIX: Update argument syntax for Record::getDecoratedLink()
1 parent 9101de1 commit 7c61a58

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

docs/detailed-result-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ the two, as it will automatically consider whether there are existing GET params
7878
The following example assumes that you have indexed a `title` and `link` for each search Document.
7979

8080
```silverstripe
81-
<a href="{$getDecoratedLink($Link)}">$Title</a>
81+
<a href="{$getDecoratedLink($Link.forTemplate)}">$Title</a>
8282
```
8383

8484
**Note:** Analytics is perhaps the most likely feature to be missing from search service providers. EG: It is

tests/Service/Results/RecordTest.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,29 @@
33
namespace SilverStripe\Discoverer\Tests\Service\Results;
44

55
use PHPUnit\Framework\Attributes\DataProvider;
6-
use SilverStripe\Control\Controller;
6+
use SilverStripe\Assets\Dev\TestAssetStore;
77
use SilverStripe\Dev\SapphireTest;
88
use SilverStripe\Discoverer\Analytics\AnalyticsData;
99
use SilverStripe\Discoverer\Service\Results\Field;
1010
use SilverStripe\Discoverer\Service\Results\Record;
11+
use SilverStripe\View\SSViewer;
1112

1213
class RecordTest extends SapphireTest
1314
{
1415

16+
protected function setUp(): void
17+
{
18+
parent::setUp();
19+
SSViewer::config()->set('source_file_comments', false);
20+
TestAssetStore::activate('RecordTest');
21+
}
22+
23+
protected function tearDown(): void
24+
{
25+
TestAssetStore::reset();
26+
parent::tearDown();
27+
}
28+
1529
public function testAnalyticsData(): void
1630
{
1731
$record = Record::create();
@@ -29,6 +43,13 @@ public function testGetDecoratedLink(?AnalyticsData $analyticsData, string $link
2943
$this->assertEquals($expectedLink, $record->getDecoratedLink($link));
3044
}
3145

46+
public function testGetDecoratedLinkTemplate(): void
47+
{
48+
$actual = Record::create()->renderWith('DecoratedLink', ['Link' => Field::create('http://www.example.com')]);
49+
50+
$this->assertSame('<a href="SilverStripe\Discoverer\Service\Results\Field">Link</a><a href="http://www.example.com">Link</a>', trim($actual->RAW()));
51+
}
52+
3253
public static function provideLinks(): array
3354
{
3455
// SapphireTest doesn't like the use of injector in data providers
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<a href="{$getDecoratedLink($Link)}">Link</a><a href="{$getDecoratedLink($Link.forTemplate)}">Link</a>

0 commit comments

Comments
 (0)