contrib modules updates
This commit is contained in:
@@ -59,8 +59,8 @@ env:
|
||||
- DRUPAL_TI_BEHAT_DRIVER="phantomjs"
|
||||
- DRUPAL_TI_BEHAT_BROWSER="firefox"
|
||||
|
||||
# Use Drupal 8.3.x to run tests.
|
||||
- DRUPAL_TI_CORE_BRANCH="8.5.x"
|
||||
# Set Drupal version in which to run tests.
|
||||
- DRUPAL_TI_CORE_BRANCH="8.6.x"
|
||||
|
||||
# PHPUnit specific commandline arguments.
|
||||
- DRUPAL_TI_PHPUNIT_ARGS="--verbose --debug"
|
||||
|
||||
@@ -5,8 +5,8 @@ type: module
|
||||
# core: 8.x
|
||||
configure: redis.admin_display
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-05-30
|
||||
version: '8.x-1.0'
|
||||
# Information added by Drupal.org packaging script on 2018-11-07
|
||||
version: '8.x-1.1'
|
||||
core: '8.x'
|
||||
project: 'redis'
|
||||
datestamp: 1527699489
|
||||
datestamp: 1541600592
|
||||
|
||||
@@ -104,10 +104,7 @@ class PhpRedis extends LockBackendAbstract {
|
||||
$key = $this->getKey($name);
|
||||
$value = $this->client->get($key);
|
||||
|
||||
// In Drupal 7, this method treated the lock as available if the ID did
|
||||
// match. The database backend and test expects it to return FALSE in that
|
||||
// case, updated accordingly.
|
||||
return FALSE === $value;
|
||||
return $value === FALSE || $value === NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -98,10 +98,7 @@ class Predis extends LockBackendAbstract {
|
||||
$key = $this->getKey($name);
|
||||
$value = $this->client->get($key);
|
||||
|
||||
// In Drupal 7, this method treated the lock as available if the ID did
|
||||
// match. The database backend and test expects it to return FALSE in that
|
||||
// case, updated accordingly.
|
||||
return FALSE === $value;
|
||||
return $value === FALSE || $value === NULL;
|
||||
}
|
||||
|
||||
public function release($name) {
|
||||
|
||||
+35
-2
@@ -36,11 +36,12 @@ class RedisLockFunctionalTest extends LockFunctionalTest {
|
||||
chmod($filename, 0666);
|
||||
$contents = file_get_contents($filename);
|
||||
$redis_interface = self::getRedisInterfaceEnv();
|
||||
$contents .= "\n\n" . '$settings[\'container_yamls\'][] = \'modules/redis/example.services.yml\';';
|
||||
$module_path = drupal_get_path('module', 'redis');
|
||||
$contents .= "\n\n" . "\$settings['container_yamls'][] = '$module_path/example.services.yml';";
|
||||
$contents .= "\n\n" . '$settings["redis.connection"]["interface"] = \'' . $redis_interface . '\';';
|
||||
file_put_contents($filename, $contents);
|
||||
$settings = Settings::getAll();
|
||||
$settings['container_yamls'][] = 'modules/redis/example.services.yml';
|
||||
$settings['container_yamls'][] = $module_path . '/example.services.yml';
|
||||
$settings['redis.connection']['interface'] = $redis_interface;
|
||||
new Settings($settings);
|
||||
OpCodeCache::invalidate(DRUPAL_ROOT . '/' . $filename);
|
||||
@@ -53,4 +54,36 @@ class RedisLockFunctionalTest extends LockFunctionalTest {
|
||||
$db_schema->dropTable('semaphore');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function testLockAcquire() {
|
||||
$redis_interface = self::getRedisInterfaceEnv();
|
||||
$lock = $this->container->get('lock');
|
||||
$this->assertInstanceOf('\Drupal\redis\Lock\\' . $redis_interface, $lock);
|
||||
|
||||
// Verify that a lock that has never been acquired is marked as available.
|
||||
// @todo Remove this line when #3002640 lands.
|
||||
// @see https://www.drupal.org/project/drupal/issues/3002640
|
||||
$this->assertTrue($lock->lockMayBeAvailable('system_test_lock_acquire'));
|
||||
|
||||
parent::testLockAcquire();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function testPersistentLock() {
|
||||
$redis_interface = self::getRedisInterfaceEnv();
|
||||
$persistent_lock = $this->container->get('lock.persistent');
|
||||
$this->assertInstanceOf('\Drupal\redis\PersistentLock\\' . $redis_interface, $persistent_lock);
|
||||
|
||||
// Verify that a lock that has never been acquired is marked as available.
|
||||
// @todo Remove this line when #3002640 lands.
|
||||
// @see https://www.drupal.org/project/drupal/issues/3002640
|
||||
$this->assertTrue($persistent_lock->lockMayBeAvailable('lock1'));
|
||||
|
||||
parent::testPersistentLock();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\redis\Kernel;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\Lock\LockBackendInterface;
|
||||
use Drupal\KernelTests\Core\Lock\LockTest;
|
||||
use Drupal\Tests\redis\Traits\RedisTestInterfaceTrait;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Tests the Redis non-persistent lock backend.
|
||||
*
|
||||
* Extends the core test to include test coverage for lockMayBeAvailable()
|
||||
* method invoked on a non-yet acquired lock.
|
||||
*
|
||||
* @group redis
|
||||
*/
|
||||
class RedisLockTest extends LockTest {
|
||||
|
||||
use RedisTestInterfaceTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = [
|
||||
'redis',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function register(ContainerBuilder $container) {
|
||||
self::setUpSettings();
|
||||
parent::register($container);
|
||||
|
||||
$container->register('lock', LockBackendInterface::class)
|
||||
->setFactory([new Reference('redis.lock.factory'), 'get']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->lock = $this->container->get('lock');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function testBackendLockRelease() {
|
||||
$redis_interface = self::getRedisInterfaceEnv();
|
||||
// Verify that the correct lock backend is being instantiated by the
|
||||
// factory.
|
||||
$this->assertInstanceOf('\Drupal\redis\Lock\\' . $redis_interface, $this->lock);
|
||||
|
||||
// Verify that a lock that has never been acquired is marked as available.
|
||||
// @todo Remove this line when #3002640 lands.
|
||||
// @see https://www.drupal.org/project/drupal/issues/3002640
|
||||
$this->assertTrue($this->lock->lockMayBeAvailable('lock_a'));
|
||||
|
||||
parent::testBackendLockRelease();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user