From ac5a01614b10afea69d83f59f14c3cc662edaad5 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Thu, 27 Jul 2017 13:26:43 +1200 Subject: [PATCH] FIX Ensure DMSUploadField called via injection is returned correctly Fixes an incompatibility with SelectUploadField in CWP --- _config/config.yml | 4 ++++ tests/cms/DMSUploadFieldTest.php | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/_config/config.yml b/_config/config.yml index 05cef68..4b7cf18 100644 --- a/_config/config.yml +++ b/_config/config.yml @@ -10,3 +10,7 @@ SiteTree: HtmlEditorField_Toolbar: extensions: - DocumentHtmlEditorFieldToolbar + +# Ensure that if the parent UploadField is overloaded with the injector, that the DMSUploadField is returned +Injector: + DMSUploadField: DMSUploadField diff --git a/tests/cms/DMSUploadFieldTest.php b/tests/cms/DMSUploadFieldTest.php index 6048f86..42969ff 100644 --- a/tests/cms/DMSUploadFieldTest.php +++ b/tests/cms/DMSUploadFieldTest.php @@ -14,6 +14,15 @@ class DMSUploadFieldTest extends SapphireTest $this->field = new DMSUploadField('StubUploadField'); } + /** + * SS 3.x injector will return an overloaded parent of a child class if the child is not injected. + * This is a sanity check. + */ + public function testDmsUploadFieldIsInjectable() + { + $this->assertInstanceOf('DMSUploadField', DMSUploadField::create('Stub')); + } + /** * The validator is coded to always return true. Replace this test if this behaviour changes in future. */