Issue #2632314 by alexpott, amateescu, ivanjaros: PluginSettingsBase::getThirdPartySettings() returns null instead of array

8.2.x
Nathaniel Catchpole 2016-03-30 11:51:58 +09:00
parent 62248090d8
commit c6f9c5a5b6
2 changed files with 39 additions and 1 deletions

View File

@ -99,7 +99,7 @@ abstract class PluginSettingsBase extends PluginBase implements PluginSettingsIn
*/
public function getThirdPartySettings($module = NULL) {
if ($module) {
return isset($this->thirdPartySettings[$module]) ? $this->thirdPartySettings[$module] : NULL;
return isset($this->thirdPartySettings[$module]) ? $this->thirdPartySettings[$module] : [];
}
return $this->thirdPartySettings;
}

View File

@ -0,0 +1,38 @@
<?php
/**
* @file
* Contains \Drupal\Tests\Core\Field\PluginSettingsBaseTest.
*/
namespace Drupal\Tests\Core\Field;
use Drupal\Core\Field\PluginSettingsBase;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\Core\Field\PluginSettingsBase
* @group Field
*/
class PluginSettingsBaseTest extends UnitTestCase {
/**
* @covers ::getThirdPartySettings
*/
public function testGetThirdPartySettings() {
$plugin_settings = new TestPluginSettingsBase();
$this->assertSame([], $plugin_settings->getThirdPartySettings());
$this->assertSame([], $plugin_settings->getThirdPartySettings('test'));
$plugin_settings->setThirdPartySetting('test', 'foo', 'bar');
$this->assertSame(['foo' => 'bar'], $plugin_settings->getThirdPartySettings('test'));
$this->assertSame([], $plugin_settings->getThirdPartySettings('test2'));
}
}
class TestPluginSettingsBase extends PluginSettingsBase {
public function __construct() {
}
}