Commit c6f9c5a5 authored by catch's avatar catch

Issue #2632314 by alexpott, amateescu, ivanjaros:...

Issue #2632314 by alexpott, amateescu, ivanjaros: PluginSettingsBase::getThirdPartySettings() returns null instead of array
parent 62248090
......@@ -99,7 +99,7 @@ public function setSetting($key, $value) {
*/
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;
}
......
<?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() {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment