diff --git a/README.md b/README.md
index 1e2ade6d..830ce1b9 100644
--- a/README.md
+++ b/README.md
@@ -168,6 +168,26 @@ class MyCustomLink extends Link
Custom links can have validation set using standard [model validation](https://docs.silverstripe.org/en/5/developer_guides/forms/validation/#model-validation).
+## Migration from LinkField v3 to v4
+
+The `Title` DB field has been renamed to `LinkText`
+
+You can manually rename this column in your database with the following code:
+
+```php
+// app/_config.php
+use SilverStripe\LinkField\Models\Link;
+use SilverStripe\ORM\DataObject;
+use SilverStripe\ORM\DB;
+
+// Only run this once
+// This will rename the `Title` database column to `LinkText` in all relevant tables
+$linkTable = DataObject::getSchema()->baseDataTable(Link::class);
+DB::get_conn()->getSchemaManager()->renameField($linkTable, 'Title', 'LinkText');
+```
+
+It's recommended to put this code in a `BuildTask` so that you can run it exactly once, and then remove that code in a future deployment.
+
## Migrating from Shae Dawson's Linkable module
https://github.com/sheadawson/silverstripe-linkable
diff --git a/lang/en.yml b/lang/en.yml
index 2fb42f45..e646950b 100644
--- a/lang/en.yml
+++ b/lang/en.yml
@@ -30,7 +30,7 @@ en:
FILE_DOES_NOT_EXIST: 'File does not exist'
FILE_FIELD: File
LINKLABEL: 'Link to a file'
- MISSING_DEFAULT_TITLE: 'File missing'
+ MISSING_DEFAULT_TITLE: '(File missing)'
PLURALNAME: 'File Links'
PLURALS:
one: 'A File Link'
@@ -38,10 +38,10 @@ en:
SINGULARNAME: 'File Link'
has_one_File: File
SilverStripe\LinkField\Models\Link:
- LINK_FIELD_TITLE: Title
- LINK_FIELD_TITLE_DESCRIPTION: 'If left blank, an appropriate default title will be used on the front-end'
+ LINK_TEXT_TITLE: 'Link text'
+ LINK_TEXT_TEXT_DESCRIPTION: 'If left blank, an appropriate default will be used on the front-end'
LINK_TYPE_TITLE: 'Link Type'
- MISSING_DEFAULT_TITLE: 'No link provided'
+ MISSING_DEFAULT_TITLE: '(No value provided)'
OPEN_IN_NEW_TITLE: 'Open in new window?'
PLURALNAME: Links
PLURALS:
@@ -49,7 +49,7 @@ en:
other: '{count} Links'
SINGULARNAME: Link
db_OpenInNew: 'Open in new'
- db_Title: Title
+ db_LinkText: 'Link text'
db_Version: Version
has_one_Owner: Owner
SilverStripe\LinkField\Models\PhoneLink:
@@ -66,7 +66,7 @@ en:
ANCHOR_FIELD_TITLE: Anchor
CANNOT_VIEW_PAGE: 'Cannot view page'
LINKLABEL: 'Page on this site'
- MISSING_DEFAULT_TITLE: 'Page missing'
+ MISSING_DEFAULT_TITLE: '(Page missing)'
PAGE_DOES_NOT_EXIST: 'Page does not exist'
PAGE_FIELD_TITLE: Page
PLURALNAME: 'Site Tree Links'
diff --git a/src/Models/FileLink.php b/src/Models/FileLink.php
index c0c8afbb..9ea944d5 100644
--- a/src/Models/FileLink.php
+++ b/src/Models/FileLink.php
@@ -59,7 +59,7 @@ public function getDefaultTitle(): string
{
$file = $this->File();
if (!$file->exists()) {
- return _t(__CLASS__ . '.MISSING_DEFAULT_TITLE', 'File missing');
+ return _t(__CLASS__ . '.MISSING_DEFAULT_TITLE', '(File missing)');
}
return (string) $this->getDescription();
diff --git a/src/Models/Link.php b/src/Models/Link.php
index 4a0cfed6..e4c06af3 100644
--- a/src/Models/Link.php
+++ b/src/Models/Link.php
@@ -15,6 +15,7 @@
use SilverStripe\ORM\DataObjectSchema;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\Versioned\Versioned;
+use SilverStripe\Forms\Tip;
/**
* A Link Data Object. This class should be treated as abstract. You should never directly interact with a plain Link
@@ -31,7 +32,7 @@ class Link extends DataObject
private static $table_name = 'LinkField_Link';
private static array $db = [
- 'Title' => 'Varchar',
+ 'LinkText' => 'Varchar',
'OpenInNew' => 'Boolean',
'Sort' => 'Int',
];
@@ -94,12 +95,12 @@ public function getCMSFields(): FieldList
$this->beforeUpdateCMSFields(function (FieldList $fields) {
$linkTypes = $this->getLinkTypes();
- $titleField = $fields->dataFieldByName('Title');
- $titleField->setTitle(_t(__CLASS__ . '.LINK_FIELD_TITLE', 'Title'));
- $titleField->setDescription(_t(
- self::class . '.LINK_FIELD_TITLE_DESCRIPTION',
- 'If left blank, an appropriate default title will be used on the front-end',
- ));
+ $linkTextField = $fields->dataFieldByName('LinkText');
+ $linkTextField->setTitle(_t(__CLASS__ . '.LINK_TEXT_TITLE', 'Link text'));
+ $linkTextField->setTitleTip(new Tip(_t(
+ self::class . '.LINK_TEXT_TEXT_DESCRIPTION',
+ 'If left blank, an appropriate default will be used on the front-end',
+ )));
$fields->removeByName('Sort');
@@ -117,19 +118,21 @@ public function getCMSFields(): FieldList
$linkTypes
),
],
- 'Title'
+ 'LinkText'
);
$linkTypeField->setEmptyString('-- select type --');
}
});
$this->afterUpdateCMSFields(function (FieldList $fields) {
- // Move the OpenInNew field to the bottom of the form if it hasn't been removed in
+ // Move the LinkText and OpenInNew fields to the bottom of the form if it hasn't been removed in
// a subclasses getCMSFields() method
- $openInNewField = $fields->dataFieldByName('OpenInNew');
- if ($openInNewField) {
- $fields->removeByName('OpenInNew');
- $fields->addFieldToTab('Root.Main', $openInNewField);
+ foreach (['LinkText', 'OpenInNew'] as $name) {
+ $field = $fields->dataFieldByName($name);
+ if ($field) {
+ $fields->removeByName($name);
+ $fields->addFieldToTab('Root.Main', $field);
+ }
}
});
@@ -285,6 +288,8 @@ public function jsonSerialize(): mixed
unset($data['ClassName']);
unset($data['RecordClassName']);
+ $data['Title'] = $this->getTitle();
+
return $data;
}
@@ -452,11 +457,11 @@ private function getLinkTypes(): array
return $types;
}
- public function getDisplayTitle(): string
+ public function getTitle(): string
{
- // If we have a title, we can just bail out without any changes
- if ($this->Title) {
- return $this->Title;
+ // If we have link text, we can just bail out without any changes
+ if ($this->LinkText) {
+ return $this->LinkText;
}
$defaultLinkTitle = $this->getDefaultTitle();
@@ -470,7 +475,7 @@ public function getDefaultTitle(): string
{
$default = $this->getDescription() ?: $this->getURL();
if (!$default) {
- $default = _t(static::class . '.MISSING_DEFAULT_TITLE', 'No link provided');
+ $default = _t(static::class . '.MISSING_DEFAULT_TITLE', '(No value provided)');
}
return $default;
}
diff --git a/src/Models/SiteTreeLink.php b/src/Models/SiteTreeLink.php
index aed10875..7c1c4b4b 100644
--- a/src/Models/SiteTreeLink.php
+++ b/src/Models/SiteTreeLink.php
@@ -10,6 +10,7 @@
use SilverStripe\Forms\TreeDropdownField;
use SilverStripe\Forms\CompositeValidator;
use SilverStripe\Forms\RequiredFields;
+use SilverStripe\Forms\Tip;
/**
* A link to a Page in the CMS
@@ -61,16 +62,14 @@ public function getCMSFields(): FieldList
'QueryString',
]);
- $titleField = $fields->dataFieldByName('Title');
- $titleField?->setDescription(
- _t(
- __CLASS__ . '.TITLE_DESCRIPTION',
- 'Auto generated from Page title if left blank',
- ),
- );
+ $linkTextField = $fields->dataFieldByName('LinkText');
+ $linkTextField?->setTitleTip(new Tip(_t(
+ __CLASS__ . '.TITLE_DESCRIPTION',
+ 'Auto generated from Page title if left blank',
+ )));
$fields->insertAfter(
- 'Title',
+ 'LinkText',
TreeDropdownField::create(
'PageID',
_t(__CLASS__ . '.PAGE_FIELD_TITLE', 'Page'),
@@ -130,10 +129,7 @@ public function getDefaultTitle(): string
{
$page = $this->Page();
if (!$page->exists()) {
- return _t(
- static::class . '.MISSING_DEFAULT_TITLE',
- 'Page missing',
- );
+ return _t(static::class . '.MISSING_DEFAULT_TITLE', '(Page missing)');
}
if (!$page->canView()) {
return '';
diff --git a/src/Tasks/LinkableMigrationTask.php b/src/Tasks/LinkableMigrationTask.php
index b63a4a4e..758beeb5 100644
--- a/src/Tasks/LinkableMigrationTask.php
+++ b/src/Tasks/LinkableMigrationTask.php
@@ -90,7 +90,7 @@ class LinkableMigrationTask extends BuildTask
'ID' => 'ID',
'LastEdited' => 'LastEdited',
'Created' => 'Created',
- 'Title' => 'Title',
+ 'Title' => 'LinkText',
'OpenInNewWindow' => 'OpenInNew',
];
diff --git a/templates/SilverStripe/LinkField/Models/Link.ss b/templates/SilverStripe/LinkField/Models/Link.ss
index 3d3c455f..83fd4762 100644
--- a/templates/SilverStripe/LinkField/Models/Link.ss
+++ b/templates/SilverStripe/LinkField/Models/Link.ss
@@ -1,3 +1,3 @@
<% if $exists %>
- target="_blank" rel="noopener noreferrer"<% end_if %>>$DisplayTitle
+ target="_blank" rel="noopener noreferrer"<% end_if %>>$Title
<% end_if %>
diff --git a/tests/php/Controllers/LinkFieldControllerTest.php b/tests/php/Controllers/LinkFieldControllerTest.php
index 755fc324..5c679507 100644
--- a/tests/php/Controllers/LinkFieldControllerTest.php
+++ b/tests/php/Controllers/LinkFieldControllerTest.php
@@ -81,10 +81,10 @@ public function testLinkFormGetSchema(
. "&ownerRelation=$ownerRelation";
$this->assertSame($expectedAction, $formSchema['schema']['action']);
// schema is nested and retains 'Root' and 'Main' tab hierarchy
- $this->assertSame('Phone', $formSchema['schema']['fields'][0]['children'][0]['children'][1]['name']);
+ $this->assertSame('Phone', $formSchema['schema']['fields'][0]['children'][0]['children'][0]['name']);
$this->assertSame('action_save', $formSchema['schema']['actions'][0]['name']);
// state node is flattened, unlike schema node
- $this->assertSame($expectedValue, $formSchema['state']['fields'][3]['value']);
+ $this->assertSame($expectedValue, $formSchema['state']['fields'][2]['value']);
$this->assertFalse(array_key_exists('errors', $formSchema));
if ($idType === 'new-record') {
$this->assertSame('OwnerID', $formSchema['state']['fields'][6]['name']);
@@ -224,10 +224,10 @@ public function testLinkFormPost(
. "&ownerRelation=$ownerRelation";
$this->assertSame($expectedUrl, $formSchema['schema']['action']);
// schema is nested and retains 'Root' and 'Main' tab hierarchy
- $this->assertSame('Phone', $formSchema['schema']['fields'][0]['children'][0]['children'][1]['name']);
+ $this->assertSame('Phone', $formSchema['schema']['fields'][0]['children'][0]['children'][0]['name']);
$this->assertSame('action_save', $formSchema['schema']['actions'][0]['name']);
// state node is flattened, unlike schema node
- $this->assertSame('9876543210', $formSchema['state']['fields'][3]['value']);
+ $this->assertSame('9876543210', $formSchema['state']['fields'][2]['value']);
if ($fail) {
// Phone was note updated on PhoneLink dataobject
$link = TestPhoneLink::get()->byID($newID);
@@ -548,18 +548,18 @@ public function provideLinkDelete(): array
* @dataProvider provideLinkSort
*/
public function testLinkSort(
- array $newTitleOrder,
+ array $newLinkTextOrder,
string $fail,
int $expectedCode,
- array $expectedTitles
+ array $expectedLinkTexts
): void {
TestPhoneLink::$fail = $fail;
$url = "/admin/linkfield/sort";
$newLinkIDs = [];
$links = TestPhoneLink::get();
- foreach ($newTitleOrder as $num) {
+ foreach ($newLinkTextOrder as $num) {
foreach ($links as $link) {
- if ($link->Title === "My phone link 0$num") {
+ if ($link->LinkText === "My phone link 0$num") {
$newLinkIDs[] = $link->ID;
}
}
@@ -575,8 +575,8 @@ public function testLinkSort(
$response = $this->post($url, null, $headers, null, $body);
$this->assertSame($expectedCode, $response->getStatusCode());
$this->assertSame(
- $this->getExpectedTitles($expectedTitles),
- TestPhoneLink::get()->filter(['OwnerRelation' => 'LinkList'])->column('Title')
+ $this->getExpectedLinkTexts($expectedLinkTexts),
+ TestPhoneLink::get()->filter(['OwnerRelation' => 'LinkList'])->column('LinkText')
);
}
@@ -584,51 +584,51 @@ public function provideLinkSort(): array
{
return [
'Success' => [
- 'newTitleOrder' => [4, 2, 3],
+ 'newLinkTextOrder' => [4, 2, 3],
'fail' => '',
'expectedCode' => 204,
- 'expectedTitles' => [4, 2, 3],
+ 'expectedLinkTexts' => [4, 2, 3],
],
'Emtpy data' => [
- 'newTitleOrder' => [],
+ 'newLinkTextOrder' => [],
'fail' => '',
'expectedCode' => 400,
- 'expectedTitles' => [2, 3, 4],
+ 'expectedLinkTexts' => [2, 3, 4],
],
'Fail can edit' => [
- 'newTitleOrder' => [4, 2, 3],
+ 'newLinkTextOrder' => [4, 2, 3],
'fail' => 'can-edit',
'expectedCode' => 403,
- 'expectedTitles' => [2, 3, 4],
+ 'expectedLinkTexts' => [2, 3, 4],
],
'Fail object data' => [
- 'newTitleOrder' => [],
+ 'newLinkTextOrder' => [],
'fail' => 'object-data',
'expectedCode' => 400,
- 'expectedTitles' => [2, 3, 4],
+ 'expectedLinkTexts' => [2, 3, 4],
],
'Fail csrf token' => [
- 'newTitleOrder' => [4, 2, 3],
+ 'newLinkTextOrder' => [4, 2, 3],
'fail' => 'csrf-token',
'expectedCode' => 400,
- 'expectedTitles' => [2, 3, 4],
+ 'expectedLinkTexts' => [2, 3, 4],
],
'Mismatched owner' => [
- 'newTitleOrder' => [4, 1, 2],
+ 'newLinkTextOrder' => [4, 1, 2],
'fail' => '',
'expectedCode' => 400,
- 'expectedTitles' => [2, 3, 4],
+ 'expectedLinkTexts' => [2, 3, 4],
],
'Mismatched owner relation' => [
- 'newTitleOrder' => [4, 5, 2],
+ 'newLinkTextOrder' => [4, 5, 2],
'fail' => '',
'expectedCode' => 400,
- 'expectedTitles' => [2, 3, 4],
+ 'expectedLinkTexts' => [2, 3, 4],
],
];
}
- private function getExpectedTitles(array $expected): array
+ private function getExpectedLinkTexts(array $expected): array
{
return array_map(function ($num) {
return "My phone link 0$num";
diff --git a/tests/php/Controllers/LinkFieldControllerTest.yml b/tests/php/Controllers/LinkFieldControllerTest.yml
index c5b4ac1a..1f132ff3 100644
--- a/tests/php/Controllers/LinkFieldControllerTest.yml
+++ b/tests/php/Controllers/LinkFieldControllerTest.yml
@@ -3,30 +3,30 @@ SilverStripe\LinkField\Tests\Models\LinkTest\LinkOwner:
TestLinkOwner02:
SilverStripe\LinkField\Tests\Controllers\LinkFieldControllerTest\TestPhoneLink:
TestPhoneLink01:
- Title: My phone link 01
+ LinkText: My phone link 01
Phone: 0123456789
Sort: 1
# Link relation is manually joined in LinkFieldControllerTest::setup()
TestPhoneLink02:
- Title: My phone link 02
+ LinkText: My phone link 02
Phone: 111222333
Sort: 1
Owner: =>SilverStripe\LinkField\Tests\Models\LinkTest\LinkOwner.TestLinkOwner02
OwnerRelation: LinkList
TestPhoneLink03:
- Title: My phone link 03
+ LinkText: My phone link 03
Phone: 321321321
Sort: 2
Owner: =>SilverStripe\LinkField\Tests\Models\LinkTest\LinkOwner.TestLinkOwner02
OwnerRelation: LinkList
TestPhoneLink04:
- Title: My phone link 04
+ LinkText: My phone link 04
Phone: 444444444
Sort: 3
Owner: =>SilverStripe\LinkField\Tests\Models\LinkTest\LinkOwner.TestLinkOwner02
OwnerRelation: LinkList
TestPhoneLink05:
- Title: My phone link 05
+ LinkText: My phone link 05
Phone: 555555555
Sort: 1
Owner: =>SilverStripe\LinkField\Tests\Models\LinkTest\LinkOwner.TestLinkOwner02
diff --git a/tests/php/Models/LinkTest.php b/tests/php/Models/LinkTest.php
index a740f2eb..5ef9fe85 100644
--- a/tests/php/Models/LinkTest.php
+++ b/tests/php/Models/LinkTest.php
@@ -81,24 +81,24 @@ public function testSiteTreeLinkTitleFallback(): void
/** @var SiteTreeLink $model */
$model = $this->objFromFixture(SiteTreeLink::class, 'page-link-1');
- $this->assertEquals('PageLink1', $model->Title, 'We expect to get a default Link title');
+ $this->assertEquals('PageLink1', $model->LinkText, 'We expect to get a default Link title');
/** @var SiteTree $page */
$page = $this->objFromFixture(SiteTree::class, 'page-1');
$model->PageID = $page->ID;
- $model->Title = null;
+ $model->LinkText = null;
$model->write();
// The actual Database Title field should still be null
- $this->assertNull($model->getField('Title'));
- $this->assertEquals(null, $model->Title, 'We expect that link does not have a title');
+ $this->assertNull($model->getField('LinkText'));
+ $this->assertEquals(null, $model->LinkText, 'We expect that link does not have a title');
$customTitle = 'My custom title';
- $model->Title = $customTitle;
+ $model->LinkText = $customTitle;
$model->write();
- $this->assertEquals($customTitle, $model->Title, 'We expect to get the custom title not page title');
+ $this->assertEquals($customTitle, $model->LinkText, 'We expect to get the custom title not page title');
}
/**
@@ -133,39 +133,25 @@ public function linkTypeProvider(): array
public function testGetVersionedState(): void
{
// Versioned Link
- $link = Link::create(['Title' => 'abc']);
+ $link = Link::create(['LinkText' => 'abc']);
$this->assertTrue(Link::has_extension(Versioned::class));
$this->assertEquals('unsaved', $link->getVersionedState());
$link->write();
$this->assertEquals('draft', $link->getVersionedState());
$link->publishSingle();
$this->assertEquals('published', $link->getVersionedState());
- $link->Title = 'def';
+ $link->LinkText = 'def';
$link->write();
$this->assertEquals('modified', $link->getVersionedState());
// Unversioned Link
Link::remove_extension(Versioned::class);
- $link = Link::create(['Title' => '123']);
+ $link = Link::create(['LinkText' => '123']);
$this->assertEquals('unsaved', $link->getVersionedState());
$link->write();
$this->assertEquals('unversioned', $link->getVersionedState());
}
- /**
- * @param string $identifier
- * @param string $class
- * @param string $expected
- * @return void
- * @dataProvider linkUrlCasesDataProvider
- */
- public function testGetUrl(string $identifier, string $class, string $expected): void
- {
- /** @var Link $link */
- $link = $this->objFromFixture($class, $identifier);
- $this->assertSame($expected, $link->getURL(), 'We expect specific URL value');
- }
-
- public function linkUrlCasesDataProvider(): array
+ public function provideGetUrl(): array
{
return [
'internal link / page only' => [
@@ -241,7 +227,21 @@ public function linkUrlCasesDataProvider(): array
];
}
- function linkDefaultTitleDataProvider(): array
+ /**
+ * @param string $identifier
+ * @param string $class
+ * @param string $expected
+ * @return void
+ * @dataProvider provideGetUrl
+ */
+ public function testGetUrl(string $identifier, string $class, string $expected): void
+ {
+ /** @var Link $link */
+ $link = $this->objFromFixture($class, $identifier);
+ $this->assertSame($expected, $link->getURL(), 'We expect specific URL value');
+ }
+
+ function provideDefaultLinkTitle(): array
{
return [
'page link' => [
@@ -267,7 +267,7 @@ function linkDefaultTitleDataProvider(): array
'file link' => [
'identifier' => 'file-link-no-image',
'class' => FileLink::class,
- 'expected' => 'File missing'
+ 'expected' => '(File missing)'
],
'page link with default title' => [
'identifier' => 'page-link-with-default-title',
@@ -277,7 +277,7 @@ function linkDefaultTitleDataProvider(): array
'page link no page default title' => [
'identifier' => 'page-link-no-page-default-title',
'class' => SiteTreeLink::class,
- 'expected' => 'Page missing'
+ 'expected' => '(Page missing)'
],
'email link with default title' => [
'identifier' => 'email-link-with-default-title',
@@ -303,14 +303,14 @@ function linkDefaultTitleDataProvider(): array
}
/**
- * @dataProvider linkDefaultTitleDataProvider
+ * @dataProvider provideDefaultLinkTitle
*/
public function testDefaultLinkTitle(string $identifier, string $class, string $expected): void
{
/** @var Link $link */
$link = $this->objFromFixture($class, $identifier);
- $this->assertEquals($expected, $link->getDisplayTitle());
+ $this->assertEquals($expected, $link->getTitle());
}
public function provideOwner()
diff --git a/tests/php/Models/LinkTest.yml b/tests/php/Models/LinkTest.yml
index 7f2bdb0b..ba28b2e8 100644
--- a/tests/php/Models/LinkTest.yml
+++ b/tests/php/Models/LinkTest.yml
@@ -10,30 +10,30 @@ SilverStripe\Assets\Image:
SilverStripe\LinkField\Models\Link:
link-1:
- Title: 'Link1'
+ LinkText: 'Link1'
SilverStripe\LinkField\Models\SiteTreeLink:
page-link-1:
- Title: 'PageLink1'
+ LinkText: 'PageLink1'
page-link-page-only:
- Title: 'PageLinkPageOnly'
+ LinkText: 'PageLinkPageOnly'
Page: =>SilverStripe\CMS\Model\SiteTree.page-1
page-link-anchor-only:
- Title: 'PageLinkAnchorOnly'
+ LinkText: 'PageLinkAnchorOnly'
Anchor: 'my-anchor'
page-link-query-string-only:
- Title: 'PageLinkQueryStringOnly'
+ LinkText: 'PageLinkQueryStringOnly'
QueryString: 'param1=value1¶m2=option2'
page-link-with-anchor:
- Title: 'PageLinkWithAnchor'
+ LinkText: 'PageLinkWithAnchor'
Anchor: 'my-anchor'
Page: =>SilverStripe\CMS\Model\SiteTree.page-1
page-link-with-query-string:
- Title: 'PageLinkWithQueryString'
+ LinkText: 'PageLinkWithQueryString'
QueryString: 'param1=value1¶m2=option2'
Page: =>SilverStripe\CMS\Model\SiteTree.page-1
page-link-with-query-string-and-anchor:
- Title: 'PageLinkWithQueryStringAndAnchor'
+ LinkText: 'PageLinkWithQueryStringAndAnchor'
QueryString: 'param1=value1¶m2=option2'
Anchor: 'my-anchor'
Page: =>SilverStripe\CMS\Model\SiteTree.page-1
@@ -44,37 +44,37 @@ SilverStripe\LinkField\Models\SiteTreeLink:
SilverStripe\LinkField\Models\EmailLink:
email-link-with-email:
- Title: 'EmailLinkWithEmail'
+ LinkText: 'EmailLinkWithEmail'
Email: 'maxime@silverstripe.com'
email-link-no-email:
- Title: 'EmailLinkNoEmail'
+ LinkText: 'EmailLinkNoEmail'
email-link-with-default-title:
Email: 'maxime@silverstripe.com'
SilverStripe\LinkField\Models\ExternalLink:
external-link-with-url:
- Title: 'ExternalLinkWithUrl'
+ LinkText: 'ExternalLinkWithUrl'
ExternalUrl: 'https://google.com'
external-link-no-url:
- Title: 'ExternalLinkNoUrl'
+ LinkText: 'ExternalLinkNoUrl'
external-link-with-default-title:
ExternalUrl: 'https://google.com'
SilverStripe\LinkField\Models\PhoneLink:
phone-link-with-phone:
- Title: 'PhoneLinkWithPhone'
+ LinkText: 'PhoneLinkWithPhone'
Phone: '+64 4 978 7330'
phone-link-no-phone:
- Title: 'PhoneLinkNoPhone'
+ LinkText: 'PhoneLinkNoPhone'
phone-link-with-default-title:
Phone: '+64 4 978 7330'
SilverStripe\LinkField\Models\FileLink:
file-link-with-image:
- Title: 'FileLinkWithImage'
+ LinkText: 'FileLinkWithImage'
File: =>SilverStripe\Assets\Image.image-1
file-link-no-image:
- Title: null
+ LinkText: null
File: =>SilverStripe\Assets\Image.image-2
OpenInNew: true
file-link-with-default-title:
diff --git a/tests/php/Models/SiteTreeLinkTest.php b/tests/php/Models/SiteTreeLinkTest.php
index 618ed003..d13f6f7f 100644
--- a/tests/php/Models/SiteTreeLinkTest.php
+++ b/tests/php/Models/SiteTreeLinkTest.php
@@ -37,7 +37,7 @@ public function testGetDefaultTitle(): void
{
// Page does not exist
$link = SiteTreeLink::create();
- $this->assertSame('Page missing', $link->getDefaultTitle());
+ $this->assertSame('(Page missing)', $link->getDefaultTitle());
// Page exists
$page = new TestSiteTreeCanView(['Title' => 'My test page']);
$page->write();
diff --git a/tests/php/Traits/AllowedLinkClassesTraitTest.php b/tests/php/Traits/AllowedLinkClassesTraitTest.php
index 511a63f8..d0293d74 100644
--- a/tests/php/Traits/AllowedLinkClassesTraitTest.php
+++ b/tests/php/Traits/AllowedLinkClassesTraitTest.php
@@ -199,7 +199,7 @@ public function testGetTypesPropsCanCreate(): void
$this->assertFalse($json['testphone']['allowed']);
}
- public function typePropsDataProvider() : array
+ public function provideGetTypesProps() : array
{
return [
'SiteTreeLink props' => [
@@ -254,7 +254,7 @@ public function typePropsDataProvider() : array
}
/**
- * @dataProvider typePropsDataProvider
+ * @dataProvider provideGetTypesProps
*/
public function testGetTypesProps(
string $class,