From b6f3840510a2ad8e682e0c1f061765fce4db2539 Mon Sep 17 00:00:00 2001 From: Kristiaan Van den Eynde Date: Fri, 26 May 2017 16:56:50 +0200 Subject: [PATCH] interdiff --- .../tests/src/Kernel/TextFormatElementFormTest.php | 7 ++++--- core/modules/user/src/Tests/UserPermissionsTest.php | 4 ---- .../tests/src/Kernel/Migrate/d6/MigrateUserTest.php | 5 ----- .../src/Kernel/Views/UserViewsFieldAccessTest.php | 18 ------------------ .../src/Kernel/Handler/FieldFieldAccessTestBase.php | 2 +- .../Element/EntityAutocompleteElementFormTest.php | 7 +++++++ 6 files changed, 12 insertions(+), 31 deletions(-) diff --git a/core/modules/filter/tests/src/Kernel/TextFormatElementFormTest.php b/core/modules/filter/tests/src/Kernel/TextFormatElementFormTest.php index 8fca62e..a0ea403 100644 --- a/core/modules/filter/tests/src/Kernel/TextFormatElementFormTest.php +++ b/core/modules/filter/tests/src/Kernel/TextFormatElementFormTest.php @@ -44,15 +44,16 @@ protected function setUp() { $manager = \Drupal::service('plugin.manager.element_info'); $manager->clearCachedDefinitions(); $manager->getDefinitions(); - /* @var \Drupal\filter\FilterFormatInterface $filter_test_format */ - $filter_test_format = FilterFormat::load('filter_test'); /* @var \Drupal\user\RoleInterface $role */ $role = Role::create([ 'id' => 'admin', 'label' => 'admin', ]); - $role->grantPermission($filter_test_format->getPermissionName()); + foreach (FilterFormat::loadMultiple(['full_html', 'filtered_html', 'filter_test']) as $format) { + /* @var \Drupal\filter\FilterFormatInterface $format */ + $role->grantPermission($format->getPermissionName()); + } $role->save(); $this->testUser = User::create([ 'name' => 'foobar', diff --git a/core/modules/user/src/Tests/UserPermissionsTest.php b/core/modules/user/src/Tests/UserPermissionsTest.php index 4f9e260..d8d0bcd 100644 --- a/core/modules/user/src/Tests/UserPermissionsTest.php +++ b/core/modules/user/src/Tests/UserPermissionsTest.php @@ -47,10 +47,6 @@ public function testUserPermissionChanges() { $storage = $this->container->get('entity.manager')->getStorage('user_role'); - // Create an additional role and mark it as admin role. - Role::create(['is_admin' => TRUE, 'id' => 'administrator', 'label' => 'Administrator'])->save(); - $storage->resetCache(); - $this->drupalLogin($this->adminUser); $rid = $this->rid; $account = $this->adminUser; diff --git a/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserTest.php b/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserTest.php index bdeb282..ed28777 100644 --- a/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserTest.php +++ b/core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserTest.php @@ -89,11 +89,6 @@ public function testUser() { ->execute() ->fetchCol(); $roles = [RoleInterface::AUTHENTICATED_ID]; - // The special UID 1 behavior has been replaced by an administrator role - // which is given to UID 1 initially, but can be removed later on. - if ($source->uid == 1) { - $roles[] = RoleInterface::ADMINISTRATOR_ID; - } $id_map = $this->getMigration('d6_user_role')->getIdMap(); foreach ($rids as $rid) { $role = $id_map->lookupDestinationId([$rid]); diff --git a/core/modules/user/tests/src/Kernel/Views/UserViewsFieldAccessTest.php b/core/modules/user/tests/src/Kernel/Views/UserViewsFieldAccessTest.php index f14779e..a443ae9 100644 --- a/core/modules/user/tests/src/Kernel/Views/UserViewsFieldAccessTest.php +++ b/core/modules/user/tests/src/Kernel/Views/UserViewsFieldAccessTest.php @@ -28,22 +28,9 @@ protected function setUp($import_test_views = TRUE) { } public function testUserFields() { - ConfigurableLanguage::create([ - 'id' => 'es', - 'name' => 'Spanish', - ])->save(); - ConfigurableLanguage::create([ - 'id' => 'fr', - 'name' => 'French', - ])->save(); - $user = User::create([ 'name' => 'test user', - 'mail' => 'druplicon@drop.org', 'status' => 1, - 'preferred_langcode' => 'es', - 'preferred_admin_langcode' => 'fr', - 'timezone' => 'ut1', 'created' => 123456, ]); @@ -54,12 +41,7 @@ public function testUserFields() { $this->assertFieldAccess('user', 'uid', $user->id()); $this->assertFieldAccess('user', 'uuid', $user->uuid()); $this->assertFieldAccess('user', 'langcode', $user->language()->getName()); - $this->assertFieldAccess('user', 'preferred_langcode', 'Spanish'); - $this->assertFieldAccess('user', 'preferred_admin_langcode', 'French'); $this->assertFieldAccess('user', 'name', 'test user'); - // $this->assertFieldAccess('user', 'mail', 'druplicon@drop.org'); - $this->assertFieldAccess('user', 'timezone', 'ut1'); - $this->assertFieldAccess('user', 'status', 'On'); // $this->assertFieldAccess('user', 'created', \Drupal::service('date.formatter')->format(123456)); // $this->assertFieldAccess('user', 'changed', \Drupal::service('date.formatter')->format(REQUEST_TIME)); } diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldFieldAccessTestBase.php b/core/modules/views/tests/src/Kernel/Handler/FieldFieldAccessTestBase.php index 5ff77bc..d5617b5 100644 --- a/core/modules/views/tests/src/Kernel/Handler/FieldFieldAccessTestBase.php +++ b/core/modules/views/tests/src/Kernel/Handler/FieldFieldAccessTestBase.php @@ -42,7 +42,7 @@ protected function setUp($import_test_views = TRUE) { $role_with_access = Role::create([ 'id' => 'with_access', - 'permissions' => ['view test entity field'], + 'permissions' => ['view test entity field', 'access content'], ]); $role_with_access->save(); $role_without_access = Role::create([ diff --git a/core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php b/core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php index 5d7ea0e..ee9316c 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php @@ -10,6 +10,7 @@ use Drupal\entity_test\Entity\EntityTest; use Drupal\entity_test\Entity\EntityTestStringId; use Drupal\KernelTests\Core\Entity\EntityKernelTestBase; +use Drupal\user\Entity\Role; use Drupal\user\Entity\User; /** @@ -50,9 +51,15 @@ protected function setUp() { $this->installEntitySchema('entity_test_string_id'); \Drupal::service('router.builder')->rebuild(); + Role::create([ + 'id' => 'test_role', + 'label' => 'Can view test entities', + 'permissions' => ['view test entity'], + ])->save(); $this->testUser = User::create([ 'name' => 'foobar1', 'mail' => 'foobar1@example.com', + 'roles' => ['test_role'], ]); $this->testUser->save(); \Drupal::service('current_user')->setAccount($this->testUser); -- 2.8.1