5 * Contains \Drupal\memcache\Tests\DrupalMemcacheConfigTest.
8 namespace Drupal\Tests\memcache\Unit;
10 use Drupal\memcache\DrupalMemcacheConfig;
11 use Drupal\Core\Site\Settings;
12 use Drupal\Tests\UnitTestCase;
15 * @coversDefaultClass \Drupal\memcache\DrupalMemcacheConfig
18 class DrupalMemcacheConfigTest extends UnitTestCase {
21 * Simple settings array to test against.
25 protected $config = [];
28 * The class under test.
30 * @var \Drupal\memcache\DrupalMemcacheConfig
35 * @covers ::__construct
37 protected function setUp(){
40 'servers' => ['127.0.0.2:12345' => 'default'],
41 'bin' => ['default' => 'default']
43 'hash_salt' => $this->randomMachineName(),
45 $settings = new Settings($this->config);
46 $this->settings = new DrupalMemcacheConfig($settings);
52 public function testGet() {
53 // Test stored settings.
54 $this->assertEquals($this->config['memcache']['servers'], $this->settings->get('servers'), 'The correct setting was not returned.');
55 $this->assertEquals($this->config['memcache']['bin'], $this->settings->get('bin'), 'The correct setting was not returned.');
57 // Test setting that isn't stored with default.
58 $this->assertEquals('3', $this->settings->get('three', '3'), 'Default value for a setting not properly returned.');
59 $this->assertNull($this->settings->get('nokey'), 'Non-null value returned for a setting that should not exist.');
65 public function testGetAll() {
66 $this->assertEquals($this->config['memcache'], $this->settings->getAll());