Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / memcache / tests / src / Unit / MemcacheSettingsTest.php
1 <?php
2
3 namespace Drupal\Tests\memcache\Unit;
4
5 use Drupal\memcache\MemcacheSettings;
6 use Drupal\Core\Site\Settings;
7 use Drupal\Tests\UnitTestCase;
8
9 /**
10  * @coversDefaultClass \Drupal\memcache\MemcacheSettings
11  * @group memcache
12  */
13 class MemcacheSettingsTest extends UnitTestCase {
14
15   /**
16    * Simple settings array to test against.
17    *
18    * @var array
19    */
20   protected $config = [];
21
22   /**
23    * The class under test.
24    *
25    * @var \Drupal\memcache\MemcacheSettings
26    */
27   protected $settings;
28
29   /**
30    * @covers ::__construct
31    */
32   protected function setUp() {
33     $this->config = [
34       'memcache' => [
35         'servers' => ['127.0.0.2:12345' => 'default'],
36         'bin' => ['default' => 'default'],
37       ],
38       'hash_salt' => $this->randomMachineName(),
39     ];
40     $settings = new Settings($this->config);
41     $this->settings = new MemcacheSettings($settings);
42   }
43
44   /**
45    * @covers ::get
46    */
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.');
51
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.');
55   }
56
57   /**
58    * @covers ::getAll
59    */
60   public function testGetAll() {
61     $this->assertEquals($this->config['memcache'], $this->settings->getAll());
62   }
63
64 }