Skip to content

Commit

Permalink
Merge pull request #60 from creative-commoners/pulls/3.0/ican
Browse files Browse the repository at this point in the history
FIX Ensure getIcon returns exposed resource URL for icon
  • Loading branch information
NightJar committed Nov 3, 2017
2 parents 654f452 + 47eef92 commit 1dda806
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 5 additions & 6 deletions code/EditableSpamProtectionField.php
Expand Up @@ -259,15 +259,14 @@ public function getRequired()

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()
Expand Down
7 changes: 7 additions & 0 deletions tests/EditableSpamProtectionFieldTest.php
Expand Up @@ -111,6 +111,13 @@ public function testSpamMapSettingsAreSerialised()
$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)
Expand Down

0 comments on commit 1dda806

Please sign in to comment.