Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT Behat-test fixtures for elemental area #105

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions _config/extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ SilverStripe\ORM\DataObject:
SilverStripe\Assets\File:
extensions:
- BasicFieldsTestFileExtension

---
Only:
classexists: 'DNADesign\Elemental\Extensions\ElementalPageExtension'
moduleexists: 'dnadesign/silverstripe-elemental'
---
SilverStripe\FrameworkTest\Model\TestPage:
extensions:
- DNADesign\Elemental\Extensions\ElementalPageExtension

SilverStripe\FrameworkTest\Elemental\Model\ElementalBehatTestObject:
extensions:
- DNADesign\Elemental\Extensions\ElementalAreasExtension
- SilverStripe\FrameworkTest\Elemental\Extension\ElementalBehatTestExtension
17 changes: 17 additions & 0 deletions code/elemental/ElementalBehatTestAdmin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace SilverStripe\FrameworkTest\Elemental\Admin;

use SilverStripe\Admin\ModelAdmin;
use SilverStripe\FrameworkTest\Elemental\Model\ElementalBehatTestObject;

class ElementalBehatTestAdmin extends ModelAdmin
{
private static string $url_segment = 'elemental-behat-test-admin';
private static string $menu_title = 'Elemental Behat Test Admin';
private static string $menu_icon_class = 'font-icon-block-banner';

private static array $managed_models = [
ElementalBehatTestObject::class,
];
}
15 changes: 15 additions & 0 deletions code/elemental/ElementalBehatTestExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace SilverStripe\FrameworkTest\Elemental\Extension;

use DNADesign\Elemental\Models\ElementalArea;
use SilverStripe\ORM\DataExtension;

class ElementalBehatTestExtension extends DataExtension
{
private static $has_one = [
'ElementalArea' => ElementalArea::class,
];

private static $owns = ['ElementalArea'];
}
26 changes: 26 additions & 0 deletions code/elemental/ElementalBehatTestObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace SilverStripe\FrameworkTest\Elemental\Model;

use SilverStripe\FrameworkTest\Elemental\Admin\ElementalBehatTestAdmin;
use SilverStripe\Control\Controller;
use SilverStripe\ORM\DataObject;

class ElementalBehatTestObject extends DataObject
{
private static string $table_name = 'ElementalBehatTestObject';

public function CMSEditLink()
{
$admin = ElementalBehatTestAdmin::singleton();
$sanitisedClassname = str_replace('\\', '-', $this->ClassName);

return Controller::join_links(
$admin->Link($sanitisedClassname),
'EditForm/field/',
$sanitisedClassname,
'item',
$this->ID,
);
}
}