mirror of
https://github.com/silverstripe/silverstripe-spamprotection.git
synced 2024-10-22 14:05:59 +02:00
FIX Ensure getIcon returns exposed resource URL for icon
This commit is contained in:
parent
654f45292c
commit
47eef922c7
@ -259,15 +259,14 @@ class EditableSpamProtectionField extends EditableFormField
|
|||||||
|
|
||||||
public function getIcon()
|
public function getIcon()
|
||||||
{
|
{
|
||||||
// Get the end of the full qualified class name
|
|
||||||
$shortClass = end(explode("\\", __CLASS__));
|
|
||||||
|
|
||||||
$resource = ModuleLoader::getModule('silverstripe/spamprotection')
|
$resource = ModuleLoader::getModule('silverstripe/spamprotection')
|
||||||
->getResource('images/' . strtolower($shortClass) . '.png');
|
->getResource('images/editablespamprotectionfield.png');
|
||||||
|
|
||||||
if ($resource->exists()) {
|
if (!$resource->exists()) {
|
||||||
return $resource->getRelativePath();
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $resource->getURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showInReports()
|
public function showInReports()
|
||||||
|
@ -111,6 +111,13 @@ class EditableSpamProtectionFieldTest extends SapphireTest
|
|||||||
$this->assertSame('baz', $field->spamMapValue('bar'));
|
$this->assertSame('baz', $field->spamMapValue('bar'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetIcon()
|
||||||
|
{
|
||||||
|
$field = new EditableSpamProtectionField;
|
||||||
|
|
||||||
|
$this->assertContains('/images/editablespamprotectionfield.png', $field->getIcon());
|
||||||
|
}
|
||||||
|
|
||||||
protected function getFormMock()
|
protected function getFormMock()
|
||||||
{
|
{
|
||||||
$formMock = $this->getMockBuilder(Form::class)
|
$formMock = $this->getMockBuilder(Form::class)
|
||||||
|
Loading…
Reference in New Issue
Block a user