From 90532279de2413bff279b479c15e6ee685d699c5 Mon Sep 17 00:00:00 2001 From: Sabina Talipova Date: Thu, 21 Dec 2023 16:03:00 +1300 Subject: [PATCH] MNT New tests classes to test version tags --- _config/extensions.yml | 13 ++++++ code/versioned/NonVersionedChildObject.php | 18 ++++++++ code/versioned/NonVersionedParentObject.php | 40 ++++++++++++++++ code/versioned/TestPageVersionedObject.php | 46 +++++++++++++++++++ .../TestVersionedObjectModelAdmin.php | 16 +++++++ code/versioned/VersionedChildObject.php | 23 ++++++++++ code/versioned/VersionedParentObject.php | 46 +++++++++++++++++++ 7 files changed, 202 insertions(+) create mode 100644 code/versioned/NonVersionedChildObject.php create mode 100644 code/versioned/NonVersionedParentObject.php create mode 100644 code/versioned/TestPageVersionedObject.php create mode 100644 code/versioned/TestVersionedObjectModelAdmin.php create mode 100644 code/versioned/VersionedChildObject.php create mode 100644 code/versioned/VersionedParentObject.php diff --git a/_config/extensions.yml b/_config/extensions.yml index 8ff7300..5438b08 100644 --- a/_config/extensions.yml +++ b/_config/extensions.yml @@ -15,6 +15,19 @@ SilverStripe\FrameworkTest\Model\Employee: extensions: - SilverStripe\FrameworkTest\Extension\TestDataObjectExtension +SilverStripe\FrameworkTest\Versioned\Model\NonVersionedParentObject: + extensions: + - SilverStripe\FrameworkTest\Extension\TestDataObjectExtension +SilverStripe\FrameworkTest\Versioned\Model\NonVersionedChildObject: + extensions: + - SilverStripe\FrameworkTest\Extension\TestDataObjectExtension +SilverStripe\FrameworkTest\Versioned\Model\VersionedChildObject: + extensions: + - SilverStripe\FrameworkTest\Extension\TestDataObjectExtension +SilverStripe\FrameworkTest\Versioned\Model\VersionedParentObject: + extensions: + - SilverStripe\FrameworkTest\Extension\TestDataObjectExtension + SilverStripe\ORM\DatabaseAdmin: extensions: - SilverStripe\FrameworkTest\GridFieldArbitraryData\DatabaseBuildExtension diff --git a/code/versioned/NonVersionedChildObject.php b/code/versioned/NonVersionedChildObject.php new file mode 100644 index 0000000..ce7062e --- /dev/null +++ b/code/versioned/NonVersionedChildObject.php @@ -0,0 +1,18 @@ +'Varchar(255)', + ]; + + private static $has_one = [ + 'VersionedParentObject' => VersionedParentObject::class, + ]; +} diff --git a/code/versioned/NonVersionedParentObject.php b/code/versioned/NonVersionedParentObject.php new file mode 100644 index 0000000..c25be8c --- /dev/null +++ b/code/versioned/NonVersionedParentObject.php @@ -0,0 +1,40 @@ +'Varchar(255)', + ]; + + private static $has_one = [ + 'TestPageVersionedObject' => TestPageVersionedObject::class, + ]; + + private static $has_many = [ + 'VersionedChildObjects' => VersionedChildObject::class, + ]; + + private static $owns = ['VersionedChildObjects']; + + public function getCMSFields() + { + $fields = parent::getCMSFields(); + + $fields->addFieldToTab('Root.VersionedChildObjects', GridField::create( + 'VersionedChildObjects', + 'VersionedChildObjects', + $this->VersionedChildObjects(), + GridFieldConfig_RecordEditor::create() + )); + + return $fields; + } +} diff --git a/code/versioned/TestPageVersionedObject.php b/code/versioned/TestPageVersionedObject.php new file mode 100644 index 0000000..0fdd718 --- /dev/null +++ b/code/versioned/TestPageVersionedObject.php @@ -0,0 +1,46 @@ + VersionedParentObject::class, + 'NonVersionedParentObjects' => NonVersionedParentObject::class, + ]; + + private static $owns = [ + 'VersionedParentObjects', + 'NonVersionedParentObjects', + ]; + + public function getCMSFields() + { + $fields = parent::getCMSFields(); + + $fields->addFieldToTab('Root.VersionedParentObjects', GridField::create( + 'VersionedParentObjects', + 'VersionedParentObjects', + $this->VersionedParentObjects(), + GridFieldConfig_RecordEditor::create() + )); + + $fields->addFieldToTab('Root.NonVersionedParentObjects', GridField::create( + 'NonVersionedParentObjects', + 'NonVersionedParentObjects', + $this->NonVersionedParentObjects(), + GridFieldConfig_RecordEditor::create() + )); + + return $fields; + } +} diff --git a/code/versioned/TestVersionedObjectModelAdmin.php b/code/versioned/TestVersionedObjectModelAdmin.php new file mode 100644 index 0000000..85cbcdd --- /dev/null +++ b/code/versioned/TestVersionedObjectModelAdmin.php @@ -0,0 +1,16 @@ +'Varchar(255)', + ]; + + private static $has_one = [ + 'NonVersionedParentObject' => NonVersionedParentObject::class, + ]; +} diff --git a/code/versioned/VersionedParentObject.php b/code/versioned/VersionedParentObject.php new file mode 100644 index 0000000..05c9d00 --- /dev/null +++ b/code/versioned/VersionedParentObject.php @@ -0,0 +1,46 @@ +'Varchar(255)', + ]; + + private static $has_one = [ + 'TestPageVersionedObject' => TestPageVersionedObject::class, + ]; + + private static $has_many = [ + 'NonVersionedChildObjects' => NonVersionedChildObject::class, + ]; + + private static $owns = ['NonVersionedChildObjects']; + + public function getCMSFields() + { + $fields = parent::getCMSFields(); + + $fields->addFieldToTab('Root.NonVersionedChildObjects', GridField::create( + 'NonVersionedChildObjects', + 'NonVersionedChildObjects', + $this->NonVersionedChildObjects(), + GridFieldConfig_RecordEditor::create() + )); + + return $fields; + } +}