Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -0,0 +1,6 @@
|
|||
name: 'User module hooks tests'
|
||||
type: module
|
||||
description: 'Support module for user hooks testing.'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Support module for user hooks testing.
|
||||
*/
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
|
||||
/**
|
||||
* Implements hook_user_format_name_alter().
|
||||
*/
|
||||
function user_hooks_test_user_format_name_alter(&$name, $account) {
|
||||
if (\Drupal::state()->get('user_hooks_test_user_format_name_alter', FALSE)) {
|
||||
if (\Drupal::state()->get('user_hooks_test_user_format_name_alter_safe', FALSE)) {
|
||||
$name = SafeMarkup::format('<em>@uid</em>', array('@uid' => $account->id()));
|
||||
}
|
||||
else {
|
||||
$name = '<em>' . $account->id() . '</em>';
|
||||
}
|
||||
}
|
||||
}
|
|
@ -58,10 +58,10 @@ display:
|
|||
offset: false
|
||||
offset_label: Offset
|
||||
tags:
|
||||
previous: '‹ previous'
|
||||
next: 'next ›'
|
||||
first: '« first'
|
||||
last: 'last »'
|
||||
previous: '‹ Previous'
|
||||
next: 'Next ›'
|
||||
first: '« First'
|
||||
last: 'Last »'
|
||||
quantity: 9
|
||||
style:
|
||||
type: default
|
||||
|
@ -169,7 +169,7 @@ display:
|
|||
title_enable: false
|
||||
title: All
|
||||
title_enable: true
|
||||
title: '%1'
|
||||
title: '{{ arguments.roles_target_id }}'
|
||||
default_argument_type: fixed
|
||||
default_argument_options:
|
||||
argument: ''
|
||||
|
|
|
@ -28,7 +28,7 @@ display:
|
|||
table: users_field_data
|
||||
field: uid
|
||||
title_enable: true
|
||||
title: '%1'
|
||||
title: '{{ arguments.uid }}'
|
||||
plugin_id: user_uid
|
||||
entity_type: user
|
||||
entity_field: uid
|
||||
|
|
|
@ -51,6 +51,12 @@ display:
|
|||
type: default
|
||||
row:
|
||||
type: fields
|
||||
sorts:
|
||||
uid:
|
||||
id: uid
|
||||
table: users
|
||||
field: uid
|
||||
plugin_id: standard
|
||||
display_plugin: default
|
||||
display_title: Master
|
||||
id: default
|
||||
|
|
|
@ -25,9 +25,6 @@ class ProfileFieldTest extends MigrateSqlSourceTestCase {
|
|||
],
|
||||
];
|
||||
|
||||
// We need to set up the database contents; it's easier to do that below.
|
||||
// These are sample result queries.
|
||||
// @todo Add multiple cases.
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'fid' => 1,
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\user\Unit\Migrate\UserPictureInstanceTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\user\Unit\Migrate;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
use Drupal\user\Plugin\migrate\source\UserPictureInstance;
|
||||
|
||||
/**
|
||||
* Tests user_picture_instance source plugin.
|
||||
*
|
||||
* @group user
|
||||
*/
|
||||
class UserPictureInstanceTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = UserPictureInstance::class;
|
||||
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'source' => [
|
||||
'plugin' => 'user_picture_instance',
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'id' => '',
|
||||
'file_directory' => 'pictures',
|
||||
'max_filesize' => '128KB',
|
||||
'max_resolution' => '128x128',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['variable'] = array(
|
||||
array(
|
||||
'name' => 'file_directory',
|
||||
'value' => serialize(NULL),
|
||||
),
|
||||
array(
|
||||
'name' => 'user_picture_file_size',
|
||||
'value' => serialize(128),
|
||||
),
|
||||
array(
|
||||
'name' => 'user_picture_dimensions',
|
||||
'value' => serialize('128x128'),
|
||||
),
|
||||
);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\user\Unit\Migrate\d6\ProfileFieldValuesTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\user\Unit\Migrate\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
use Drupal\user\Plugin\migrate\source\d6\ProfileFieldValues;
|
||||
|
||||
/**
|
||||
* Tests the d6_profile_field_values source plugin.
|
||||
*
|
||||
* @group user
|
||||
*/
|
||||
class ProfileFieldValuesTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = ProfileFieldValues::class;
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_profile_field_values',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'fid' => '8',
|
||||
'profile_color' => array('red'),
|
||||
'uid' => '2',
|
||||
),
|
||||
array(
|
||||
'fid' => '9',
|
||||
'profile_biography' => array('Lorem ipsum dolor sit amet...'),
|
||||
'uid' => '2',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['profile_values'] = array(
|
||||
array(
|
||||
'fid' => '8',
|
||||
'uid' => '2',
|
||||
'value' => 'red',
|
||||
),
|
||||
array(
|
||||
'fid' => '9',
|
||||
'uid' => '2',
|
||||
'value' => 'Lorem ipsum dolor sit amet...',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['profile_fields'] = array(
|
||||
array(
|
||||
'fid' => '8',
|
||||
'title' => 'Favorite color',
|
||||
'name' => 'profile_color',
|
||||
'explanation' => 'List your favorite color',
|
||||
'category' => 'Personal information',
|
||||
'page' => 'Peole whose favorite color is %value',
|
||||
'type' => 'textfield',
|
||||
'weight' => '-10',
|
||||
'required' => '0',
|
||||
'register' => '1',
|
||||
'visibility' => '2',
|
||||
'autocomplete' => '1',
|
||||
'options' => '',
|
||||
),
|
||||
array(
|
||||
'fid' => '9',
|
||||
'title' => 'Biography',
|
||||
'name' => 'profile_biography',
|
||||
'explanation' => 'Tell people a little bit about yourself',
|
||||
'category' => 'Personal information',
|
||||
'page' => '',
|
||||
'type' => 'textarea',
|
||||
'weight' => '-8',
|
||||
'required' => '0',
|
||||
'register' => '0',
|
||||
'visibility' => '2',
|
||||
'autocomplete' => '0',
|
||||
'options' => '',
|
||||
),
|
||||
);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -16,16 +16,10 @@ use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
|||
*/
|
||||
class RoleTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\user\Plugin\migrate\source\d6\Role';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
// This needs to be the identifier of the actual key: cid for comment, nid
|
||||
// for node and so on.
|
||||
'source' => array(
|
||||
'plugin' => 'd6_user_role',
|
||||
),
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\user\Unit\Migrate\d6\UserPictureFileTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\user\Unit\Migrate\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
use Drupal\user\Plugin\migrate\source\d6\UserPictureFile;
|
||||
|
||||
/**
|
||||
* Tests the d6_user_picture_file source plugin.
|
||||
*
|
||||
* @group user
|
||||
*/
|
||||
class UserPictureFileTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = UserPictureFile::class;
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_user_picture_file',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'uid' => '2',
|
||||
'picture' => 'core/modules/simpletest/files/image-test.jpg',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['users'] = array(
|
||||
array(
|
||||
'uid' => '2',
|
||||
'picture' => 'core/modules/simpletest/files/image-test.jpg',
|
||||
),
|
||||
array(
|
||||
'uid' => '15',
|
||||
'picture' => '',
|
||||
),
|
||||
);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -42,7 +42,9 @@ class PermissionAccessCheckTest extends UnitTestCase {
|
|||
parent::setUp();
|
||||
|
||||
$this->container = new ContainerBuilder();
|
||||
$cache_contexts_manager = $this->prophesize(CacheContextsManager::class)->reveal();
|
||||
$cache_contexts_manager = $this->prophesize(CacheContextsManager::class);
|
||||
$cache_contexts_manager->assertValidTokens()->willReturn(TRUE);
|
||||
$cache_contexts_manager->reveal();
|
||||
$this->container->set('cache_contexts_manager', $cache_contexts_manager);
|
||||
\Drupal::setContainer($this->container);
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
namespace Drupal\Tests\user\Unit;
|
||||
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
|
||||
use Drupal\Core\StringTranslation\TranslatableMarkup;
|
||||
use Drupal\Core\StringTranslation\TranslationInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\user\PermissionHandler;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
|
@ -40,7 +43,7 @@ class PermissionHandlerTest extends UnitTestCase {
|
|||
/**
|
||||
* The mocked string translation.
|
||||
*
|
||||
* @var \Drupal\Core\StringTranslation\TranslationInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \Drupal\Tests\user\Unit\TestTranslationManager
|
||||
*/
|
||||
protected $stringTranslation;
|
||||
|
||||
|
@ -57,7 +60,7 @@ class PermissionHandlerTest extends UnitTestCase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->stringTranslation = $this->getStringTranslationStub();
|
||||
$this->stringTranslation = new TestTranslationManager();
|
||||
$this->controllerResolver = $this->getMock('Drupal\Core\Controller\ControllerResolverInterface');
|
||||
}
|
||||
|
||||
|
@ -407,3 +410,31 @@ class TestPermissionCallbacks {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements a translation manager in tests.
|
||||
*/
|
||||
class TestTranslationManager implements TranslationInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function translate($string, array $args = array(), array $options = array()) {
|
||||
return new TranslatableMarkup($string, $args, $options, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function translateString(TranslatableMarkup $translated_string) {
|
||||
return $translated_string->getUntranslatedString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function formatPlural($count, $singular, $plural, array $args = array(), array $options = array()) {
|
||||
return new PluralTranslatableMarkup($count, $singular, $plural, $args, $options, $this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\user\Unit\Plugin\migrate\process\ConvertTokensTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\user\Unit\Plugin\migrate\process;
|
||||
|
||||
use Drupal\user\Plugin\migrate\process\ConvertTokens;
|
||||
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
|
||||
|
||||
/**
|
||||
* Tests the ConvertTokens plugin.
|
||||
*
|
||||
* @group user
|
||||
*/
|
||||
class ConvertTokensTest extends MigrateProcessTestCase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->plugin = new ConvertTokens([], 'convert_tokens', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests conversion of user tokens.
|
||||
*/
|
||||
public function testConvertTokens() {
|
||||
$value = $this->plugin->transform('Account details for !username at !site', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->assertEquals('Account details for [user:name] at [site:name]', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests conversion of user tokens with a NULL value.
|
||||
*/
|
||||
public function testConvertTokensNull() {
|
||||
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->assertEquals('', $value);
|
||||
}
|
||||
|
||||
}
|
|
@ -64,7 +64,9 @@ class UserAccessControlHandlerTest extends UnitTestCase {
|
|||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$cache_contexts_manager = $this->prophesize(CacheContextsManager::class)->reveal();
|
||||
$cache_contexts_manager = $this->prophesize(CacheContextsManager::class);
|
||||
$cache_contexts_manager->assertValidTokens()->willReturn(TRUE);
|
||||
$cache_contexts_manager->reveal();
|
||||
$container = new Container();
|
||||
$container->set('cache_contexts_manager', $cache_contexts_manager);
|
||||
\Drupal::setContainer($container);
|
||||
|
|
|
@ -164,6 +164,33 @@ class UserAuthTest extends UnitTestCase {
|
|||
$this->assertsame(1, $this->userAuth->authenticate($this->username, $this->password));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the authenticate method with a correct password.
|
||||
*
|
||||
* We discovered in https://www.drupal.org/node/2563751 that logging in with a
|
||||
* password that is literally "0" was not possible. This test ensures that
|
||||
* this regression can't happen again.
|
||||
*
|
||||
* @covers ::authenticate
|
||||
*/
|
||||
public function testAuthenticateWithZeroPassword() {
|
||||
$this->testUser->expects($this->once())
|
||||
->method('id')
|
||||
->will($this->returnValue(2));
|
||||
|
||||
$this->userStorage->expects($this->once())
|
||||
->method('loadByProperties')
|
||||
->with(array('name' => $this->username))
|
||||
->will($this->returnValue(array($this->testUser)));
|
||||
|
||||
$this->passwordService->expects($this->once())
|
||||
->method('check')
|
||||
->with(0, 0)
|
||||
->will($this->returnValue(TRUE));
|
||||
|
||||
$this->assertsame(2, $this->userAuth->authenticate($this->username, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the authenticate method with a correct password and new password hash.
|
||||
*
|
||||
|
|
Reference in a new issue