Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023
This commit is contained in:
parent
2720a9ec4b
commit
f3791f1da3
1898 changed files with 54300 additions and 11481 deletions
|
@ -38,8 +38,12 @@ display:
|
|||
table: users_field_data
|
||||
field: changed
|
||||
label: 'Updated date'
|
||||
date_format: html_date
|
||||
plugin_id: date
|
||||
plugin_id: field
|
||||
type: timestamp
|
||||
settings:
|
||||
date_format: html_date
|
||||
custom_date_format: ''
|
||||
timezone: ''
|
||||
entity_type: user
|
||||
entity_field: changed
|
||||
filters: { }
|
||||
|
|
|
@ -0,0 +1,220 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- user
|
||||
id: test_user_roles_rid
|
||||
label: test_user_roles_rid
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: users_field_data
|
||||
base_field: uid
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: none
|
||||
options: { }
|
||||
cache:
|
||||
type: tag
|
||||
options: { }
|
||||
query:
|
||||
type: views_query
|
||||
options:
|
||||
disable_sql_rewrite: false
|
||||
distinct: false
|
||||
replica: false
|
||||
query_comment: ''
|
||||
query_tags: { }
|
||||
exposed_form:
|
||||
type: basic
|
||||
options:
|
||||
submit_button: Apply
|
||||
reset_button: false
|
||||
reset_button_label: Reset
|
||||
exposed_sorts_label: 'Sort by'
|
||||
expose_sort_order: true
|
||||
sort_asc_label: Asc
|
||||
sort_desc_label: Desc
|
||||
pager:
|
||||
type: full
|
||||
options:
|
||||
items_per_page: 10
|
||||
offset: 0
|
||||
id: 0
|
||||
total_pages: null
|
||||
expose:
|
||||
items_per_page: false
|
||||
items_per_page_label: 'Items per page'
|
||||
items_per_page_options: '5, 10, 25, 50'
|
||||
items_per_page_options_all: false
|
||||
items_per_page_options_all_label: '- All -'
|
||||
offset: false
|
||||
offset_label: Offset
|
||||
tags:
|
||||
previous: '‹ previous'
|
||||
next: 'next ›'
|
||||
first: '« first'
|
||||
last: 'last »'
|
||||
quantity: 9
|
||||
style:
|
||||
type: default
|
||||
options:
|
||||
grouping: { }
|
||||
row_class: ''
|
||||
default_row_class: true
|
||||
uses_fields: false
|
||||
row:
|
||||
type: fields
|
||||
options:
|
||||
inline: { }
|
||||
separator: ''
|
||||
hide_empty: false
|
||||
default_field_elements: true
|
||||
fields:
|
||||
name:
|
||||
id: name
|
||||
table: users_field_data
|
||||
field: name
|
||||
entity_type: user
|
||||
entity_field: name
|
||||
label: ''
|
||||
alter:
|
||||
alter_text: false
|
||||
make_link: false
|
||||
absolute: false
|
||||
trim: false
|
||||
word_boundary: false
|
||||
ellipsis: false
|
||||
strip_tags: false
|
||||
html: false
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
plugin_id: field
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
exclude: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: true
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_alter_empty: true
|
||||
click_sort_column: value
|
||||
type: user_name
|
||||
settings: { }
|
||||
group_column: value
|
||||
group_columns: { }
|
||||
group_rows: true
|
||||
delta_limit: 0
|
||||
delta_offset: 0
|
||||
delta_reversed: false
|
||||
delta_first_last: false
|
||||
multi_type: separator
|
||||
separator: ', '
|
||||
field_api_classes: false
|
||||
filters:
|
||||
status:
|
||||
value: true
|
||||
table: users_field_data
|
||||
field: status
|
||||
plugin_id: boolean
|
||||
entity_type: user
|
||||
entity_field: status
|
||||
id: status
|
||||
expose:
|
||||
operator: ''
|
||||
group: 1
|
||||
sorts:
|
||||
uid:
|
||||
id: uid
|
||||
table: users
|
||||
field: uid
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
order: ASC
|
||||
exposed: false
|
||||
expose:
|
||||
label: ''
|
||||
entity_type: user
|
||||
entity_field: uid
|
||||
plugin_id: standard
|
||||
header: { }
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships: { }
|
||||
arguments:
|
||||
roles_target_id:
|
||||
id: roles_target_id
|
||||
table: user__roles
|
||||
field: roles_target_id
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
default_action: empty
|
||||
exception:
|
||||
value: all
|
||||
title_enable: false
|
||||
title: All
|
||||
title_enable: true
|
||||
title: '%1'
|
||||
default_argument_type: fixed
|
||||
default_argument_options:
|
||||
argument: ''
|
||||
default_argument_skip_url: false
|
||||
summary_options:
|
||||
base_path: ''
|
||||
count: true
|
||||
items_per_page: 25
|
||||
override: false
|
||||
summary:
|
||||
sort_order: asc
|
||||
number_of_records: 0
|
||||
format: default_summary
|
||||
specify_validation: false
|
||||
validate:
|
||||
type: none
|
||||
fail: 'not found'
|
||||
validate_options: { }
|
||||
break_phrase: false
|
||||
add_table: false
|
||||
require_value: false
|
||||
reduce_duplicates: false
|
||||
plugin_id: user__roles_rid
|
||||
display_extenders: { }
|
||||
cache_metadata:
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- url
|
||||
- url.query_args
|
||||
- user.permissions
|
||||
cacheable: false
|
||||
page_1:
|
||||
display_plugin: page
|
||||
id: page_1
|
||||
display_title: Page
|
||||
position: 1
|
||||
display_options:
|
||||
display_extenders: { }
|
||||
path: user_roles_rid_test
|
||||
cache_metadata:
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- url
|
||||
- url.query_args
|
||||
- user.permissions
|
||||
cacheable: false
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\user\Unit\Migrate\ProfileFieldTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\user\Unit\Migrate;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests profile_field source plugin.
|
||||
*
|
||||
* @group user
|
||||
*/
|
||||
class ProfileFieldTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\user\Plugin\migrate\source\ProfileField';
|
||||
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test_profile_fields',
|
||||
'source' => [
|
||||
'plugin' => 'd6_profile_field',
|
||||
],
|
||||
];
|
||||
|
||||
// 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,
|
||||
'title' => 'First name',
|
||||
'name' => 'profile_first_name',
|
||||
'explanation' => 'First name user',
|
||||
'category' => 'profile',
|
||||
'page' => '',
|
||||
'type' => 'textfield',
|
||||
'weight' => 0,
|
||||
'required' => 1,
|
||||
'register' => 0,
|
||||
'visibility' => 2,
|
||||
'autocomplete' => 0,
|
||||
'options' => [],
|
||||
],
|
||||
[
|
||||
'fid' => 2,
|
||||
'title' => 'Last name',
|
||||
'name' => 'profile_last_name',
|
||||
'explanation' => 'Last name user',
|
||||
'category' => 'profile',
|
||||
'page' => '',
|
||||
'type' => 'textfield',
|
||||
'weight' => 0,
|
||||
'required' => 0,
|
||||
'register' => 0,
|
||||
'visibility' => 2,
|
||||
'autocomplete' => 0,
|
||||
'options' => [],
|
||||
],
|
||||
[
|
||||
'fid' => 3,
|
||||
'title' => 'Policy',
|
||||
'name' => 'profile_policy',
|
||||
'explanation' => 'A checkbox that say if you accept policy of website',
|
||||
'category' => 'profile',
|
||||
'page' => '',
|
||||
'type' => 'checkbox',
|
||||
'weight' => 0,
|
||||
'required' => 1,
|
||||
'register' => 1,
|
||||
'visibility' => 2,
|
||||
'autocomplete' => 0,
|
||||
'options' => [],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Prepopulate contents with results.
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['profile_fields'] = $this->expectedResults;
|
||||
foreach ($this->databaseContents['profile_fields'] as &$row) {
|
||||
$row['options'] = serialize([]);
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
86
core/modules/user/tests/src/Unit/Migrate/d6/RoleTest.php
Normal file
86
core/modules/user/tests/src/Unit/Migrate/d6/RoleTest.php
Normal file
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\user\Unit\Migrate\d6\RoleTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\user\Unit\Migrate\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 role source plugin.
|
||||
*
|
||||
* @group user
|
||||
*/
|
||||
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',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'rid' => 1,
|
||||
'name' => 'anonymous user',
|
||||
'permissions' => array(
|
||||
'access content',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'rid' => 2,
|
||||
'name' => 'authenticated user',
|
||||
'permissions' => array(
|
||||
'access comments',
|
||||
'access content',
|
||||
'post comments',
|
||||
'post comments without approval',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'rid' => 3,
|
||||
'name' => 'administrator',
|
||||
'permissions' => array(
|
||||
'access comments',
|
||||
'administer comments',
|
||||
'post comments',
|
||||
'post comments without approval',
|
||||
'access content',
|
||||
'administer content types',
|
||||
'administer nodes',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $row) {
|
||||
$this->databaseContents['permission'][] = array(
|
||||
'perm' => implode(', ', $row['permissions']),
|
||||
'rid' => $row['rid'],
|
||||
);
|
||||
unset($row['permissions']);
|
||||
$this->databaseContents['role'][] = $row;
|
||||
}
|
||||
$this->databaseContents['filter_formats'][] = array(
|
||||
'format' => 1,
|
||||
'roles' => '',
|
||||
);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\user\Unit\Migrate\d6\UserPictureTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\user\Unit\Migrate\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 user picture source plugin.
|
||||
*
|
||||
* @group user
|
||||
*/
|
||||
class UserPictureTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\user\Plugin\migrate\source\d6\UserPicture';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test_user_picture',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_user_picture',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'uid' => 1,
|
||||
'access' => 1382835435,
|
||||
'picture' => 'sites/default/files/pictures/picture-1.jpg',
|
||||
),
|
||||
array(
|
||||
'uid' => 2,
|
||||
'access' => 1382835436,
|
||||
'picture' => 'sites/default/files/pictures/picture-2.jpg',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['users'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
88
core/modules/user/tests/src/Unit/Migrate/d6/UserTest.php
Normal file
88
core/modules/user/tests/src/Unit/Migrate/d6/UserTest.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\user\Unit\Migrate\d6\UserTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\user\Unit\Migrate\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 user source plugin.
|
||||
*
|
||||
* @group user
|
||||
*/
|
||||
class UserTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\user\Plugin\migrate\source\d6\User';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_user',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'uid' => 2,
|
||||
'name' => 'admin',
|
||||
// @todo d6 hash?
|
||||
'pass' => '1234',
|
||||
'mail' => 'admin@example.com',
|
||||
'theme' => '',
|
||||
'signature' => '',
|
||||
'signature_format' => 0,
|
||||
'created' => 1279402616,
|
||||
'access' => 1322981278,
|
||||
'login' => 1322699994,
|
||||
'status' => 0,
|
||||
'timezone' => 'America/Lima',
|
||||
'language' => 'en',
|
||||
// @todo Add the file when needed.
|
||||
'picture' => 'sites/default/files/pictures/picture-1.jpg',
|
||||
'init' => 'admin@example.com',
|
||||
'data' => NULL,
|
||||
),
|
||||
array(
|
||||
'uid' => 4,
|
||||
'name' => 'alice',
|
||||
// @todo d6 hash?
|
||||
'pass' => '1234',
|
||||
'mail' => 'alice@example.com',
|
||||
'theme' => '',
|
||||
'signature' => '',
|
||||
'signature_format' => 0,
|
||||
'created' => 1322981368,
|
||||
'access' => 1322982419,
|
||||
'login' => 132298140,
|
||||
'status' => 0,
|
||||
'timezone' => 'America/Lima',
|
||||
'language' => 'en',
|
||||
'picture' => '',
|
||||
'init' => 'alice@example.com',
|
||||
'data' => NULL,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
$this->databaseContents['users'][$k] = $row;
|
||||
}
|
||||
// getDatabase() will not create empty tables, so we need to insert data
|
||||
// even if it's irrelevant to the test.
|
||||
$this->databaseContents['users_roles'] = array(
|
||||
array(
|
||||
'uid' => 99,
|
||||
'rid' => 99,
|
||||
),
|
||||
);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -11,6 +11,8 @@ use Drupal\Core\Access\AccessResult;
|
|||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\user\Access\PermissionAccessCheck;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Drupal\Core\Cache\Context\CacheContextsManager;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\user\Access\PermissionAccessCheck
|
||||
|
@ -26,12 +28,24 @@ class PermissionAccessCheckTest extends UnitTestCase {
|
|||
*/
|
||||
public $accessCheck;
|
||||
|
||||
/**
|
||||
* The dependency injection container.
|
||||
*
|
||||
* @var \Symfony\Component\DependencyInjection\ContainerBuilder
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->container = new ContainerBuilder();
|
||||
$cache_contexts_manager = $this->prophesize(CacheContextsManager::class)->reveal();
|
||||
$this->container->set('cache_contexts_manager', $cache_contexts_manager);
|
||||
\Drupal::setContainer($this->container);
|
||||
|
||||
$this->accessCheck = new PermissionAccessCheck();
|
||||
}
|
||||
|
||||
|
@ -41,15 +55,13 @@ class PermissionAccessCheckTest extends UnitTestCase {
|
|||
* @return array
|
||||
*/
|
||||
public function providerTestAccess() {
|
||||
$allowed = AccessResult::allowedIf(TRUE)->addCacheContexts(['user.permissions']);
|
||||
$neutral = AccessResult::allowedIf(FALSE)->addCacheContexts(['user.permissions']);
|
||||
return [
|
||||
[[], AccessResult::allowedIf(FALSE)],
|
||||
[['_permission' => 'allowed'], $allowed],
|
||||
[['_permission' => 'denied'], $neutral],
|
||||
[['_permission' => 'allowed+denied'], $allowed],
|
||||
[['_permission' => 'allowed+denied+other'], $allowed],
|
||||
[['_permission' => 'allowed,denied'], $neutral],
|
||||
[[], FALSE],
|
||||
[['_permission' => 'allowed'], TRUE, ['user.permissions']],
|
||||
[['_permission' => 'denied'], FALSE, ['user.permissions']],
|
||||
[['_permission' => 'allowed+denied'], TRUE, ['user.permissions']],
|
||||
[['_permission' => 'allowed+denied+other'], TRUE, ['user.permissions']],
|
||||
[['_permission' => 'allowed,denied'], FALSE, ['user.permissions']],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -59,7 +71,8 @@ class PermissionAccessCheckTest extends UnitTestCase {
|
|||
* @dataProvider providerTestAccess
|
||||
* @covers ::access
|
||||
*/
|
||||
public function testAccess($requirements, $access) {
|
||||
public function testAccess($requirements, $access, array $contexts = []) {
|
||||
$access_result = AccessResult::allowedIf($access)->addCacheContexts($contexts);
|
||||
$user = $this->getMock('Drupal\Core\Session\AccountInterface');
|
||||
$user->expects($this->any())
|
||||
->method('hasPermission')
|
||||
|
@ -71,7 +84,7 @@ class PermissionAccessCheckTest extends UnitTestCase {
|
|||
));
|
||||
$route = new Route('', [], $requirements);
|
||||
|
||||
$this->assertEquals($access, $this->accessCheck->access($route, $user));
|
||||
$this->assertEquals($access_result, $this->accessCheck->access($route, $user));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\user\Unit\Plugin\migrate\source\d7\RoleTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\user\Unit\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D7 role source plugin.
|
||||
*
|
||||
* @group user
|
||||
*/
|
||||
class RoleTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\user\Plugin\migrate\source\d7\Role';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd7_user_role',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'rid' => 1,
|
||||
'name' => 'anonymous user',
|
||||
'permissions' => array(
|
||||
'access content',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'rid' => 2,
|
||||
'name' => 'authenticated user',
|
||||
'permissions' => array(
|
||||
'access comments',
|
||||
'access content',
|
||||
'post comments',
|
||||
'post comments without approval',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'rid' => 3,
|
||||
'name' => 'administrator',
|
||||
'permissions' => array(
|
||||
'access comments',
|
||||
'administer comments',
|
||||
'post comments',
|
||||
'post comments without approval',
|
||||
'access content',
|
||||
'administer content types',
|
||||
'administer nodes',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $row) {
|
||||
foreach ($row['permissions'] as $permission) {
|
||||
$this->databaseContents['role_permission'][] = array(
|
||||
'permission' => $permission,
|
||||
'rid' => $row['rid'],
|
||||
);
|
||||
}
|
||||
unset($row['permissions']);
|
||||
$this->databaseContents['role'][] = $row;
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\user\Unit\Plugin\migrate\source\d7\UserTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\user\Unit\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D7 user source plugin.
|
||||
*
|
||||
* @group user
|
||||
*/
|
||||
class UserTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\user\Plugin\migrate\source\d7\User';
|
||||
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'source' => [
|
||||
'plugin' => 'd7_user',
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'uid' => '2',
|
||||
'name' => 'Odo',
|
||||
'pass' => '$S$DVpvPItXvnsmF3giVEe7Jy2lG.SCoEs8uKwpHsyPvdeNAaNZYxZ8',
|
||||
'mail' => 'odo@local.host',
|
||||
'signature' => '',
|
||||
'signature_format' => 'filtered_html',
|
||||
'created' => '1432750741',
|
||||
'access' => '0',
|
||||
'login' => '0',
|
||||
'status' => '1',
|
||||
'timezone' => 'America/Chicago',
|
||||
'language' => '',
|
||||
'picture' => '0',
|
||||
'init' => 'odo@local.host',
|
||||
'roles' => [2],
|
||||
'data' => [
|
||||
'contact' => 1,
|
||||
],
|
||||
'field_file' => [
|
||||
[
|
||||
'fid' => 99,
|
||||
'display' => 1,
|
||||
'description' => 'None',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['users'][] = [
|
||||
'uid' => '2',
|
||||
'name' => 'Odo',
|
||||
'pass' => '$S$DVpvPItXvnsmF3giVEe7Jy2lG.SCoEs8uKwpHsyPvdeNAaNZYxZ8',
|
||||
'mail' => 'odo@local.host',
|
||||
'theme' => '',
|
||||
'signature' => '',
|
||||
'signature_format' => 'filtered_html',
|
||||
'created' => '1432750741',
|
||||
'access' => '0',
|
||||
'login' => '0',
|
||||
'status' => '1',
|
||||
'timezone' => 'America/Chicago',
|
||||
'language' => '',
|
||||
'picture' => '0',
|
||||
'init' => 'odo@local.host',
|
||||
'data' => 'a:1:{s:7:"contact";i:1;}',
|
||||
];
|
||||
$this->databaseContents['users_roles'][] = [
|
||||
'uid' => 2,
|
||||
'rid' => 2,
|
||||
];
|
||||
$this->databaseContents['role'][] = [
|
||||
'rid' => 2,
|
||||
'name' => 'authenticated user',
|
||||
'weight' => 0,
|
||||
];
|
||||
$this->databaseContents['field_config_instance'] = [
|
||||
[
|
||||
'id' => '33',
|
||||
'field_id' => '11',
|
||||
'field_name' => 'field_file',
|
||||
'entity_type' => 'user',
|
||||
'bundle' => 'user',
|
||||
'data' => 'a:0:{}',
|
||||
'deleted' => '0',
|
||||
],
|
||||
];
|
||||
$this->databaseContents['field_data_field_file'] = [
|
||||
[
|
||||
'entity_type' => 'user',
|
||||
'bundle' => 'user',
|
||||
'deleted' => 0,
|
||||
'entity_id' => 2,
|
||||
'revision_id' => NULL,
|
||||
'language' => 'und',
|
||||
'delta' => 0,
|
||||
'field_file_fid' => 99,
|
||||
'field_file_display' => 1,
|
||||
'field_file_description' => 'None',
|
||||
],
|
||||
];
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -7,8 +7,9 @@
|
|||
|
||||
namespace Drupal\Tests\user\Unit;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
use Drupal\Core\Cache\Context\CacheContextsManager;
|
||||
use Drupal\Core\DependencyInjection\Container;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\user\UserAccessControlHandler;
|
||||
|
||||
|
@ -62,6 +63,12 @@ class UserAccessControlHandlerTest extends UnitTestCase {
|
|||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$cache_contexts_manager = $this->prophesize(CacheContextsManager::class)->reveal();
|
||||
$container = new Container();
|
||||
$container->set('cache_contexts_manager', $cache_contexts_manager);
|
||||
\Drupal::setContainer($container);
|
||||
|
||||
$this->viewer = $this->getMock('\Drupal\Core\Session\AccountInterface');
|
||||
$this->viewer
|
||||
->expects($this->any())
|
||||
|
@ -125,13 +132,8 @@ class UserAccessControlHandlerTest extends UnitTestCase {
|
|||
->will($this->returnValue($this->{$target}));
|
||||
|
||||
foreach (array('view' => $view, 'edit' => $edit) as $operation => $result) {
|
||||
$message = SafeMarkup::format("User @field field access returns @result with operation '@op' for @account accessing @target", array(
|
||||
'@field' => $field,
|
||||
'@result' => !isset($result) ? 'null' : ($result ? 'true' : 'false'),
|
||||
'@op' => $operation,
|
||||
'@account' => $viewer,
|
||||
'@target' => $target,
|
||||
));
|
||||
$result_text = !isset($result) ? 'null' : ($result ? 'true' : 'false');
|
||||
$message = "User '$field' field access returns '$result_text' with operation '$operation' for '$viewer' accessing '$target'";
|
||||
$this->assertSame($result, $this->accessControlHandler->fieldAccess($operation, $field_definition, $this->{$viewer}, $this->items), $message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\Tests\user\Unit\Views\Argument;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\user\Entity\Role;
|
||||
|
@ -20,9 +19,9 @@ use Drupal\user\Plugin\views\argument\RolesRid;
|
|||
class RolesRidTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* Tests the title_query method.
|
||||
* Tests the titleQuery method.
|
||||
*
|
||||
* @see \Drupal\user\Plugin\views\argument\RolesRid::title_query()
|
||||
* @covers ::titleQuery
|
||||
*/
|
||||
public function testTitleQuery() {
|
||||
$role1 = new Role(array(
|
||||
|
@ -72,16 +71,16 @@ class RolesRidTest extends UnitTestCase {
|
|||
$roles_rid_argument = new RolesRid(array(), 'user__roles_rid', array(), $entity_manager);
|
||||
|
||||
$roles_rid_argument->value = array();
|
||||
$titles = $roles_rid_argument->title_query();
|
||||
$titles = $roles_rid_argument->titleQuery();
|
||||
$this->assertEquals(array(), $titles);
|
||||
|
||||
$roles_rid_argument->value = array('test_rid_1');
|
||||
$titles = $roles_rid_argument->title_query();
|
||||
$titles = $roles_rid_argument->titleQuery();
|
||||
$this->assertEquals(array('test rid 1'), $titles);
|
||||
|
||||
$roles_rid_argument->value = array('test_rid_1', 'test_rid_2');
|
||||
$titles = $roles_rid_argument->title_query();
|
||||
$this->assertEquals(array('test rid 1', SafeMarkup::checkPlain('test <strong>rid 2</strong>')), $titles);
|
||||
$titles = $roles_rid_argument->titleQuery();
|
||||
$this->assertEquals(array('test rid 1', 'test <strong>rid 2</strong>'), $titles);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue