Skip to content
Snippets Groups Projects
Commit 3b967741 authored by Jakob P's avatar Jakob P
Browse files

Issue #2996055 by japerry, ericgsmith, Wim Leers: Test coverage

parent ae689e0c
No related branches found
No related tags found
1 merge request!30Expand test platforms.
Pipeline #222038 passed with warnings
......@@ -8,6 +8,13 @@ include:
variables:
_PHPUNIT_CONCURRENT: '1'
SKIP_CSPELL: 1
OPT_IN_TEST_PREVIOUS_MAJOR: 1
OPT_IN_TEST_PREVIOUS_MINOR: 1
OPT_IN_TEST_NEXT_MINOR: 1
OPT_IN_TEST_NEXT_MAJOR: 1
OPT_IN_TEST_MAX_PHP: 1
#
# Start custom overrides.
#
......@@ -36,4 +43,4 @@ phpunit:
# Show more log output
_PHPUNIT_EXTRA: --verbose
# Convenient, and we have no secrets.
_SHOW_ENVIRONMENT_VARIABLES: '1'
_SHOW_ENVIRONMENT_VARIABLES: 1
......@@ -243,8 +243,9 @@ abstract class DriverBase implements DrupalMemcacheInterface {
*/
public function getServers() {
$memcache_servers = \Drupal::configFactory()->getEditable('memcache.settings')->get('memcache_servers');
$host = getenv('MEMCACHED_HOST') ?: '127.0.0.1:11211';
if (!isset($memcache_servers)) {
$memcache_servers = ['127.0.0.1:11211' => 'default'];
$memcache_servers = [$host => 'default'];
}
return $memcache_servers;
......
......@@ -17,7 +17,7 @@ class MemcachedDriver extends DriverBase {
$result = $this->memcache->set($full_key, $value, $exp);
// Something bad happened. Let's log the problem.
if (!$result && $this->settings->get('debug')) {
if (!$result || $this->settings->get('debug')) {
$result_code = $this->memcache->getResultCode();
$result_message = $this->memcache->getResultMessage();
......
<?php
namespace Drupal\memcache\Tests;
namespace Drupal\Tests\memcache\Functional;
use Drupal\Tests\system\Functional\Lock\LockFunctionalTest;
......@@ -18,4 +18,26 @@ class MemcacheLockFunctionalTest extends LockFunctionalTest {
*/
protected static $modules = ['system_test', 'memcache', 'memcache_test'];
public function setUp(): void {
parent::setUp();
$host = getenv('MEMCACHED_HOST') ?: '127.0.0.1:11211';
$settings['settings']['memcache'] = (object) [
'value' => [
'servers' => [$host => 'default'],
'bin' => ['default' => 'default'],
],
'required' => TRUE,
];
$settings['settings']['hash_salt'] = (object) [
'value' => $this->randomMachineName(),
'required' => TRUE,
];
$this->writeSettings($settings);
}
public function testLockAcquire(): void {
parent::testLockAcquire();
}
}
......@@ -30,6 +30,15 @@ class MemcacheBackendTest extends GenericCacheBackendUnitTestBase implements Ser
$service_definition->setArgument(2, 0);
}
public function setUp(): void {
parent::setUp();
$host = getenv('MEMCACHED_HOST') ?: '127.0.0.1:11211';
$this->setSetting('memcache', [
'servers' => [$host => 'default'],
'bin' => ['default' => 'default'],
'debug' => TRUE,
]);
}
/**
* Creates a new instance of DatabaseBackend.
*
......@@ -46,4 +55,16 @@ class MemcacheBackendTest extends GenericCacheBackendUnitTestBase implements Ser
return $factory->get($bin);
}
/**
* Gets a backend to test; this will get a shared instance set in the object.
*
* @return \Drupal\Core\Cache\CacheBackendInterface
* Cache backend to test.
*/
protected function getCacheBackend($bin = NULL) {
$backend = parent::getCacheBackend($bin);
usleep(10000);
return $backend;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment