MNT Cuccumber Studio test suite (#167)

This commit is contained in:
Sabina Talipova 2024-02-29 14:33:36 +13:00 committed by GitHub
parent f8eac086d2
commit 49f6e5f8a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 153 additions and 6 deletions

View File

@ -43,3 +43,20 @@ SilverStripe\FrameworkTest\Elemental\Model\ElementalBehatTestObject:
BasicElementalPage: BasicElementalPage:
extensions: extensions:
- DNADesign\Elemental\Extensions\ElementalPageExtension - 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

View 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';
}

View 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'),
]
);
}
}

View File

@ -12,7 +12,6 @@ use SilverStripe\LinkField\Models\SiteTreeLink;
class ElementContentExtension extends Extension class ElementContentExtension extends Extension
{ {
private static bool $inline_editable = true; private static bool $inline_editable = true;
private static array $has_one = [ private static array $has_one = [
@ -44,13 +43,13 @@ class ElementContentExtension extends Extension
$fields->addFieldsToTab( $fields->addFieldsToTab(
'Root.Main', 'Root.Main',
[ [
LinkField::create('OneLink') LinkField::create('OneLink', 'Single Link')
->setAllowedTypes([ ->setAllowedTypes([
SiteTreeLink::class, SiteTreeLink::class,
EmailLink::class, EmailLink::class,
PhoneLink::class PhoneLink::class
]), ]),
MultiLinkField::create('ManyLinks'), MultiLinkField::create('ManyLinks', 'Multiple Links'),
], ],
); );
} }

View File

@ -38,18 +38,18 @@ class LinkPageExtension extends Extension
public function updateCMSFields(FieldList $fields) public function updateCMSFields(FieldList $fields)
{ {
$fields->removeByName(['Content', 'HasOneLinkID', 'HasManyLinks']); $fields->removeByName(['Content', 'HasOneLinkID', 'HasManyLinksID']);
$fields->addFieldsToTab( $fields->addFieldsToTab(
'Root.Main', 'Root.Main',
[ [
LinkField::create('HasOneLink') LinkField::create('HasOneLink', 'Single Link')
->setAllowedTypes([ ->setAllowedTypes([
SiteTreeLink::class, SiteTreeLink::class,
EmailLink::class, EmailLink::class,
PhoneLink::class PhoneLink::class
]), ]),
MultiLinkField::create('HasManyLinks'), MultiLinkField::create('HasManyLinks', 'Multiple Links'),
], ],
); );
} }

View File

@ -0,0 +1,10 @@
<?php
namespace SilverStripe\FrameworkTest\LinkField\PageTypes;
use Page;
class LinkFieldTestPage extends Page
{
private static string $table_name = 'LinkFieldTestPage';
}

View File

@ -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 %>

View File

@ -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>