diff --git a/code/EditableSpamProtectionField.php b/code/EditableSpamProtectionField.php index 790cefb..88aeb73 100644 --- a/code/EditableSpamProtectionField.php +++ b/code/EditableSpamProtectionField.php @@ -259,15 +259,14 @@ class EditableSpamProtectionField extends EditableFormField public function getIcon() { - // Get the end of the full qualified class name - $shortClass = end(explode("\\", __CLASS__)); - $resource = ModuleLoader::getModule('silverstripe/spamprotection') - ->getResource('images/' . strtolower($shortClass) . '.png'); + ->getResource('images/editablespamprotectionfield.png'); - if ($resource->exists()) { - return $resource->getRelativePath(); + if (!$resource->exists()) { + return ''; } + + return $resource->getURL(); } public function showInReports() diff --git a/tests/EditableSpamProtectionFieldTest.php b/tests/EditableSpamProtectionFieldTest.php index 1729721..11010b0 100644 --- a/tests/EditableSpamProtectionFieldTest.php +++ b/tests/EditableSpamProtectionFieldTest.php @@ -111,6 +111,13 @@ class EditableSpamProtectionFieldTest extends SapphireTest $this->assertSame('baz', $field->spamMapValue('bar')); } + public function testGetIcon() + { + $field = new EditableSpamProtectionField; + + $this->assertContains('/images/editablespamprotectionfield.png', $field->getIcon()); + } + protected function getFormMock() { $formMock = $this->getMockBuilder(Form::class)