3 namespace Drupal\Tests\memcache\Unit;
5 use Drupal\memcache\MemcacheSettings;
6 use Drupal\Core\Site\Settings;
7 use Drupal\Tests\UnitTestCase;
10 * @coversDefaultClass \Drupal\memcache\MemcacheSettings
13 class MemcacheSettingsTest extends UnitTestCase {
16 * Simple settings array to test against.
20 protected $config = [];
23 * The class under test.
25 * @var \Drupal\memcache\MemcacheSettings
30 * @covers ::__construct
32 protected function setUp() {
35 'servers' => ['127.0.0.2:12345' => 'default'],
36 'bin' => ['default' => 'default'],
38 'hash_salt' => $this->randomMachineName(),
40 $settings = new Settings($this->config);
41 $this->settings = new MemcacheSettings($settings);
47 public function testGet() {
48 // Test stored settings.
49 $this->assertEquals($this->config['memcache']['servers'], $this->settings->get('servers'), 'The correct setting was not returned.');
50 $this->assertEquals($this->config['memcache']['bin'], $this->settings->get('bin'), 'The correct setting was not returned.');
52 // Test setting that isn't stored with default.
53 $this->assertEquals('3', $this->settings->get('three', '3'), 'Default value for a setting not properly returned.');
54 $this->assertNull($this->settings->get('nokey'), 'Non-null value returned for a setting that should not exist.');
60 public function testGetAll() {
61 $this->assertEquals($this->config['memcache'], $this->settings->getAll());