MemcacheSettingsTest.php in Memcache API and Integration 8.2
File
tests/src/Unit/MemcacheSettingsTest.php
View source
<?php
namespace Drupal\Tests\memcache\Unit;
use Drupal\memcache\MemcacheSettings;
use Drupal\Core\Site\Settings;
use Drupal\Tests\UnitTestCase;
class MemcacheSettingsTest extends UnitTestCase {
protected $config = [];
protected $settings;
protected function setUp() {
$this->config = [
'memcache' => [
'servers' => [
'127.0.0.2:12345' => 'default',
],
'bin' => [
'default' => 'default',
],
],
'hash_salt' => $this
->randomMachineName(),
];
$settings = new Settings($this->config);
$this->settings = new MemcacheSettings($settings);
}
public function testGet() {
$this
->assertEquals($this->config['memcache']['servers'], $this->settings
->get('servers'), 'The correct setting was not returned.');
$this
->assertEquals($this->config['memcache']['bin'], $this->settings
->get('bin'), 'The correct setting was not returned.');
$this
->assertEquals('3', $this->settings
->get('three', '3'), 'Default value for a setting not properly returned.');
$this
->assertNull($this->settings
->get('nokey'), 'Non-null value returned for a setting that should not exist.');
}
public function testGetAll() {
$this
->assertEquals($this->config['memcache'], $this->settings
->getAll());
}
}