mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
MNT Cuccumber Studio test suite (#167)
This commit is contained in:
parent
f8eac086d2
commit
49f6e5f8a6
@ -43,3 +43,20 @@ SilverStripe\FrameworkTest\Elemental\Model\ElementalBehatTestObject:
|
||||
BasicElementalPage:
|
||||
extensions:
|
||||
- DNADesign\Elemental\Extensions\ElementalPageExtension
|
||||
|
||||
---
|
||||
Only:
|
||||
moduleexists: 'silverstripe/linkfield'
|
||||
---
|
||||
|
||||
SilverStripe\FrameworkTest\LinkField\PageTypes\LinkFieldTestPage:
|
||||
extensions:
|
||||
- SilverStripe\FrameworkTest\LinkField\Extensions\LinkPageExtension
|
||||
|
||||
SilverStripe\FrameworkTest\Model\Company:
|
||||
extensions:
|
||||
- SilverStripe\FrameworkTest\LinkField\Extensions\CompanyExtension
|
||||
|
||||
SilverStripe\FrameworkTest\LinkField\Blocks\LinkFieldTestBlock:
|
||||
extensions:
|
||||
- SilverStripe\FrameworkTest\LinkField\Extensions\ElementContentExtension
|
||||
|
16
code/linkfield/Blocks/LinkFieldTestBlock.php
Normal file
16
code/linkfield/Blocks/LinkFieldTestBlock.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FrameworkTest\LinkField\Blocks;
|
||||
|
||||
use DNADesign\Elemental\Models\BaseElement;
|
||||
|
||||
class LinkFieldTestBlock extends BaseElement
|
||||
{
|
||||
private static string $table_name = 'LinkFieldTestBlock';
|
||||
|
||||
private static string $icon = 'font-icon-block-file-list';
|
||||
|
||||
private static string $singular_name = 'Links List Block';
|
||||
|
||||
private static string $plural_name = 'Links List Blocks';
|
||||
}
|
50
code/linkfield/Extensions/CompanyExtension.php
Normal file
50
code/linkfield/Extensions/CompanyExtension.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FrameworkTest\LinkField\Extensions;
|
||||
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\LinkField\Models\Link;
|
||||
use SilverStripe\LinkField\Form\LinkField;
|
||||
use SilverStripe\LinkField\Form\MultiLinkField;
|
||||
use SilverStripe\LinkField\Models\ExternalLink;
|
||||
|
||||
class CompanyExtension extends Extension
|
||||
{
|
||||
private static array $has_one = [
|
||||
'CompanyWebSiteLink' => Link::class,
|
||||
];
|
||||
|
||||
private static $has_many = [
|
||||
'ManyCompanyWebSiteLink' => Link::class . '.Owner',
|
||||
];
|
||||
|
||||
private static array $owns = [
|
||||
'CompanyWebSiteLink',
|
||||
'ManyCompanyWebSiteLink',
|
||||
];
|
||||
|
||||
private static array $cascade_deletes = [
|
||||
'CompanyWebSiteLink',
|
||||
'ManyCompanyWebSiteLink',
|
||||
];
|
||||
|
||||
private static array $cascade_duplicates = [
|
||||
'CompanyWebSiteLink',
|
||||
'ManyCompanyWebSiteLink',
|
||||
];
|
||||
|
||||
public function updateCMSFields(FieldList $fields)
|
||||
{
|
||||
$fields->removeByName(['CompanyWebSiteLinkID', 'ManyCompanyWebSiteLinkID']);
|
||||
|
||||
$fields->addFieldsToTab(
|
||||
'Root.Main',
|
||||
[
|
||||
LinkField::create('CompanyWebSiteLink', 'Company Website link')
|
||||
->setAllowedTypes([ExternalLink::class]),
|
||||
MultiLinkField::create('ManyCompanyWebSiteLink', 'Multiple Company Website link'),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@ use SilverStripe\LinkField\Models\SiteTreeLink;
|
||||
|
||||
class ElementContentExtension extends Extension
|
||||
{
|
||||
|
||||
private static bool $inline_editable = true;
|
||||
|
||||
private static array $has_one = [
|
||||
@ -44,13 +43,13 @@ class ElementContentExtension extends Extension
|
||||
$fields->addFieldsToTab(
|
||||
'Root.Main',
|
||||
[
|
||||
LinkField::create('OneLink')
|
||||
LinkField::create('OneLink', 'Single Link')
|
||||
->setAllowedTypes([
|
||||
SiteTreeLink::class,
|
||||
EmailLink::class,
|
||||
PhoneLink::class
|
||||
]),
|
||||
MultiLinkField::create('ManyLinks'),
|
||||
MultiLinkField::create('ManyLinks', 'Multiple Links'),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -38,18 +38,18 @@ class LinkPageExtension extends Extension
|
||||
|
||||
public function updateCMSFields(FieldList $fields)
|
||||
{
|
||||
$fields->removeByName(['Content', 'HasOneLinkID', 'HasManyLinks']);
|
||||
$fields->removeByName(['Content', 'HasOneLinkID', 'HasManyLinksID']);
|
||||
|
||||
$fields->addFieldsToTab(
|
||||
'Root.Main',
|
||||
[
|
||||
LinkField::create('HasOneLink')
|
||||
LinkField::create('HasOneLink', 'Single Link')
|
||||
->setAllowedTypes([
|
||||
SiteTreeLink::class,
|
||||
EmailLink::class,
|
||||
PhoneLink::class
|
||||
]),
|
||||
MultiLinkField::create('HasManyLinks'),
|
||||
MultiLinkField::create('HasManyLinks', 'Multiple Links'),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
10
code/linkfield/PageTypes/LinkFieldTestPage.php
Normal file
10
code/linkfield/PageTypes/LinkFieldTestPage.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FrameworkTest\LinkField\PageTypes;
|
||||
|
||||
use Page;
|
||||
|
||||
class LinkFieldTestPage extends Page
|
||||
{
|
||||
private static string $table_name = 'LinkFieldTestPage';
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<% if $OneLink %>
|
||||
<div class="mt-1">
|
||||
<h4>Single Link</h4>
|
||||
<% with $OneLink %>
|
||||
<% if $exists %>
|
||||
<a href="$URL" <% if $OpenInNew %>target="_blank" rel="noopener noreferrer"<% end_if %>>$Title</a>
|
||||
<% end_if %>
|
||||
<% end_with %>
|
||||
</div>
|
||||
<% end_if %>
|
||||
|
||||
<% if $ManyLinks %>
|
||||
<div class="mt-1">
|
||||
<h4>Multiple Link</h4>
|
||||
<ul>
|
||||
<% loop $ManyLinks %>
|
||||
<li>$Me</li>
|
||||
<% end_loop %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end_if %>
|
@ -0,0 +1,34 @@
|
||||
<div class="content search-results">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<section class="col-lg-8 offset-lg-2">
|
||||
<div class="search-results__heading">
|
||||
<h1>$Title.XML</h1>
|
||||
|
||||
<% if $HasOneLink %>
|
||||
<div class="mt-1">
|
||||
<h4>Single Link</h4>
|
||||
<% with $HasOneLink %>
|
||||
<% if $exists %>
|
||||
<a href="$URL" <% if $OpenInNew %>target="_blank" rel="noopener noreferrer"<% end_if %>>$Title</a>
|
||||
<% end_if %>
|
||||
<% end_with %>
|
||||
</div>
|
||||
<% end_if %>
|
||||
|
||||
|
||||
<% if $HasManyLinks %>
|
||||
<div class="mt-1">
|
||||
<h4>Multiple Link</h4>
|
||||
<ul>
|
||||
<% loop $HasManyLinks %>
|
||||
<li>$Me</li>
|
||||
<% end_loop %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end_if %>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user