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