"
+ */
+ public function testReferencedEntity() {
+ $entity_type = $this->entity->getEntityTypeId();
+ $referencing_entity_url = $this->referencingEntity->urlInfo('canonical');
+ $non_referencing_entity_url = $this->nonReferencingEntity->urlInfo('canonical');
+ $listing_url = Url::fromRoute('entity.entity_test.collection_referencing_entities', [
+ 'entity_reference_field_name' => $entity_type . '_reference',
+ 'referenced_entity_type' => $entity_type,
+ 'referenced_entity_id' => $this->entity->id(),
+ ]);
+ $empty_entity_listing_url = Url::fromRoute('entity.entity_test.collection_empty', ['entity_type_id' => $entity_type]);
+ $nonempty_entity_listing_url = Url::fromRoute('entity.entity_test.collection_labels_alphabetically', ['entity_type_id' => $entity_type]);
+
+ // The default cache contexts for rendered entities.
+ $default_cache_contexts = ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme', 'user.permissions'];
+ $entity_cache_contexts = $default_cache_contexts;
+ $page_cache_contexts = Cache::mergeContexts($default_cache_contexts, ['url.query_args:' . MainContentViewSubscriber::WRAPPER_FORMAT]);
+
+ // Cache tags present on every rendered page.
+ // 'user.permissions' is a required cache context, and responses that vary
+ // by this cache context when requested by anonymous users automatically
+ // also get this cache tag, to ensure correct invalidation.
+ $page_cache_tags = Cache::mergeTags(['http_response', 'rendered'], ['config:user.role.anonymous']);
+ // If the block module is used, the Block page display variant is used,
+ // which adds the block config entity type's list cache tags.
+ $page_cache_tags = Cache::mergeTags($page_cache_tags, \Drupal::moduleHandler()->moduleExists('block') ? ['config:block_list'] : []);
+
+ $page_cache_tags_referencing_entity = in_array('user.permissions', $this->getAccessCacheContextsForEntity($this->referencingEntity)) ? ['config:user.role.anonymous'] : [];
+
+ $view_cache_tag = [];
+ if ($this->entity->getEntityType()->hasHandlerClass('view_builder')) {
+ $view_cache_tag = \Drupal::entityManager()->getViewBuilder($entity_type)
+ ->getCacheTags();
+ }
+
+ $context_metadata = \Drupal::service('cache_contexts_manager')->convertTokensToKeys($entity_cache_contexts);
+ $cache_context_tags = $context_metadata->getCacheTags();
+
+ // Generate the cache tags for the (non) referencing entities.
+ $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags());
+ // Includes the main entity's cache tags, since this entity references it.
+ $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $this->entity->getCacheTags());
+ $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $this->getAdditionalCacheTagsForEntity($this->entity));
+ $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $view_cache_tag);
+ $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $cache_context_tags);
+ $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, ['rendered']);
+
+ $non_referencing_entity_cache_tags = Cache::mergeTags($this->nonReferencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags());
+ $non_referencing_entity_cache_tags = Cache::mergeTags($non_referencing_entity_cache_tags, ['rendered']);
+
+ // Generate the cache tags for all two possible entity listing paths.
+ // 1. list cache tag only (listing query has no match)
+ // 2. list cache tag plus entity cache tag (listing query has a match)
+ $empty_entity_listing_cache_tags = Cache::mergeTags($this->entity->getEntityType()->getListCacheTags(), $page_cache_tags);
+
+ $nonempty_entity_listing_cache_tags = Cache::mergeTags($this->entity->getEntityType()->getListCacheTags(), $this->entity->getCacheTags());
+ $nonempty_entity_listing_cache_tags = Cache::mergeTags($nonempty_entity_listing_cache_tags, $this->getAdditionalCacheTagsForEntityListing($this->entity));
+ $nonempty_entity_listing_cache_tags = Cache::mergeTags($nonempty_entity_listing_cache_tags, $page_cache_tags);
+
+ $this->pass("Test referencing entity.", 'Debug');
+ $this->verifyPageCache($referencing_entity_url, 'MISS');
+
+ // Verify a cache hit, but also the presence of the correct cache tags.
+ $expected_tags = Cache::mergeTags($referencing_entity_cache_tags, $page_cache_tags);
+ $expected_tags = Cache::mergeTags($expected_tags, $page_cache_tags_referencing_entity);
+ $this->verifyPageCache($referencing_entity_url, 'HIT', $expected_tags);
+
+ // Also verify the existence of an entity render cache entry.
+ $cache_keys = ['entity_view', 'entity_test', $this->referencingEntity->id(), 'full'];
+ $cid = $this->createCacheId($cache_keys, $entity_cache_contexts);
+ $access_cache_contexts = $this->getAccessCacheContextsForEntity($this->entity);
+ $additional_cache_contexts = $this->getAdditionalCacheContextsForEntity($this->referencingEntity);
+ $redirected_cid = NULL;
+ if (count($access_cache_contexts) || count($additional_cache_contexts)) {
+ $cache_contexts = Cache::mergeContexts($entity_cache_contexts, $additional_cache_contexts);
+ $cache_contexts = Cache::mergeContexts($cache_contexts, $access_cache_contexts);
+ $redirected_cid = $this->createCacheId($cache_keys, $cache_contexts);
+ $context_metadata = \Drupal::service('cache_contexts_manager')->convertTokensToKeys($cache_contexts);
+ $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $context_metadata->getCacheTags());
+ }
+ $this->verifyRenderCache($cid, $referencing_entity_cache_tags, $redirected_cid);
+
+ $this->pass("Test non-referencing entity.", 'Debug');
+ $this->verifyPageCache($non_referencing_entity_url, 'MISS');
+ // Verify a cache hit, but also the presence of the correct cache tags.
+ $this->verifyPageCache($non_referencing_entity_url, 'HIT', Cache::mergeTags($non_referencing_entity_cache_tags, $page_cache_tags));
+ // Also verify the existence of an entity render cache entry.
+ $cache_keys = ['entity_view', 'entity_test', $this->nonReferencingEntity->id(), 'full'];
+ $cid = $this->createCacheId($cache_keys, $entity_cache_contexts);
+ $this->verifyRenderCache($cid, $non_referencing_entity_cache_tags);
+
+
+ $this->pass("Test listing of referencing entities.", 'Debug');
+ // Prime the page cache for the listing of referencing entities.
+ $this->verifyPageCache($listing_url, 'MISS');
+
+ // Verify a cache hit, but also the presence of the correct cache tags.
+ $expected_tags = Cache::mergeTags($referencing_entity_cache_tags, $page_cache_tags);
+ $expected_tags = Cache::mergeTags($expected_tags, $page_cache_tags_referencing_entity);
+ $this->verifyPageCache($listing_url, 'HIT', $expected_tags);
+
+ $this->pass("Test empty listing.", 'Debug');
+ // Prime the page cache for the empty listing.
+ $this->verifyPageCache($empty_entity_listing_url, 'MISS');
+ // Verify a cache hit, but also the presence of the correct cache tags.
+ $this->verifyPageCache($empty_entity_listing_url, 'HIT', $empty_entity_listing_cache_tags);
+ // Verify the entity type's list cache contexts are present.
+ $contexts_in_header = $this->drupalGetHeader('X-Drupal-Cache-Contexts');
+ $this->assertEqual(Cache::mergeContexts($page_cache_contexts, $this->getAdditionalCacheContextsForEntityListing()), empty($contexts_in_header) ? [] : explode(' ', $contexts_in_header));
+
+
+ $this->pass("Test listing containing referenced entity.", 'Debug');
+ // Prime the page cache for the listing containing the referenced entity.
+ $this->verifyPageCache($nonempty_entity_listing_url, 'MISS', $nonempty_entity_listing_cache_tags);
+ // Verify a cache hit, but also the presence of the correct cache tags.
+ $this->verifyPageCache($nonempty_entity_listing_url, 'HIT', $nonempty_entity_listing_cache_tags);
+ // Verify the entity type's list cache contexts are present.
+ $contexts_in_header = $this->drupalGetHeader('X-Drupal-Cache-Contexts');
+ $this->assertEqual(Cache::mergeContexts($page_cache_contexts, $this->getAdditionalCacheContextsForEntityListing()), empty($contexts_in_header) ? [] : explode(' ', $contexts_in_header));
+
+
+ // Verify that after modifying the referenced entity, there is a cache miss
+ // for every route except the one for the non-referencing entity.
+ $this->pass("Test modification of referenced entity.", 'Debug');
+ $this->entity->save();
+ $this->verifyPageCache($referencing_entity_url, 'MISS');
+ $this->verifyPageCache($listing_url, 'MISS');
+ $this->verifyPageCache($empty_entity_listing_url, 'MISS');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'MISS');
+ $this->verifyPageCache($non_referencing_entity_url, 'HIT');
+
+ // Verify cache hits.
+ $this->verifyPageCache($referencing_entity_url, 'HIT');
+ $this->verifyPageCache($listing_url, 'HIT');
+ $this->verifyPageCache($empty_entity_listing_url, 'HIT');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'HIT');
+
+
+ // Verify that after modifying the referencing entity, there is a cache miss
+ // for every route except the ones for the non-referencing entity and the
+ // empty entity listing.
+ $this->pass("Test modification of referencing entity.", 'Debug');
+ $this->referencingEntity->save();
+ $this->verifyPageCache($referencing_entity_url, 'MISS');
+ $this->verifyPageCache($listing_url, 'MISS');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'HIT');
+ $this->verifyPageCache($non_referencing_entity_url, 'HIT');
+ $this->verifyPageCache($empty_entity_listing_url, 'HIT');
+
+ // Verify cache hits.
+ $this->verifyPageCache($referencing_entity_url, 'HIT');
+ $this->verifyPageCache($listing_url, 'HIT');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'HIT');
+
+
+ // Verify that after modifying the non-referencing entity, there is a cache
+ // miss only for the non-referencing entity route.
+ $this->pass("Test modification of non-referencing entity.", 'Debug');
+ $this->nonReferencingEntity->save();
+ $this->verifyPageCache($referencing_entity_url, 'HIT');
+ $this->verifyPageCache($listing_url, 'HIT');
+ $this->verifyPageCache($empty_entity_listing_url, 'HIT');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'HIT');
+ $this->verifyPageCache($non_referencing_entity_url, 'MISS');
+
+ // Verify cache hits.
+ $this->verifyPageCache($non_referencing_entity_url, 'HIT');
+
+
+ if ($this->entity->getEntityType()->hasHandlerClass('view_builder')) {
+ // Verify that after modifying the entity's display, there is a cache miss
+ // for both the referencing entity, and the listing of referencing
+ // entities, but not for any other routes.
+ $referenced_entity_view_mode = $this->selectViewMode($this->entity->getEntityTypeId());
+ $this->pass("Test modification of referenced entity's '$referenced_entity_view_mode' display.", 'Debug');
+ $entity_display = entity_get_display($entity_type, $this->entity->bundle(), $referenced_entity_view_mode);
+ $entity_display->save();
+ $this->verifyPageCache($referencing_entity_url, 'MISS');
+ $this->verifyPageCache($listing_url, 'MISS');
+ $this->verifyPageCache($non_referencing_entity_url, 'HIT');
+ $this->verifyPageCache($empty_entity_listing_url, 'HIT');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'HIT');
+
+ // Verify cache hits.
+ $this->verifyPageCache($referencing_entity_url, 'HIT');
+ $this->verifyPageCache($listing_url, 'HIT');
+ }
+
+
+ if ($bundle_entity_type_id = $this->entity->getEntityType()->getBundleEntityType()) {
+ // Verify that after modifying the corresponding bundle entity, there is a
+ // cache miss for both the referencing entity, and the listing of
+ // referencing entities, but not for any other routes.
+ $this->pass("Test modification of referenced entity's bundle entity.", 'Debug');
+ $bundle_entity = $this->container->get('entity_type.manager')
+ ->getStorage($bundle_entity_type_id)
+ ->load($this->entity->bundle());
+ $bundle_entity->save();
+ $this->verifyPageCache($referencing_entity_url, 'MISS');
+ $this->verifyPageCache($listing_url, 'MISS');
+ $this->verifyPageCache($non_referencing_entity_url, 'HIT');
+ // Special case: entity types may choose to use their bundle entity type
+ // cache tags, to avoid having excessively granular invalidation.
+ $is_special_case = $bundle_entity->getCacheTags() == $this->entity->getCacheTags() && $bundle_entity->getEntityType()->getListCacheTags() == $this->entity->getEntityType()->getListCacheTags();
+ if ($is_special_case) {
+ $this->verifyPageCache($empty_entity_listing_url, 'MISS');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'MISS');
+ }
+ else {
+ $this->verifyPageCache($empty_entity_listing_url, 'HIT');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'HIT');
+ }
+
+ // Verify cache hits.
+ $this->verifyPageCache($referencing_entity_url, 'HIT');
+ $this->verifyPageCache($listing_url, 'HIT');
+ if ($is_special_case) {
+ $this->verifyPageCache($empty_entity_listing_url, 'HIT');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'HIT');
+ }
+ }
+
+
+ if ($this->entity->getEntityType()->get('field_ui_base_route')) {
+ // Verify that after modifying a configurable field on the entity, there
+ // is a cache miss.
+ $this->pass("Test modification of referenced entity's configurable field.", 'Debug');
+ $field_storage_name = $this->entity->getEntityTypeId() . '.configurable_field';
+ $field_storage = FieldStorageConfig::load($field_storage_name);
+ $field_storage->save();
+ $this->verifyPageCache($referencing_entity_url, 'MISS');
+ $this->verifyPageCache($listing_url, 'MISS');
+ $this->verifyPageCache($empty_entity_listing_url, 'HIT');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'HIT');
+ $this->verifyPageCache($non_referencing_entity_url, 'HIT');
+
+ // Verify cache hits.
+ $this->verifyPageCache($referencing_entity_url, 'HIT');
+ $this->verifyPageCache($listing_url, 'HIT');
+
+
+ // Verify that after modifying a configurable field on the entity, there
+ // is a cache miss.
+ $this->pass("Test modification of referenced entity's configurable field.", 'Debug');
+ $field_name = $this->entity->getEntityTypeId() . '.' . $this->entity->bundle() . '.configurable_field';
+ $field = FieldConfig::load($field_name);
+ $field->save();
+ $this->verifyPageCache($referencing_entity_url, 'MISS');
+ $this->verifyPageCache($listing_url, 'MISS');
+ $this->verifyPageCache($empty_entity_listing_url, 'HIT');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'HIT');
+ $this->verifyPageCache($non_referencing_entity_url, 'HIT');
+
+ // Verify cache hits.
+ $this->verifyPageCache($referencing_entity_url, 'HIT');
+ $this->verifyPageCache($listing_url, 'HIT');
+ }
+
+
+ // Verify that after invalidating the entity's cache tag directly, there is
+ // a cache miss for every route except the ones for the non-referencing
+ // entity and the empty entity listing.
+ $this->pass("Test invalidation of referenced entity's cache tag.", 'Debug');
+ Cache::invalidateTags($this->entity->getCacheTagsToInvalidate());
+ $this->verifyPageCache($referencing_entity_url, 'MISS');
+ $this->verifyPageCache($listing_url, 'MISS');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'MISS');
+ $this->verifyPageCache($non_referencing_entity_url, 'HIT');
+ $this->verifyPageCache($empty_entity_listing_url, 'HIT');
+
+ // Verify cache hits.
+ $this->verifyPageCache($referencing_entity_url, 'HIT');
+ $this->verifyPageCache($listing_url, 'HIT');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'HIT');
+
+ // Verify that after invalidating the entity's list cache tag directly,
+ // there is a cache miss for both the empty entity listing and the non-empty
+ // entity listing routes, but not for other routes.
+ $this->pass("Test invalidation of referenced entity's list cache tag.", 'Debug');
+ Cache::invalidateTags($this->entity->getEntityType()->getListCacheTags());
+ $this->verifyPageCache($empty_entity_listing_url, 'MISS');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'MISS');
+ $this->verifyPageCache($referencing_entity_url, 'HIT');
+ $this->verifyPageCache($non_referencing_entity_url, 'HIT');
+ $this->verifyPageCache($listing_url, 'HIT');
+
+ // Verify cache hits.
+ $this->verifyPageCache($empty_entity_listing_url, 'HIT');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'HIT');
+
+
+ if (!empty($view_cache_tag)) {
+ // Verify that after invalidating the generic entity type's view cache tag
+ // directly, there is a cache miss for both the referencing entity, and the
+ // listing of referencing entities, but not for other routes.
+ $this->pass("Test invalidation of referenced entity's 'view' cache tag.", 'Debug');
+ Cache::invalidateTags($view_cache_tag);
+ $this->verifyPageCache($referencing_entity_url, 'MISS');
+ $this->verifyPageCache($listing_url, 'MISS');
+ $this->verifyPageCache($non_referencing_entity_url, 'HIT');
+ $this->verifyPageCache($empty_entity_listing_url, 'HIT');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'HIT');
+
+ // Verify cache hits.
+ $this->verifyPageCache($referencing_entity_url, 'HIT');
+ $this->verifyPageCache($listing_url, 'HIT');
+ }
+
+ // Verify that after deleting the entity, there is a cache miss for every
+ // route except for the non-referencing entity one.
+ $this->pass('Test deletion of referenced entity.', 'Debug');
+ $this->entity->delete();
+ $this->verifyPageCache($referencing_entity_url, 'MISS');
+ $this->verifyPageCache($listing_url, 'MISS');
+ $this->verifyPageCache($empty_entity_listing_url, 'MISS');
+ $this->verifyPageCache($nonempty_entity_listing_url, 'MISS');
+ $this->verifyPageCache($non_referencing_entity_url, 'HIT');
+
+ // Verify cache hits.
+ $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags());
+ $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, ['http_response', 'rendered']);
+
+ $nonempty_entity_listing_cache_tags = Cache::mergeTags($this->entity->getEntityType()->getListCacheTags(), $this->getAdditionalCacheTagsForEntityListing());
+ $nonempty_entity_listing_cache_tags = Cache::mergeTags($nonempty_entity_listing_cache_tags, $page_cache_tags);
+
+ $this->verifyPageCache($referencing_entity_url, 'HIT', Cache::mergeTags($referencing_entity_cache_tags, $page_cache_tags));
+ $this->verifyPageCache($listing_url, 'HIT', $page_cache_tags);
+ $this->verifyPageCache($empty_entity_listing_url, 'HIT', $empty_entity_listing_cache_tags);
+ $this->verifyPageCache($nonempty_entity_listing_url, 'HIT', $nonempty_entity_listing_cache_tags);
+ }
+
+ /**
+ * Creates a cache ID from a list of cache keys and a set of cache contexts.
+ *
+ * @param string[] $keys
+ * A list of cache keys.
+ * @param string[] $contexts
+ * A set of cache contexts.
+ *
+ * @return string
+ * The cache ID string.
+ */
+ protected function createCacheId(array $keys, array $contexts) {
+ $cid_parts = $keys;
+
+ $contexts = \Drupal::service('cache_contexts_manager')->convertTokensToKeys($contexts);
+ $cid_parts = array_merge($cid_parts, $contexts->getKeys());
+
+ return implode(':', $cid_parts);
+ }
+
+ /**
+ * Verify that a given render cache entry exists, with the correct cache tags.
+ *
+ * @param string $cid
+ * The render cache item ID.
+ * @param array $tags
+ * An array of expected cache tags.
+ * @param string|null $redirected_cid
+ * (optional) The redirected render cache item ID.
+ */
+ protected function verifyRenderCache($cid, array $tags, $redirected_cid = NULL) {
+ // Also verify the existence of an entity render cache entry.
+ $cache_entry = \Drupal::cache('render')->get($cid);
+ $this->assertTrue($cache_entry, 'A render cache entry exists.');
+ sort($cache_entry->tags);
+ sort($tags);
+ $this->assertIdentical($cache_entry->tags, $tags);
+ $is_redirecting_cache_item = isset($cache_entry->data['#cache_redirect']);
+ if ($redirected_cid === NULL) {
+ $this->assertFalse($is_redirecting_cache_item, 'Render cache entry is not a redirect.');
+ // If this is a redirecting cache item unlike we expected, log it.
+ if ($is_redirecting_cache_item) {
+ debug($cache_entry->data);
+ }
+ }
+ else {
+ // Verify that $cid contains a cache redirect.
+ $this->assertTrue($is_redirecting_cache_item, 'Render cache entry is a redirect.');
+ // If this is not a redirecting cache item unlike we expected, log it.
+ if (!$is_redirecting_cache_item) {
+ debug($cache_entry->data);
+ }
+ // Verify that the cache redirect points to the expected CID.
+ $redirect_cache_metadata = $cache_entry->data['#cache'];
+ $actual_redirection_cid = $this->createCacheId(
+ $redirect_cache_metadata['keys'],
+ $redirect_cache_metadata['contexts']
+ );
+ $this->assertIdentical($redirected_cid, $actual_redirection_cid);
+ // Finally, verify that the redirected CID exists and has the same cache
+ // tags.
+ $this->verifyRenderCache($redirected_cid, $tags);
+ }
+ }
+
+}
diff --git a/web/core/modules/system/src/Tests/Entity/EntityListBuilderTest.php b/web/core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php
similarity index 85%
rename from web/core/modules/system/src/Tests/Entity/EntityListBuilderTest.php
rename to web/core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php
index 2a849b29c..94225f4e9 100644
--- a/web/core/modules/system/src/Tests/Entity/EntityListBuilderTest.php
+++ b/web/core/modules/system/tests/src/Functional/Entity/EntityListBuilderTest.php
@@ -1,22 +1,22 @@
webUser = $this->drupalCreateUser(array(
+ $this->webUser = $this->drupalCreateUser([
'administer entity_test content',
- ));
+ ]);
$this->drupalLogin($this->webUser);
}
@@ -37,7 +37,7 @@ class EntityListBuilderTest extends WebTestBase {
public function testPager() {
// Create 51 test entities.
for ($i = 1; $i < 52; $i++) {
- EntityTest::create(array('name' => 'Test entity ' . $i))->save();
+ EntityTest::create(['name' => 'Test entity ' . $i])->save();
}
// Load the listing page.
diff --git a/web/core/modules/system/src/Tests/Entity/EntityOperationsTest.php b/web/core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php
similarity index 82%
rename from web/core/modules/system/src/Tests/Entity/EntityOperationsTest.php
rename to web/core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php
index 3e4c69f81..b020f4287 100644
--- a/web/core/modules/system/src/Tests/Entity/EntityOperationsTest.php
+++ b/web/core/modules/system/tests/src/Functional/Entity/EntityOperationsTest.php
@@ -1,28 +1,28 @@
drupalLogin($this->drupalCreateUser(array('administer permissions')));
+ $this->drupalLogin($this->drupalCreateUser(['administer permissions']));
}
/**
@@ -36,7 +36,7 @@ class EntityOperationsTest extends WebTestBase {
$roles = user_roles();
foreach ($roles as $role) {
$this->assertLinkByHref($role->url() . '/test_operation');
- $this->assertLink(format_string('Test Operation: @label', array('@label' => $role->label())));
+ $this->assertLink(format_string('Test Operation: @label', ['@label' => $role->label()]));
}
}
diff --git a/web/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php b/web/core/modules/system/tests/src/Functional/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
similarity index 58%
rename from web/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
rename to web/core/modules/system/tests/src/Functional/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
index 86bc703ce..df3310281 100644
--- a/web/core/modules/system/src/Tests/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
+++ b/web/core/modules/system/tests/src/Functional/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
@@ -1,13 +1,14 @@
drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
/**
@@ -49,10 +50,10 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
foreach ($tests as $test) {
foreach ($test['arguments'] as $arguments) {
- $result = call_user_func_array(array($handler, 'getReferenceableEntities'), $arguments);
- $this->assertEqual($result, $test['result'], format_string('Valid result set returned by @handler.', array('@handler' => $handler_name)));
+ $result = call_user_func_array([$handler, 'getReferenceableEntities'], $arguments);
+ $this->assertEqual($result, $test['result'], format_string('Valid result set returned by @handler.', ['@handler' => $handler_name]));
- $result = call_user_func_array(array($handler, 'countReferenceableEntities'), $arguments);
+ $result = call_user_func_array([$handler, 'countReferenceableEntities'], $arguments);
if (!empty($test['result'])) {
$bundle = key($test['result']);
$count = count($test['result'][$bundle]);
@@ -61,7 +62,7 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
$count = 0;
}
- $this->assertEqual($result, $count, format_string('Valid count returned by @handler.', array('@handler' => $handler_name)));
+ $this->assertEqual($result, $count, format_string('Valid count returned by @handler.', ['@handler' => $handler_name]));
}
}
}
@@ -70,39 +71,39 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
* Test the node-specific overrides of the entity handler.
*/
public function testNodeHandler() {
- $selection_options = array(
+ $selection_options = [
'target_type' => 'node',
'handler' => 'default',
- 'handler_settings' => array(
+ 'handler_settings' => [
'target_bundles' => NULL,
- ),
- );
+ ],
+ ];
// Build a set of test data.
// Titles contain HTML-special characters to test escaping.
- $node_values = array(
- 'published1' => array(
+ $node_values = [
+ 'published1' => [
'type' => 'article',
- 'status' => NODE_PUBLISHED,
+ 'status' => NodeInterface::PUBLISHED,
'title' => 'Node published1 (<&>)',
'uid' => 1,
- ),
- 'published2' => array(
+ ],
+ 'published2' => [
'type' => 'article',
- 'status' => NODE_PUBLISHED,
+ 'status' => NodeInterface::PUBLISHED,
'title' => 'Node published2 (<&>)',
'uid' => 1,
- ),
- 'unpublished' => array(
+ ],
+ 'unpublished' => [
'type' => 'article',
- 'status' => NODE_NOT_PUBLISHED,
+ 'status' => NodeInterface::NOT_PUBLISHED,
'title' => 'Node unpublished (<&>)',
'uid' => 1,
- ),
- );
+ ],
+ ];
- $nodes = array();
- $node_labels = array();
+ $nodes = [];
+ $node_labels = [];
foreach ($node_values as $key => $values) {
$node = Node::create($values);
$node->save();
@@ -111,84 +112,84 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
}
// Test as a non-admin.
- $normal_user = $this->drupalCreateUser(array('access content'));
+ $normal_user = $this->drupalCreateUser(['access content']);
\Drupal::currentUser()->setAccount($normal_user);
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL, 'CONTAINS'),
- ),
- 'result' => array(
- 'article' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL, 'CONTAINS'],
+ ],
+ 'result' => [
+ 'article' => [
$nodes['published1']->id() => $node_labels['published1'],
$nodes['published2']->id() => $node_labels['published2'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('published1', 'CONTAINS'),
- array('Published1', 'CONTAINS'),
- ),
- 'result' => array(
- 'article' => array(
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['published1', 'CONTAINS'],
+ ['Published1', 'CONTAINS'],
+ ],
+ 'result' => [
+ 'article' => [
$nodes['published1']->id() => $node_labels['published1'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('published2', 'CONTAINS'),
- array('Published2', 'CONTAINS'),
- ),
- 'result' => array(
- 'article' => array(
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['published2', 'CONTAINS'],
+ ['Published2', 'CONTAINS'],
+ ],
+ 'result' => [
+ 'article' => [
$nodes['published2']->id() => $node_labels['published2'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('invalid node', 'CONTAINS'),
- ),
- 'result' => array(),
- ),
- array(
- 'arguments' => array(
- array('Node unpublished', 'CONTAINS'),
- ),
- 'result' => array(),
- ),
- );
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['invalid node', 'CONTAINS'],
+ ],
+ 'result' => [],
+ ],
+ [
+ 'arguments' => [
+ ['Node unpublished', 'CONTAINS'],
+ ],
+ 'result' => [],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'Node handler');
// Test as an admin.
- $admin_user = $this->drupalCreateUser(array('access content', 'bypass node access'));
+ $admin_user = $this->drupalCreateUser(['access content', 'bypass node access']);
\Drupal::currentUser()->setAccount($admin_user);
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL, 'CONTAINS'),
- ),
- 'result' => array(
- 'article' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL, 'CONTAINS'],
+ ],
+ 'result' => [
+ 'article' => [
$nodes['published1']->id() => $node_labels['published1'],
$nodes['published2']->id() => $node_labels['published2'],
$nodes['unpublished']->id() => $node_labels['unpublished'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('Node unpublished', 'CONTAINS'),
- ),
- 'result' => array(
- 'article' => array(
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['Node unpublished', 'CONTAINS'],
+ ],
+ 'result' => [
+ 'article' => [
$nodes['unpublished']->id() => $node_labels['unpublished'],
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'Node handler (admin)');
}
@@ -196,39 +197,39 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
* Test the user-specific overrides of the entity handler.
*/
public function testUserHandler() {
- $selection_options = array(
+ $selection_options = [
'target_type' => 'user',
'handler' => 'default',
- 'handler_settings' => array(
+ 'handler_settings' => [
'target_bundles' => NULL,
'include_anonymous' => TRUE,
- ),
- );
+ ],
+ ];
// Build a set of test data.
- $user_values = array(
+ $user_values = [
'anonymous' => User::load(0),
'admin' => User::load(1),
- 'non_admin' => array(
+ 'non_admin' => [
'name' => 'non_admin <&>',
'mail' => 'non_admin@example.com',
- 'roles' => array(),
+ 'roles' => [],
'pass' => user_password(),
'status' => 1,
- ),
- 'blocked' => array(
+ ],
+ 'blocked' => [
'name' => 'blocked <&>',
'mail' => 'blocked@example.com',
- 'roles' => array(),
+ 'roles' => [],
'pass' => user_password(),
'status' => 0,
- ),
- );
+ ],
+ ];
$user_values['anonymous']->name = $this->config('user.settings')->get('anonymous');
- $users = array();
+ $users = [];
- $user_labels = array();
+ $user_labels = [];
foreach ($user_values as $key => $values) {
if (is_array($values)) {
$account = User::create($values);
@@ -243,113 +244,113 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
// Test as a non-admin.
\Drupal::currentUser()->setAccount($users['non_admin']);
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL, 'CONTAINS'),
- ),
- 'result' => array(
- 'user' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL, 'CONTAINS'],
+ ],
+ 'result' => [
+ 'user' => [
$users['admin']->id() => $user_labels['admin'],
$users['non_admin']->id() => $user_labels['non_admin'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('non_admin', 'CONTAINS'),
- array('NON_ADMIN', 'CONTAINS'),
- ),
- 'result' => array(
- 'user' => array(
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['non_admin', 'CONTAINS'],
+ ['NON_ADMIN', 'CONTAINS'],
+ ],
+ 'result' => [
+ 'user' => [
$users['non_admin']->id() => $user_labels['non_admin'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('invalid user', 'CONTAINS'),
- ),
- 'result' => array(),
- ),
- array(
- 'arguments' => array(
- array('blocked', 'CONTAINS'),
- ),
- 'result' => array(),
- ),
- );
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['invalid user', 'CONTAINS'],
+ ],
+ 'result' => [],
+ ],
+ [
+ 'arguments' => [
+ ['blocked', 'CONTAINS'],
+ ],
+ 'result' => [],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'User handler');
\Drupal::currentUser()->setAccount($users['admin']);
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL, 'CONTAINS'),
- ),
- 'result' => array(
- 'user' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL, 'CONTAINS'],
+ ],
+ 'result' => [
+ 'user' => [
$users['anonymous']->id() => $user_labels['anonymous'],
$users['admin']->id() => $user_labels['admin'],
$users['non_admin']->id() => $user_labels['non_admin'],
$users['blocked']->id() => $user_labels['blocked'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('blocked', 'CONTAINS'),
- ),
- 'result' => array(
- 'user' => array(
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['blocked', 'CONTAINS'],
+ ],
+ 'result' => [
+ 'user' => [
$users['blocked']->id() => $user_labels['blocked'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('Anonymous', 'CONTAINS'),
- array('anonymous', 'CONTAINS'),
- ),
- 'result' => array(
- 'user' => array(
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['Anonymous', 'CONTAINS'],
+ ['anonymous', 'CONTAINS'],
+ ],
+ 'result' => [
+ 'user' => [
$users['anonymous']->id() => $user_labels['anonymous'],
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'User handler (admin)');
// Test the 'include_anonymous' option.
$selection_options['handler_settings']['include_anonymous'] = FALSE;
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array('Anonymous', 'CONTAINS'),
- array('anonymous', 'CONTAINS'),
- ),
- 'result' => array(),
- ),
- );
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ ['Anonymous', 'CONTAINS'],
+ ['anonymous', 'CONTAINS'],
+ ],
+ 'result' => [],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'User handler (does not include anonymous)');
// Check that the Anonymous user is not included in the results when no
// label matching is done, for example when using the 'options_select'
// widget.
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL),
- ),
- 'result' => array(
- 'user' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL],
+ ],
+ 'result' => [
+ 'user' => [
$users['admin']->id() => $user_labels['admin'],
$users['non_admin']->id() => $user_labels['non_admin'],
$users['blocked']->id() => $user_labels['blocked'],
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'User handler (does not include anonymous)');
}
@@ -357,30 +358,30 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
* Test the comment-specific overrides of the entity handler.
*/
public function testCommentHandler() {
- $selection_options = array(
+ $selection_options = [
'target_type' => 'comment',
'handler' => 'default',
- 'handler_settings' => array(
+ 'handler_settings' => [
'target_bundles' => NULL,
- ),
- );
+ ],
+ ];
// Build a set of test data.
- $node_values = array(
- 'published' => array(
+ $node_values = [
+ 'published' => [
'type' => 'article',
'status' => 1,
'title' => 'Node published',
'uid' => 1,
- ),
- 'unpublished' => array(
+ ],
+ 'unpublished' => [
'type' => 'article',
'status' => 0,
'title' => 'Node unpublished',
'uid' => 1,
- ),
- );
- $nodes = array();
+ ],
+ ];
+ $nodes = [];
foreach ($node_values as $key => $values) {
$node = Node::create($values);
$node->save();
@@ -390,8 +391,8 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
// Create comment field on article.
$this->addDefaultCommentField('node', 'article');
- $comment_values = array(
- 'published_published' => array(
+ $comment_values = [
+ 'published_published' => [
'entity_id' => $nodes['published']->id(),
'entity_type' => 'node',
'field_name' => 'comment',
@@ -401,8 +402,8 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
'status' => CommentInterface::PUBLISHED,
'subject' => 'Comment Published <&>',
'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ),
- 'published_unpublished' => array(
+ ],
+ 'published_unpublished' => [
'entity_id' => $nodes['published']->id(),
'entity_type' => 'node',
'field_name' => 'comment',
@@ -412,8 +413,8 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
'status' => CommentInterface::NOT_PUBLISHED,
'subject' => 'Comment Unpublished <&>',
'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ),
- 'unpublished_published' => array(
+ ],
+ 'unpublished_published' => [
'entity_id' => $nodes['unpublished']->id(),
'entity_type' => 'node',
'field_name' => 'comment',
@@ -423,11 +424,11 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
'status' => CommentInterface::NOT_PUBLISHED,
'subject' => 'Comment Published on Unpublished node <&>',
'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
- ),
- );
+ ],
+ ];
- $comments = array();
- $comment_labels = array();
+ $comments = [];
+ $comment_labels = [];
foreach ($comment_values as $key => $values) {
$comment = Comment::create($values);
$comment->save();
@@ -436,79 +437,79 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
}
// Test as a non-admin.
- $normal_user = $this->drupalCreateUser(array('access content', 'access comments'));
+ $normal_user = $this->drupalCreateUser(['access content', 'access comments']);
\Drupal::currentUser()->setAccount($normal_user);
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL, 'CONTAINS'),
- ),
- 'result' => array(
- 'comment' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL, 'CONTAINS'],
+ ],
+ 'result' => [
+ 'comment' => [
$comments['published_published']->cid->value => $comment_labels['published_published'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('Published', 'CONTAINS'),
- ),
- 'result' => array(
- 'comment' => array(
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['Published', 'CONTAINS'],
+ ],
+ 'result' => [
+ 'comment' => [
$comments['published_published']->cid->value => $comment_labels['published_published'],
- ),
- ),
- ),
- array(
- 'arguments' => array(
- array('invalid comment', 'CONTAINS'),
- ),
- 'result' => array(),
- ),
- array(
- 'arguments' => array(
- array('Comment Unpublished', 'CONTAINS'),
- ),
- 'result' => array(),
- ),
- );
+ ],
+ ],
+ ],
+ [
+ 'arguments' => [
+ ['invalid comment', 'CONTAINS'],
+ ],
+ 'result' => [],
+ ],
+ [
+ 'arguments' => [
+ ['Comment Unpublished', 'CONTAINS'],
+ ],
+ 'result' => [],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'Comment handler');
// Test as a comment admin.
- $admin_user = $this->drupalCreateUser(array('access content', 'access comments', 'administer comments'));
+ $admin_user = $this->drupalCreateUser(['access content', 'access comments', 'administer comments']);
\Drupal::currentUser()->setAccount($admin_user);
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL, 'CONTAINS'),
- ),
- 'result' => array(
- 'comment' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL, 'CONTAINS'],
+ ],
+ 'result' => [
+ 'comment' => [
$comments['published_published']->cid->value => $comment_labels['published_published'],
$comments['published_unpublished']->cid->value => $comment_labels['published_unpublished'],
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'Comment handler (comment admin)');
// Test as a node and comment admin.
- $admin_user = $this->drupalCreateUser(array('access content', 'access comments', 'administer comments', 'bypass node access'));
+ $admin_user = $this->drupalCreateUser(['access content', 'access comments', 'administer comments', 'bypass node access']);
\Drupal::currentUser()->setAccount($admin_user);
- $referenceable_tests = array(
- array(
- 'arguments' => array(
- array(NULL, 'CONTAINS'),
- ),
- 'result' => array(
- 'comment' => array(
+ $referenceable_tests = [
+ [
+ 'arguments' => [
+ [NULL, 'CONTAINS'],
+ ],
+ 'result' => [
+ 'comment' => [
$comments['published_published']->cid->value => $comment_labels['published_published'],
$comments['published_unpublished']->cid->value => $comment_labels['published_unpublished'],
$comments['unpublished_published']->cid->value => $comment_labels['unpublished_published'],
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
$this->assertReferenceable($selection_options, $referenceable_tests, 'Comment handler (comment + node admin)');
}
diff --git a/web/core/modules/system/src/Tests/Entity/EntityRevisionsTest.php b/web/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php
similarity index 80%
rename from web/core/modules/system/src/Tests/Entity/EntityRevisionsTest.php
rename to web/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php
index 13847fa8e..38db0e9dc 100644
--- a/web/core/modules/system/src/Tests/Entity/EntityRevisionsTest.php
+++ b/web/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php
@@ -1,10 +1,10 @@
webUser = $this->drupalCreateUser(array(
+ $this->webUser = $this->drupalCreateUser([
'administer entity_test content',
'view test entity',
- ));
+ ]);
$this->drupalLogin($this->webUser);
// Enable an additional language.
@@ -64,17 +64,17 @@ class EntityRevisionsTest extends WebTestBase {
// Create initial entity.
$entity = $this->container->get('entity_type.manager')
->getStorage($entity_type)
- ->create(array(
+ ->create([
'name' => 'foo',
'user_id' => $this->webUser->id(),
- ));
+ ]);
$entity->field_test_text->value = 'bar';
$entity->save();
- $names = array();
- $texts = array();
- $created = array();
- $revision_ids = array();
+ $names = [];
+ $texts = [];
+ $created = [];
+ $revision_ids = [];
// Create three revisions.
$revision_count = 3;
@@ -93,23 +93,24 @@ class EntityRevisionsTest extends WebTestBase {
$revision_ids[] = $entity->revision_id->value;
// Check that the fields and properties contain new content.
- $this->assertTrue($entity->revision_id->value > $legacy_revision_id, format_string('%entity_type: Revision ID changed.', array('%entity_type' => $entity_type)));
- $this->assertNotEqual($entity->name->value, $legacy_name, format_string('%entity_type: Name changed.', array('%entity_type' => $entity_type)));
- $this->assertNotEqual($entity->field_test_text->value, $legacy_text, format_string('%entity_type: Text changed.', array('%entity_type' => $entity_type)));
+ $this->assertTrue($entity->revision_id->value > $legacy_revision_id, format_string('%entity_type: Revision ID changed.', ['%entity_type' => $entity_type]));
+ $this->assertNotEqual($entity->name->value, $legacy_name, format_string('%entity_type: Name changed.', ['%entity_type' => $entity_type]));
+ $this->assertNotEqual($entity->field_test_text->value, $legacy_text, format_string('%entity_type: Text changed.', ['%entity_type' => $entity_type]));
}
+ $storage = $this->container->get('entity_type.manager')->getStorage($entity_type);
for ($i = 0; $i < $revision_count; $i++) {
// Load specific revision.
- $entity_revision = entity_revision_load($entity_type, $revision_ids[$i]);
+ $entity_revision = $storage->loadRevision($revision_ids[$i]);
// Check if properties and fields contain the revision specific content.
- $this->assertEqual($entity_revision->revision_id->value, $revision_ids[$i], format_string('%entity_type: Revision ID matches.', array('%entity_type' => $entity_type)));
- $this->assertEqual($entity_revision->name->value, $names[$i], format_string('%entity_type: Name matches.', array('%entity_type' => $entity_type)));
- $this->assertEqual($entity_revision->field_test_text->value, $texts[$i], format_string('%entity_type: Text matches.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($entity_revision->revision_id->value, $revision_ids[$i], format_string('%entity_type: Revision ID matches.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entity_revision->name->value, $names[$i], format_string('%entity_type: Name matches.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entity_revision->field_test_text->value, $texts[$i], format_string('%entity_type: Text matches.', ['%entity_type' => $entity_type]));
// Check non-revisioned values are loaded.
- $this->assertTrue(isset($entity_revision->created->value), format_string('%entity_type: Non-revisioned field is loaded.', array('%entity_type' => $entity_type)));
- $this->assertEqual($entity_revision->created->value, $created[2], format_string('%entity_type: Non-revisioned field value is the same between revisions.', array('%entity_type' => $entity_type)));
+ $this->assertTrue(isset($entity_revision->created->value), format_string('%entity_type: Non-revisioned field is loaded.', ['%entity_type' => $entity_type]));
+ $this->assertEqual($entity_revision->created->value, $created[2], format_string('%entity_type: Non-revisioned field value is the same between revisions.', ['%entity_type' => $entity_type]));
}
// Confirm the correct revision text appears in the edit form.
@@ -117,8 +118,8 @@ class EntityRevisionsTest extends WebTestBase {
->getStorage($entity_type)
->load($entity->id->value);
$this->drupalGet($entity_type . '/manage/' . $entity->id->value . '/edit');
- $this->assertFieldById('edit-name-0-value', $entity->name->value, format_string('%entity_type: Name matches in UI.', array('%entity_type' => $entity_type)));
- $this->assertFieldById('edit-field-test-text-0-value', $entity->field_test_text->value, format_string('%entity_type: Text matches in UI.', array('%entity_type' => $entity_type)));
+ $this->assertFieldById('edit-name-0-value', $entity->name->value, format_string('%entity_type: Name matches in UI.', ['%entity_type' => $entity_type]));
+ $this->assertFieldById('edit-field-test-text-0-value', $entity->field_test_text->value, format_string('%entity_type: Text matches in UI.', ['%entity_type' => $entity_type]));
}
/**
diff --git a/web/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php b/web/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php
similarity index 86%
rename from web/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php
rename to web/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php
index d9f36ff91..684e0be8f 100644
--- a/web/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php
+++ b/web/core/modules/system/tests/src/Functional/Entity/EntityViewControllerTest.php
@@ -1,30 +1,30 @@
' . $label . '
@@ -86,7 +86,7 @@ class EntityViewControllerTest extends WebTestBase {
public function testFieldItemAttributes() {
// Make sure the test field will be rendered.
entity_get_display('entity_test', 'entity_test', 'default')
- ->setComponent('field_test_text', array('type' => 'text_default'))
+ ->setComponent('field_test_text', ['type' => 'text_default'])
->save();
// Create an entity and save test value in field_test_text.
@@ -98,24 +98,24 @@ class EntityViewControllerTest extends WebTestBase {
// Browse to the entity and verify that the attribute is rendered in the
// field item HTML markup.
$this->drupalGet('entity_test/' . $entity->id());
- $xpath = $this->xpath('//div[@data-field-item-attr="foobar"]/p[text()=:value]', array(':value' => $test_value));
+ $xpath = $this->xpath('//div[@data-field-item-attr="foobar"]/p[text()=:value]', [':value' => $test_value]);
$this->assertTrue($xpath, 'The field item attribute has been found in the rendered output of the field.');
// Enable the RDF module to ensure that two modules can add attributes to
// the same field item.
- \Drupal::service('module_installer')->install(array('rdf'));
+ \Drupal::service('module_installer')->install(['rdf']);
$this->resetAll();
// Set an RDF mapping for the field_test_text field. This RDF mapping will
// be turned into RDFa attributes in the field item output.
$mapping = rdf_get_mapping('entity_test', 'entity_test');
- $mapping->setFieldMapping('field_test_text', array(
- 'properties' => array('schema:text'),
- ))->save();
+ $mapping->setFieldMapping('field_test_text', [
+ 'properties' => ['schema:text'],
+ ])->save();
// Browse to the entity and verify that the attributes from both modules
// are rendered in the field item HTML markup.
$this->drupalGet('entity_test/' . $entity->id());
- $xpath = $this->xpath('//div[@data-field-item-attr="foobar" and @property="schema:text"]/p[text()=:value]', array(':value' => $test_value));
+ $xpath = $this->xpath('//div[@data-field-item-attr="foobar" and @property="schema:text"]/p[text()=:value]', [':value' => $test_value]);
$this->assertTrue($xpath, 'The field item attributes from both modules have been found in the rendered output of the field.');
}
@@ -139,10 +139,10 @@ class EntityViewControllerTest extends WebTestBase {
* The created entity.
*/
protected function createTestEntity($entity_type) {
- $data = array(
+ $data = [
'bundle' => $entity_type,
'name' => $this->randomMachineName(),
- );
+ ];
return $this->container->get('entity.manager')->getStorage($entity_type)->create($data);
}
diff --git a/web/core/modules/system/src/Tests/File/ConfigTest.php b/web/core/modules/system/tests/src/Functional/File/ConfigTest.php
similarity index 80%
rename from web/core/modules/system/src/Tests/File/ConfigTest.php
rename to web/core/modules/system/tests/src/Functional/File/ConfigTest.php
index 2313e26e3..da2003aa7 100644
--- a/web/core/modules/system/src/Tests/File/ConfigTest.php
+++ b/web/core/modules/system/tests/src/Functional/File/ConfigTest.php
@@ -1,35 +1,35 @@
drupalLogin ($this->drupalCreateUser(array('administer site configuration')));
+ $this->drupalLogin ($this->drupalCreateUser(['administer site configuration']));
}
/**
* Tests file configuration page.
*/
- function testFileConfigurationPage() {
+ public function testFileConfigurationPage() {
$this->drupalGet('admin/config/media/file-system');
// Set the file paths to non-default values.
// The respective directories are created automatically
// upon form submission.
$file_path = $this->publicFilesDirectory;
- $fields = array(
+ $fields = [
'file_temporary_path' => $file_path . '/file_config_page_test/temporary',
'file_default_scheme' => 'private',
- );
+ ];
// Check that public and private can be selected as default scheme.
$this->assertText('Public local files served by the webserver.');
@@ -43,10 +43,10 @@ class ConfigTest extends WebTestBase {
// Remove the private path, rebuild the container and verify that private
// can no longer be selected in the UI.
- $settings['settings']['file_private_path'] = (object) array(
+ $settings['settings']['file_private_path'] = (object) [
'value' => '',
'required' => TRUE,
- );
+ ];
$this->writeSettings($settings);
$this->rebuildContainer();
diff --git a/web/core/modules/system/src/Tests/File/FileSaveHtaccessLoggingTest.php b/web/core/modules/system/tests/src/Functional/File/FileSaveHtaccessLoggingTest.php
similarity index 83%
rename from web/core/modules/system/src/Tests/File/FileSaveHtaccessLoggingTest.php
rename to web/core/modules/system/tests/src/Functional/File/FileSaveHtaccessLoggingTest.php
index 5827e24ef..442591d15 100644
--- a/web/core/modules/system/src/Tests/File/FileSaveHtaccessLoggingTest.php
+++ b/web/core/modules/system/tests/src/Functional/File/FileSaveHtaccessLoggingTest.php
@@ -1,23 +1,23 @@
publicFilesDirectory . '/test/private';
diff --git a/web/core/modules/system/src/Tests/FileTransfer/FileTransferTest.php b/web/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php
similarity index 79%
rename from web/core/modules/system/src/Tests/FileTransfer/FileTransferTest.php
rename to web/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php
index e8a67890e..76d8be800 100644
--- a/web/core/modules/system/src/Tests/FileTransfer/FileTransferTest.php
+++ b/web/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php
@@ -1,10 +1,10 @@
testConnection = TestFileTransfer::factory(\Drupal::root(), array('hostname' => $this->hostname, 'username' => $this->username, 'password' => $this->password, 'port' => $this->port));
+ $this->testConnection = TestFileTransfer::factory(\Drupal::root(), ['hostname' => $this->hostname, 'username' => $this->username, 'password' => $this->password, 'port' => $this->port]);
}
- function _getFakeModuleFiles() {
- $files = array(
+ public function _getFakeModuleFiles() {
+ $files = [
'fake.module',
'fake.info.yml',
- 'theme' => array(
+ 'theme' => [
'fake.html.twig'
- ),
- 'inc' => array(
+ ],
+ 'inc' => [
'fake.inc'
- )
- );
+ ]
+ ];
return $files;
}
- function _buildFakeModule() {
+ public function _buildFakeModule() {
$location = 'temporary://fake';
if (is_dir($location)) {
$ret = 0;
- $output = array();
+ $output = [];
exec('rm -Rf ' . escapeshellarg($location), $output, $ret);
if ($ret != 0) {
throw new Exception('Error removing fake module directory.');
@@ -53,7 +53,7 @@ class FileTransferTest extends WebTestBase {
return $location;
}
- function _writeDirectory($base, $files = array()) {
+ public function _writeDirectory($base, $files = []) {
mkdir($base);
foreach ($files as $key => $file) {
if (is_array($file)) {
@@ -66,7 +66,7 @@ class FileTransferTest extends WebTestBase {
}
}
- function testJail() {
+ public function testJail() {
$source = $this->_buildFakeModule();
// This convoluted piece of code is here because our testing framework does
diff --git a/web/core/modules/system/src/Tests/FileTransfer/MockTestConnection.php b/web/core/modules/system/tests/src/Functional/FileTransfer/MockTestConnection.php
similarity index 53%
rename from web/core/modules/system/src/Tests/FileTransfer/MockTestConnection.php
rename to web/core/modules/system/tests/src/Functional/FileTransfer/MockTestConnection.php
index 7e63dc78f..029e72c95 100644
--- a/web/core/modules/system/src/Tests/FileTransfer/MockTestConnection.php
+++ b/web/core/modules/system/tests/src/Functional/FileTransfer/MockTestConnection.php
@@ -1,22 +1,22 @@
commandsRun[] = $cmd;
}
- function flushCommands() {
+ public function flushCommands() {
$out = $this->commandsRun;
- $this->commandsRun = array();
+ $this->commandsRun = [];
return $out;
}
diff --git a/web/core/modules/system/src/Tests/FileTransfer/TestFileTransfer.php b/web/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php
similarity index 70%
rename from web/core/modules/system/src/Tests/FileTransfer/TestFileTransfer.php
rename to web/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php
index eb73ebc90..ca11ad0f5 100644
--- a/web/core/modules/system/src/Tests/FileTransfer/TestFileTransfer.php
+++ b/web/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php
@@ -1,6 +1,6 @@
connection->connectionString = 'test://' . urlencode($this->username) . ':' . urlencode($this->password) . "@$this->host:$this->port/";
}
- function copyFileJailed($source, $destination) {
+ public function copyFileJailed($source, $destination) {
$this->connection->run("copyFile $source $destination");
}
@@ -40,25 +40,25 @@ class TestFileTransfer extends FileTransfer {
$this->connection->run("rmdir $directory");
}
- function createDirectoryJailed($directory) {
+ public function createDirectoryJailed($directory) {
$this->connection->run("mkdir $directory");
}
- function removeFileJailed($destination) {
+ public function removeFileJailed($destination) {
if (!ftp_delete($this->connection, $item)) {
- throw new FileTransferException('Unable to remove to file @file.', NULL, array('@file' => $item));
+ throw new FileTransferException('Unable to remove to file @file.', NULL, ['@file' => $item]);
}
}
- function isDirectory($path) {
+ public function isDirectory($path) {
return $this->shouldIsDirectoryReturnTrue;
}
- function isFile($path) {
+ public function isFile($path) {
return FALSE;
}
- function chmodJailed($path, $mode, $recursive) {
+ public function chmodJailed($path, $mode, $recursive) {
return;
}
diff --git a/web/core/modules/system/src/Tests/Form/ElementsAccessTest.php b/web/core/modules/system/tests/src/Functional/Form/ElementsAccessTest.php
similarity index 85%
rename from web/core/modules/system/src/Tests/Form/ElementsAccessTest.php
rename to web/core/modules/system/tests/src/Functional/Form/ElementsAccessTest.php
index 13386d7b3..1a92893c3 100644
--- a/web/core/modules/system/src/Tests/Form/ElementsAccessTest.php
+++ b/web/core/modules/system/tests/src/Functional/Form/ElementsAccessTest.php
@@ -1,22 +1,22 @@
form = new FormTestObject($this->container->get('config.factory'));
- $this->values = array(
- 'bananas' => array(
+ $this->values = [
+ 'bananas' => [
'#value' => $this->randomString(10),
'#config_name' => 'form_test.object',
'#config_key' => 'bananas',
- ),
- );
+ ],
+ ];
}
/**
@@ -37,14 +37,14 @@ class FormObjectTest extends SystemConfigFormTestBase {
*
* @see \Drupal\form_test\EventSubscriber\FormTestEventSubscriber::onKernelRequest()
*/
- function testObjectFormCallback() {
+ public function testObjectFormCallback() {
$config_factory = $this->container->get('config.factory');
$this->drupalGet('form-test/object-builder');
$this->assertText('The FormTestObject::buildForm() method was used for this form.');
$elements = $this->xpath('//form[@id="form-test-form-test-object"]');
$this->assertTrue(!empty($elements), 'The correct form ID was used.');
- $this->drupalPostForm(NULL, array('bananas' => 'green'), t('Save'));
+ $this->drupalPostForm(NULL, ['bananas' => 'green'], t('Save'));
$this->assertText('The FormTestObject::validateForm() method was used for this form.');
$this->assertText('The FormTestObject::submitForm() method was used for this form.');
$value = $config_factory->get('form_test.object')->get('bananas');
@@ -64,7 +64,7 @@ class FormObjectTest extends SystemConfigFormTestBase {
$this->assertText('The FormTestServiceObject::buildForm() method was used for this form.');
$elements = $this->xpath('//form[@id="form-test-form-test-service-object"]');
$this->assertTrue(!empty($elements), 'The correct form ID was used.');
- $this->drupalPostForm(NULL, array('bananas' => 'brown'), t('Save'));
+ $this->drupalPostForm(NULL, ['bananas' => 'brown'], t('Save'));
$this->assertText('The FormTestServiceObject::validateForm() method was used for this form.');
$this->assertText('The FormTestServiceObject::submitForm() method was used for this form.');
$value = $config_factory->get('form_test.object')->get('bananas');
@@ -77,7 +77,7 @@ class FormObjectTest extends SystemConfigFormTestBase {
$this->assertTrue(!empty($elements), 'The correct form ID was used.');
$this->assertText('custom_value', 'Ensure parameters are injected from request attributes.');
$this->assertText('request_value', 'Ensure the request object is injected.');
- $this->drupalPostForm(NULL, array('bananas' => 'black'), t('Save'));
+ $this->drupalPostForm(NULL, ['bananas' => 'black'], t('Save'));
$this->assertText('The FormTestControllerObject::validateForm() method was used for this form.');
$this->assertText('The FormTestControllerObject::submitForm() method was used for this form.');
$value = $config_factory->get('form_test.object')->get('bananas');
diff --git a/web/core/modules/system/src/Tests/Form/ModulesListFormWebTest.php b/web/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php
similarity index 84%
rename from web/core/modules/system/src/Tests/Form/ModulesListFormWebTest.php
rename to web/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php
index 921a27d78..dc63e64d7 100644
--- a/web/core/modules/system/src/Tests/Form/ModulesListFormWebTest.php
+++ b/web/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php
@@ -1,20 +1,20 @@
drupalLogin(
$this->drupalCreateUser(
- array('administer modules', 'administer permissions')
+ ['administer modules', 'administer permissions']
)
);
$this->drupalGet('admin/modules');
diff --git a/web/core/modules/system/src/Tests/Form/RedirectTest.php b/web/core/modules/system/tests/src/Functional/Form/RedirectTest.php
similarity index 69%
rename from web/core/modules/system/src/Tests/Form/RedirectTest.php
rename to web/core/modules/system/tests/src/Functional/Form/RedirectTest.php
index 6b6d36001..a4c9e15b3 100644
--- a/web/core/modules/system/src/Tests/Form/RedirectTest.php
+++ b/web/core/modules/system/tests/src/Functional/Form/RedirectTest.php
@@ -1,75 +1,75 @@
array('foo' => 'bar'));
+ $options = ['query' => ['foo' => 'bar']];
$options['absolute'] = TRUE;
// Test basic redirection.
- $edit = array(
+ $edit = [
'redirection' => TRUE,
'destination' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm($path, $edit, t('Submit'));
- $this->assertUrl($edit['destination'], array(), 'Basic redirection works.');
+ $this->assertUrl($edit['destination'], [], 'Basic redirection works.');
// Test without redirection.
- $edit = array(
+ $edit = [
'redirection' => FALSE,
- );
+ ];
$this->drupalPostForm($path, $edit, t('Submit'));
- $this->assertUrl($path, array(), 'When redirect is set to FALSE, there should be no redirection.');
+ $this->assertUrl($path, [], 'When redirect is set to FALSE, there should be no redirection.');
// Test redirection with query parameters.
- $edit = array(
+ $edit = [
'redirection' => TRUE,
'destination' => $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm($path, $edit, t('Submit'), $options);
- $this->assertUrl($edit['destination'], array(), 'Redirection with query parameters works.');
+ $this->assertUrl($edit['destination'], [], 'Redirection with query parameters works.');
// Test without redirection but with query parameters.
- $edit = array(
+ $edit = [
'redirection' => FALSE,
- );
+ ];
$this->drupalPostForm($path, $edit, t('Submit'), $options);
$this->assertUrl($path, $options, 'When redirect is set to FALSE, there should be no redirection, and the query parameters should be passed along.');
// Test redirection back to the original path.
- $edit = array(
+ $edit = [
'redirection' => TRUE,
'destination' => '',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Submit'));
- $this->assertUrl($path, array(), 'When using an empty redirection string, there should be no redirection.');
+ $this->assertUrl($path, [], 'When using an empty redirection string, there should be no redirection.');
// Test redirection back to the original path with query parameters.
- $edit = array(
+ $edit = [
'redirection' => TRUE,
'destination' => '',
- );
+ ];
$this->drupalPostForm($path, $edit, t('Submit'), $options);
$this->assertUrl($path, $options, 'When using an empty redirection string, there should be no redirection, and the query parameters should be passed along.');
}
@@ -82,15 +82,15 @@ class RedirectTest extends WebTestBase {
$this->drupalPlaceBlock('redirect_form_block');
// Create a user that does not have permission to administer blocks.
- $user = $this->drupalCreateUser(array('administer themes'));
+ $user = $this->drupalCreateUser(['administer themes']);
$this->drupalLogin($user);
// Visit page 'foo' (404 page) and submit the form. Verify it ends up
// at the right URL.
- $expected = \Drupal::url('form_test.route1', array(), array('query' => array('test1' => 'test2'), 'absolute' => TRUE));
+ $expected = \Drupal::url('form_test.route1', [], ['query' => ['test1' => 'test2'], 'absolute' => TRUE]);
$this->drupalGet('foo');
$this->assertResponse(404);
- $this->drupalPostForm(NULL, array(), t('Submit'));
+ $this->drupalPostForm(NULL, [], t('Submit'));
$this->assertResponse(200);
$this->assertUrl($expected, [], 'Redirected to correct URL/query.');
@@ -98,7 +98,7 @@ class RedirectTest extends WebTestBase {
// ends up at the right URL.
$this->drupalGet('admin/structure/block');
$this->assertResponse(403);
- $this->drupalPostForm(NULL, array(), t('Submit'));
+ $this->drupalPostForm(NULL, [], t('Submit'));
$this->assertResponse(200);
$this->assertUrl($expected, [], 'Redirected to correct URL/query.');
}
diff --git a/web/core/modules/system/src/Tests/Lock/LockFunctionalTest.php b/web/core/modules/system/tests/src/Functional/Lock/LockFunctionalTest.php
similarity index 95%
rename from web/core/modules/system/src/Tests/Lock/LockFunctionalTest.php
rename to web/core/modules/system/tests/src/Functional/Lock/LockFunctionalTest.php
index 0355a7617..0b13f18d6 100644
--- a/web/core/modules/system/src/Tests/Lock/LockFunctionalTest.php
+++ b/web/core/modules/system/tests/src/Functional/Lock/LockFunctionalTest.php
@@ -1,22 +1,22 @@
Drupal.org' => "Drupal.org [1]\n\n[1] https://www.drupal.org\n",
// @todo Footer URLs should be absolute.
@@ -151,7 +151,7 @@ class HtmlToTextTest extends WebTestBase {
// A couple of tests for Unicode characters.
'I will be back…
' => "I /will/ be back…\n",
'FrançAIS is ÜBER-åwesome' => "FrançAIS is ÜBER-åwesome\n",
- );
+ ];
foreach ($tests as $html => $text) {
$this->assertHtmlToText($html, $text, 'Supported tags');
@@ -168,27 +168,27 @@ class HtmlToTextTest extends WebTestBase {
'Drupal Drupal Drupal',
"Drupal *Drupal* Drupal\n",
'Allowed tag found',
- array('b')
+ ['b']
);
$this->assertHtmlToText(
'Drupal Drupal
Drupal',
"Drupal Drupal Drupal\n",
'Disallowed tag not found',
- array('b')
+ ['b']
);
$this->assertHtmlToText(
'Drupal
Drupal
Drupal',
"Drupal Drupal Drupal\n",
'Disallowed
, , and tags not found',
- array('a', 'br', 'h1')
+ ['a', 'br', 'h1']
);
$this->assertHtmlToText(
'Drupal',
"Drupal\n",
'Unsupported and tags not found',
- array('html', 'body')
+ ['html', 'body']
);
}
@@ -203,7 +203,7 @@ class HtmlToTextTest extends WebTestBase {
$input,
$collapsed,
'Whitespace is collapsed',
- array('p')
+ ['p']
);
}
@@ -312,17 +312,17 @@ class HtmlToTextTest extends WebTestBase {
* and spaces are properly handled.
*/
public function testDrupalHtmlToTextParagraphs() {
- $tests = array();
- $tests[] = array(
+ $tests = [];
+ $tests[] = [
'html' => "line 1
\nline 2
line 3\n
line 4
paragraph
",
// @todo Trailing line breaks should be trimmed.
'text' => "line 1\nline 2\nline 3\nline 4\n\nparagraph\n\n",
- );
- $tests[] = array(
+ ];
+ $tests[] = [
'html' => "line 1
line 2
line 4
line 5
0
",
// @todo Trailing line breaks should be trimmed.
'text' => "line 1\nline 2\n\nline 4\nline 5\n\n0\n\n",
- );
+ ];
foreach ($tests as $test) {
$this->assertHtmlToText($test['html'], $test['text'], 'Paragraph breaks');
}
diff --git a/web/core/modules/system/src/Tests/Mail/MailTest.php b/web/core/modules/system/tests/src/Functional/Mail/MailTest.php
similarity index 88%
rename from web/core/modules/system/src/Tests/Mail/MailTest.php
rename to web/core/modules/system/tests/src/Functional/Mail/MailTest.php
index 70f5a4b4c..74549a321 100644
--- a/web/core/modules/system/src/Tests/Mail/MailTest.php
+++ b/web/core/modules/system/tests/src/Functional/Mail/MailTest.php
@@ -1,9 +1,9 @@
config('system.mail')->set('interface.default', 'test_php_mail_failure')->save();
// Get the default MailInterface class instance.
- $mail_backend = \Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'default', 'key' => 'default'));
+ $mail_backend = \Drupal::service('plugin.manager.mail')->getInstance(['module' => 'default', 'key' => 'default']);
// Assert whether the default mail backend is an instance of the expected
// class.
@@ -38,7 +38,7 @@ class MailTest extends WebTestBase {
$this->config('system.mail')->set('interface.mymodule_testkey', 'test_mail_collector')->save();
// Get the added MailInterface class instance.
- $mail_backend = \Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'mymodule', 'key' => 'testkey'));
+ $mail_backend = \Drupal::service('plugin.manager.mail')->getInstance(['module' => 'mymodule', 'key' => 'testkey']);
// Assert whether the added mail backend is an instance of the expected
// class.
@@ -56,7 +56,7 @@ class MailTest extends WebTestBase {
// Use the state system collector mail backend.
$this->config('system.mail')->set('interface.default', 'test_mail_collector')->save();
// Reset the state variable that holds sent messages.
- \Drupal::state()->set('system.test_mail_collector', array());
+ \Drupal::state()->set('system.test_mail_collector', []);
// Send a test message that simpletest_mail_alter should cancel.
\Drupal::service('plugin.manager.mail')->mail('simpletest', 'cancel_test', 'cancel@example.com', $language_interface->getId());
@@ -77,11 +77,11 @@ class MailTest extends WebTestBase {
// Use the state system collector mail backend.
$this->config('system.mail')->set('interface.default', 'test_mail_collector')->save();
// Reset the state variable that holds sent messages.
- \Drupal::state()->set('system.test_mail_collector', array());
+ \Drupal::state()->set('system.test_mail_collector', []);
// Send an email with a reply-to address specified.
$from_email = 'Drupal ';
$reply_email = 'someone_else@example.com';
- \Drupal::service('plugin.manager.mail')->mail('simpletest', 'from_test', 'from_test@example.com', $language, array(), $reply_email);
+ \Drupal::service('plugin.manager.mail')->mail('simpletest', 'from_test', 'from_test@example.com', $language, [], $reply_email);
// Test that the reply-to email is just the email and not the site name
// and default sender email.
$captured_emails = \Drupal::state()->get('system.test_mail_collector');
diff --git a/web/core/modules/system/src/Tests/Menu/MenuAccessTest.php b/web/core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php
similarity index 92%
rename from web/core/modules/system/src/Tests/Menu/MenuAccessTest.php
rename to web/core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php
index fff17e58c..10af396a6 100644
--- a/web/core/modules/system/src/Tests/Menu/MenuAccessTest.php
+++ b/web/core/modules/system/tests/src/Functional/Menu/MenuAccessTest.php
@@ -1,16 +1,16 @@
drupalGet('foo/asdf/c');
$this->assertResponse(403);
- $elements = $this->xpath('//ul[@class=:class]/li/a[@href=:href]', array(
+ $elements = $this->xpath('//ul[@class=:class]/li/a[@href=:href]', [
':class' => 'tabs primary',
':href' => Url::fromRoute('menu_test.router_test1', ['bar' => 'asdf'])->toString(),
- ));
+ ]);
$this->assertTrue(empty($elements), 'No tab linking to foo/asdf found');
$this->assertNoLinkByHref('foo/asdf/b');
$this->assertNoLinkByHref('foo/asdf/c');
diff --git a/web/core/modules/system/src/Tests/Menu/MenuLinkSecurityTest.php b/web/core/modules/system/tests/src/Functional/Menu/MenuLinkSecurityTest.php
similarity index 87%
rename from web/core/modules/system/src/Tests/Menu/MenuLinkSecurityTest.php
rename to web/core/modules/system/tests/src/Functional/Menu/MenuLinkSecurityTest.php
index 94bb14af0..c58bf8e50 100644
--- a/web/core/modules/system/src/Tests/Menu/MenuLinkSecurityTest.php
+++ b/web/core/modules/system/tests/src/Functional/Menu/MenuLinkSecurityTest.php
@@ -1,16 +1,16 @@
install(array('module_test', 'module_autoload_test'), FALSE);
+ \Drupal::service('module_installer')->install(['module_test', 'module_autoload_test'], FALSE);
$this->resetAll();
// Check twice to test an unprimed and primed system_list() cache.
for ($i = 0; $i < 2; $i++) {
@@ -38,9 +38,9 @@ class ClassLoaderTest extends WebTestBase {
*
* @see \Drupal\module_autoload_test\SomeClass
*/
- function testClassLoadingNotInstalledModules() {
+ public function testClassLoadingNotInstalledModules() {
// Enable the module_test module.
- \Drupal::service('module_installer')->install(array('module_test'), FALSE);
+ \Drupal::service('module_installer')->install(['module_test'], FALSE);
$this->resetAll();
// Check twice to test an unprimed and primed system_list() cache.
for ($i = 0; $i < 2; $i++) {
@@ -55,12 +55,12 @@ class ClassLoaderTest extends WebTestBase {
*
* @see \Drupal\module_autoload_test\SomeClass
*/
- function testClassLoadingDisabledModules() {
+ public function testClassLoadingDisabledModules() {
// Enable the module_test and module_autoload_test modules.
- \Drupal::service('module_installer')->install(array('module_test', 'module_autoload_test'), FALSE);
+ \Drupal::service('module_installer')->install(['module_test', 'module_autoload_test'], FALSE);
$this->resetAll();
// Ensure that module_autoload_test is disabled.
- $this->container->get('module_installer')->uninstall(array('module_autoload_test'), FALSE);
+ $this->container->get('module_installer')->uninstall(['module_autoload_test'], FALSE);
$this->resetAll();
// Check twice to test an unprimed and primed system_list() cache.
for ($i = 0; $i < 2; $i++) {
@@ -76,8 +76,8 @@ class ClassLoaderTest extends WebTestBase {
public function testMultipleModules() {
$this->drupalLogin($this->rootUser);
$edit = [
- "modules[Testing][module_install_class_loader_test1][enable]" => TRUE,
- "modules[Testing][module_install_class_loader_test2][enable]" => TRUE,
+ "modules[module_install_class_loader_test1][enable]" => TRUE,
+ "modules[module_install_class_loader_test2][enable]" => TRUE,
];
$this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->rebuildContainer();
diff --git a/web/core/modules/system/src/Tests/Module/ExperimentalModuleTest.php b/web/core/modules/system/tests/src/Functional/Module/ExperimentalModuleTest.php
similarity index 87%
rename from web/core/modules/system/src/Tests/Module/ExperimentalModuleTest.php
rename to web/core/modules/system/tests/src/Functional/Module/ExperimentalModuleTest.php
index 7b1a376bd..177fc5ba1 100644
--- a/web/core/modules/system/src/Tests/Module/ExperimentalModuleTest.php
+++ b/web/core/modules/system/tests/src/Functional/Module/ExperimentalModuleTest.php
@@ -1,15 +1,15 @@
drupalPostForm('admin/modules', $edit, t('Install'));
$this->assertText('Module Test page has been enabled.');
$this->assertNoText('Experimental modules are provided for testing purposes only.');
@@ -48,7 +48,7 @@ class ExperimentalModuleTest extends WebTestBase {
// There should be a confirmation form with an experimental warning, but no
// list of dependencies.
$edit = [];
- $edit["modules[Core (Experimental)][experimental_module_test][enable]"] = TRUE;
+ $edit["modules[experimental_module_test][enable]"] = TRUE;
$this->drupalPostForm('admin/modules', $edit, 'Install');
// The module should not be enabled and there should be a warning and a
@@ -70,7 +70,7 @@ class ExperimentalModuleTest extends WebTestBase {
// Test enabling a module that is not itself experimental, but that depends
// on an experimental module.
$edit = [];
- $edit["modules[Testing][experimental_module_dependency_test][enable]"] = TRUE;
+ $edit["modules[experimental_module_dependency_test][enable]"] = TRUE;
$this->drupalPostForm('admin/modules', $edit, 'Install');
// The module should not be enabled and there should be a warning and a
@@ -98,8 +98,8 @@ class ExperimentalModuleTest extends WebTestBase {
// still a warning about experimental modules, but no message about
// dependencies, since the user specifically enabled the dependency.
$edit = [];
- $edit["modules[Core (Experimental)][experimental_module_test][enable]"] = TRUE;
- $edit["modules[Testing][experimental_module_dependency_test][enable]"] = TRUE;
+ $edit["modules[experimental_module_test][enable]"] = TRUE;
+ $edit["modules[experimental_module_dependency_test][enable]"] = TRUE;
$this->drupalPostForm('admin/modules', $edit, 'Install');
// The module should not be enabled and there should be a warning and a
@@ -110,7 +110,7 @@ class ExperimentalModuleTest extends WebTestBase {
$this->assertText('The following modules are experimental: Experimental Test');
// Ensure the non-experimental module is not listed as experimental.
- $this->assertNoText('The following modules are experimental: Experimental Test, Experimental Dependency Test');
+ $this->assertNoText('The following modules are experimental: Experimental Dependency Test, Experimental Test');
$this->assertNoText('The following modules are experimental: Experimental Dependency Test');
// There should be no message about enabling dependencies.
@@ -118,13 +118,13 @@ class ExperimentalModuleTest extends WebTestBase {
// Enable the module and confirm that it worked.
$this->drupalPostForm(NULL, [], 'Continue');
- $this->assertText('2 modules have been enabled: Experimental Test, Experimental Dependency Test');
+ $this->assertText('2 modules have been enabled: Experimental Dependency Test, Experimental Test');
// Try to enable an experimental module that can not be due to
// hook_requirements().
\Drupal::state()->set('experimental_module_requirements_test_requirements', TRUE);
$edit = [];
- $edit["modules[Core (Experimental)][experimental_module_requirements_test][enable]"] = TRUE;
+ $edit["modules[experimental_module_requirements_test][enable]"] = TRUE;
$this->drupalPostForm('admin/modules', $edit, 'Install');
$this->assertUrl('admin/modules', [], 'If the module can not be installed we are not taken to the confirm form.');
$this->assertText('The Experimental Test Requirements module can not be installed.');
diff --git a/web/core/modules/system/src/Tests/Module/InstallTest.php b/web/core/modules/system/tests/src/Functional/Module/InstallTest.php
similarity index 83%
rename from web/core/modules/system/src/Tests/Module/InstallTest.php
rename to web/core/modules/system/tests/src/Functional/Module/InstallTest.php
index babdd76d7..ccbca6d31 100644
--- a/web/core/modules/system/src/Tests/Module/InstallTest.php
+++ b/web/core/modules/system/tests/src/Functional/Module/InstallTest.php
@@ -1,23 +1,23 @@
install(array('user'), FALSE);
+ \Drupal::service('module_installer')->install(['user'], FALSE);
$this->assertIdentical($this->config('core.extension')->get('module.user'), 0);
}
@@ -70,9 +70,9 @@ class InstallTest extends WebTestBase {
*/
public function testModuleNameLength() {
$module_name = 'invalid_module_name_over_the_maximum_allowed_character_length';
- $message = format_string('Exception thrown when enabling module %name with a name length over the allowed maximum', array('%name' => $module_name));
+ $message = format_string('Exception thrown when enabling module %name with a name length over the allowed maximum', ['%name' => $module_name]);
try {
- $this->container->get('module_installer')->install(array($module_name));
+ $this->container->get('module_installer')->install([$module_name]);
$this->fail($message);
}
catch (ExtensionNameLengthException $e) {
@@ -80,9 +80,9 @@ class InstallTest extends WebTestBase {
}
// Since for the UI, the submit callback uses FALSE, test that too.
- $message = format_string('Exception thrown when enabling as if via the UI the module %name with a name length over the allowed maximum', array('%name' => $module_name));
+ $message = format_string('Exception thrown when enabling as if via the UI the module %name with a name length over the allowed maximum', ['%name' => $module_name]);
try {
- $this->container->get('module_installer')->install(array($module_name), FALSE);
+ $this->container->get('module_installer')->install([$module_name], FALSE);
$this->fail($message);
}
catch (ExtensionNameLengthException $e) {
diff --git a/web/core/modules/system/tests/src/Functional/Module/ModuleTestBase.php b/web/core/modules/system/tests/src/Functional/Module/ModuleTestBase.php
new file mode 100644
index 000000000..392f2875e
--- /dev/null
+++ b/web/core/modules/system/tests/src/Functional/Module/ModuleTestBase.php
@@ -0,0 +1,194 @@
+adminUser = $this->drupalCreateUser(['access administration pages', 'administer modules']);
+ $this->drupalLogin($this->adminUser);
+ }
+
+ /**
+ * Assert there are tables that begin with the specified base table name.
+ *
+ * @param $base_table
+ * Beginning of table name to look for.
+ * @param $count
+ * (optional) Whether or not to assert that there are tables that match the
+ * specified base table. Defaults to TRUE.
+ */
+ public function assertTableCount($base_table, $count = TRUE) {
+ $tables = db_find_tables(Database::getConnection()->prefixTables('{' . $base_table . '}') . '%');
+
+ if ($count) {
+ return $this->assertTrue($tables, format_string('Tables matching "@base_table" found.', ['@base_table' => $base_table]));
+ }
+ return $this->assertFalse($tables, format_string('Tables matching "@base_table" not found.', ['@base_table' => $base_table]));
+ }
+
+ /**
+ * Assert that all tables defined in a module's hook_schema() exist.
+ *
+ * @param $module
+ * The name of the module.
+ */
+ public function assertModuleTablesExist($module) {
+ $tables = array_keys(drupal_get_module_schema($module));
+ $tables_exist = TRUE;
+ foreach ($tables as $table) {
+ if (!db_table_exists($table)) {
+ $tables_exist = FALSE;
+ }
+ }
+ return $this->assertTrue($tables_exist, format_string('All database tables defined by the @module module exist.', ['@module' => $module]));
+ }
+
+ /**
+ * Assert that none of the tables defined in a module's hook_schema() exist.
+ *
+ * @param $module
+ * The name of the module.
+ */
+ public function assertModuleTablesDoNotExist($module) {
+ $tables = array_keys(drupal_get_module_schema($module));
+ $tables_exist = FALSE;
+ foreach ($tables as $table) {
+ if (db_table_exists($table)) {
+ $tables_exist = TRUE;
+ }
+ }
+ return $this->assertFalse($tables_exist, format_string('None of the database tables defined by the @module module exist.', ['@module' => $module]));
+ }
+
+ /**
+ * Asserts that the default configuration of a module has been installed.
+ *
+ * @param string $module
+ * The name of the module.
+ *
+ * @return bool
+ * TRUE if configuration has been installed, FALSE otherwise.
+ */
+ public function assertModuleConfig($module) {
+ $module_config_dir = drupal_get_path('module', $module) . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
+ if (!is_dir($module_config_dir)) {
+ return;
+ }
+ $module_file_storage = new FileStorage($module_config_dir);
+
+ // Verify that the module's default config directory is not empty and
+ // contains default configuration files (instead of something else).
+ $all_names = $module_file_storage->listAll();
+ if (empty($all_names)) {
+ // Module has an empty config directory. For example it might contain a
+ // schema directory.
+ return;
+ }
+ $this->assertTrue($all_names);
+
+ // Look up each default configuration object name in the active
+ // configuration, and if it exists, remove it from the stack.
+ // Only default config that belongs to $module is guaranteed to exist; any
+ // other default config depends on whether other modules are enabled. Thus,
+ // list all default config once more, but filtered by $module.
+ $names = $module_file_storage->listAll($module . '.');
+ foreach ($names as $key => $name) {
+ if ($this->config($name)->get()) {
+ unset($names[$key]);
+ }
+ }
+ // Verify that all configuration has been installed (which means that $names
+ // is empty).
+ return $this->assertFalse($names, format_string('All default configuration of @module module found.', ['@module' => $module]));
+ }
+
+ /**
+ * Asserts that no configuration exists for a given module.
+ *
+ * @param string $module
+ * The name of the module.
+ *
+ * @return bool
+ * TRUE if no configuration was found, FALSE otherwise.
+ */
+ public function assertNoModuleConfig($module) {
+ $names = \Drupal::configFactory()->listAll($module . '.');
+ return $this->assertFalse($names, format_string('No configuration found for @module module.', ['@module' => $module]));
+ }
+
+ /**
+ * Assert the list of modules are enabled or disabled.
+ *
+ * @param $modules
+ * Module list to check.
+ * @param $enabled
+ * Expected module state.
+ */
+ public function assertModules(array $modules, $enabled) {
+ $this->rebuildContainer();
+ foreach ($modules as $module) {
+ if ($enabled) {
+ $message = 'Module "@module" is enabled.';
+ }
+ else {
+ $message = 'Module "@module" is not enabled.';
+ }
+ $this->assertEqual($this->container->get('module_handler')->moduleExists($module), $enabled, format_string($message, ['@module' => $module]));
+ }
+ }
+
+ /**
+ * Verify a log entry was entered for a module's status change.
+ *
+ * @param $type
+ * The category to which this message belongs.
+ * @param $message
+ * The message to store in the log. Keep $message translatable
+ * by not concatenating dynamic values into it! Variables in the
+ * message should be added by using placeholder strings alongside
+ * the variables argument to declare the value of the placeholders.
+ * See t() for documentation on how $message and $variables interact.
+ * @param $variables
+ * Array of variables to replace in the message on display or
+ * NULL if message is already translated or not possible to
+ * translate.
+ * @param $severity
+ * The severity of the message, as per RFC 3164.
+ * @param $link
+ * A link to associate with the message.
+ */
+ public function assertLogMessage($type, $message, $variables = [], $severity = RfcLogLevel::NOTICE, $link = '') {
+ $count = db_select('watchdog', 'w')
+ ->condition('type', $type)
+ ->condition('message', $message)
+ ->condition('variables', serialize($variables))
+ ->condition('severity', $severity)
+ ->condition('link', $link)
+ ->countQuery()
+ ->execute()
+ ->fetchField();
+ $this->assertTrue($count > 0, format_string('watchdog table contains @count rows for @message', ['@count' => $count, '@message' => format_string($message, $variables)]));
+ }
+
+}
diff --git a/web/core/modules/system/src/Tests/Module/UninstallTest.php b/web/core/modules/system/tests/src/Functional/Module/UninstallTest.php
similarity index 88%
rename from web/core/modules/system/src/Tests/Module/UninstallTest.php
rename to web/core/modules/system/tests/src/Functional/Module/UninstallTest.php
index 20e191dfd..2b17b8fcf 100644
--- a/web/core/modules/system/src/Tests/Module/UninstallTest.php
+++ b/web/core/modules/system/tests/src/Functional/Module/UninstallTest.php
@@ -1,35 +1,35 @@
container->get('module_installer')->uninstall(array('module_test'));
+ $this->container->get('module_installer')->uninstall(['module_test']);
// Are the perms defined by module_test removed?
$this->assertFalse(user_roles(FALSE, 'module_test perm'), 'Permissions were all removed.');
@@ -38,8 +38,8 @@ class UninstallTest extends WebTestBase {
/**
* Tests the Uninstall page and Uninstall confirmation page.
*/
- function testUninstallPage() {
- $account = $this->drupalCreateUser(array('administer modules'));
+ public function testUninstallPage() {
+ $account = $this->drupalCreateUser(['administer modules']);
$this->drupalLogin($account);
// Create a node type.
@@ -67,7 +67,7 @@ class UninstallTest extends WebTestBase {
$node->delete();
// Uninstall module_test.
- $edit = array();
+ $edit = [];
$edit['uninstall[module_test]'] = TRUE;
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
$this->assertNoText(\Drupal::translation()->translate('Configuration deletions'), 'No configuration deletions listed on the module install confirmation page.');
@@ -78,14 +78,14 @@ class UninstallTest extends WebTestBase {
// Uninstall node testing that the configuration that will be deleted is
// listed.
- $node_dependencies = \Drupal::service('config.manager')->findConfigEntityDependentsAsEntities('module', array('node'));
- $edit = array();
+ $node_dependencies = \Drupal::service('config.manager')->findConfigEntityDependentsAsEntities('module', ['node']);
+ $edit = [];
$edit['uninstall[node]'] = TRUE;
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
$this->assertText(\Drupal::translation()->translate('Configuration deletions'), 'Configuration deletions listed on the module install confirmation page.');
$this->assertNoText(\Drupal::translation()->translate('Configuration updates'), 'No configuration updates listed on the module install confirmation page.');
- $entity_types = array();
+ $entity_types = [];
foreach ($node_dependencies as $entity) {
$label = $entity->label() ?: $entity->id();
$this->assertText($label);
@@ -103,7 +103,7 @@ class UninstallTest extends WebTestBase {
// cleared during the uninstall.
\Drupal::cache()->set('uninstall_test', 'test_uninstall_page', Cache::PERMANENT);
$cached = \Drupal::cache()->get('uninstall_test');
- $this->assertEqual($cached->data, 'test_uninstall_page', SafeMarkup::format('Cache entry found: @bin', array('@bin' => $cached->data)));
+ $this->assertEqual($cached->data, 'test_uninstall_page', SafeMarkup::format('Cache entry found: @bin', ['@bin' => $cached->data]));
$this->drupalPostForm(NULL, NULL, t('Uninstall'));
$this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
@@ -123,7 +123,7 @@ class UninstallTest extends WebTestBase {
$this->assertTitle(t('Uninstall') . ' | Drupal');
// Make sure the correct error is shown when no modules are selected.
- $edit = array();
+ $edit = [];
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
$this->assertText(t('No modules selected.'), 'No module is selected to uninstall');
}
@@ -132,12 +132,12 @@ class UninstallTest extends WebTestBase {
* Tests that a module which fails to install can still be uninstalled.
*/
public function testFailedInstallStatus() {
- $account = $this->drupalCreateUser(array('administer modules'));
+ $account = $this->drupalCreateUser(['administer modules']);
$this->drupalLogin($account);
$message = 'Exception thrown when installing module_installer_config_test with an invalid configuration file.';
try {
- $this->container->get('module_installer')->install(array('module_installer_config_test'));
+ $this->container->get('module_installer')->install(['module_installer_config_test']);
$this->fail($message);
}
catch (EntityMalformedException $e) {
diff --git a/web/core/modules/system/src/Tests/ParamConverter/UpcastingTest.php b/web/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php
similarity index 80%
rename from web/core/modules/system/src/Tests/ParamConverter/UpcastingTest.php
rename to web/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php
index b881386c8..faafe8460 100644
--- a/web/core/modules/system/src/Tests/ParamConverter/UpcastingTest.php
+++ b/web/core/modules/system/tests/src/Functional/ParamConverter/UpcastingTest.php
@@ -1,8 +1,8 @@
drupalCreateNode(array('title' => $this->randomMachineName(8)));
- $user = $this->drupalCreateUser(array('access content'));
+ $node = $this->drupalCreateNode(['title' => $this->randomMachineName(8)]);
+ $user = $this->drupalCreateUser(['access content']);
$foo = 'bar';
// paramconverter_test/test_user_node_foo/{user}/{node}/{foo}
@@ -48,8 +48,8 @@ class UpcastingTest extends WebTestBase {
* Confirms we can upcast to controller arguments of the same type.
*/
public function testSameTypes() {
- $node = $this->drupalCreateNode(array('title' => $this->randomMachineName(8)));
- $parent = $this->drupalCreateNode(array('title' => $this->randomMachineName(8)));
+ $node = $this->drupalCreateNode(['title' => $this->randomMachineName(8)]);
+ $parent = $this->drupalCreateNode(['title' => $this->randomMachineName(8)]);
// paramconverter_test/node/{node}/set/parent/{parent}
// options.parameters.parent.type = entity:node
$this->drupalGet("paramconverter_test/node/" . $node->id() . "/set/parent/" . $parent->id());
@@ -63,19 +63,19 @@ class UpcastingTest extends WebTestBase {
$language = ConfigurableLanguage::createFromLangcode('de');
$language->save();
\Drupal::configFactory()->getEditable('language.negotiation')
- ->set('url.prefixes', array('de' => 'de'))
+ ->set('url.prefixes', ['de' => 'de'])
->save();
// The container must be recreated after adding a new language.
$this->rebuildContainer();
- $node = $this->drupalCreateNode(array('title' => 'English label'));
+ $node = $this->drupalCreateNode(['title' => 'English label']);
$translation = $node->addTranslation('de');
$translation->setTitle('Deutscher Titel')->save();
$this->drupalGet("/paramconverter_test/node/" . $node->id() . "/test_language");
$this->assertRaw("English label");
- $this->drupalGet("paramconverter_test/node/" . $node->id() . "/test_language", array('language' => $language));
+ $this->drupalGet("paramconverter_test/node/" . $node->id() . "/test_language", ['language' => $language]);
$this->assertRaw("Deutscher Titel");
}
diff --git a/web/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php b/web/core/modules/system/tests/src/Functional/Path/UrlAlterFunctionalTest.php
similarity index 82%
rename from web/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php
rename to web/core/modules/system/tests/src/Functional/Path/UrlAlterFunctionalTest.php
index 743b74bde..271774169 100644
--- a/web/core/modules/system/src/Tests/Path/UrlAlterFunctionalTest.php
+++ b/web/core/modules/system/tests/src/Functional/Path/UrlAlterFunctionalTest.php
@@ -1,9 +1,10 @@
assertTrue(Database::getConnection()->schema()->tableExists('url_alias'), 'The url_alias table exists after Drupal installation.');
// User names can have quotes and plus signs so we should ensure that URL
// altering works with this.
- $account = $this->drupalCreateUser(array('administer url aliases'), "a'foo+bar");
+ $account = $this->drupalCreateUser(['administer url aliases'], "a'foo+bar");
$this->drupalLogin($account);
$uid = $account->id();
@@ -41,14 +42,14 @@ class UrlAlterFunctionalTest extends WebTestBase {
$this->assertUrlOutboundAlter("/user/$uid", "/user/$name");
// Test that a path always uses its alias.
- $path = array('source' => "/user/$uid/test1", 'alias' => '/alias/test1');
+ $path = ['source' => "/user/$uid/test1", 'alias' => '/alias/test1'];
$this->container->get('path.alias_storage')->save($path['source'], $path['alias']);
$this->rebuildContainer();
$this->assertUrlInboundAlter('/alias/test1', "/user/$uid/test1");
$this->assertUrlOutboundAlter("/user/$uid/test1", '/alias/test1');
// Test adding an alias via the UI.
- $edit = array('source' => "/user/$uid/edit", 'alias' => '/alias/test2');
+ $edit = ['source' => "/user/$uid/edit", 'alias' => '/alias/test2'];
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
$this->assertText(t('The alias has been saved.'));
$this->drupalGet('alias/test2');
@@ -74,6 +75,10 @@ class UrlAlterFunctionalTest extends WebTestBase {
$this->drupalGet("community/" . $term->id());
$this->assertText($term_name, 'The community/{tid} path gets resolved correctly');
$this->assertUrlOutboundAlter("/forum/" . $term->id(), "/community/" . $term->id());
+
+ // Test outbound query string altering.
+ $url = Url::fromRoute('user.login');
+ $this->assertIdentical(\Drupal::request()->getBaseUrl() . '/user/login?foo=bar', $url->toString());
}
/**
@@ -90,7 +95,7 @@ class UrlAlterFunctionalTest extends WebTestBase {
protected function assertUrlOutboundAlter($original, $final) {
// Test outbound altering.
$result = $this->container->get('path_processor_manager')->processOutbound($original);
- return $this->assertIdentical($result, $final, format_string('Altered outbound URL %original, expected %final, and got %result.', array('%original' => $original, '%final' => $final, '%result' => $result)));
+ return $this->assertIdentical($result, $final, format_string('Altered outbound URL %original, expected %final, and got %result.', ['%original' => $original, '%final' => $final, '%result' => $result]));
}
/**
@@ -107,7 +112,7 @@ class UrlAlterFunctionalTest extends WebTestBase {
protected function assertUrlInboundAlter($original, $final) {
// Test inbound altering.
$result = $this->container->get('path.alias_manager')->getPathByAlias($original);
- return $this->assertIdentical($result, $final, format_string('Altered inbound URL %original, expected %final, and got %result.', array('%original' => $original, '%final' => $final, '%result' => $result)));
+ return $this->assertIdentical($result, $final, format_string('Altered inbound URL %original, expected %final, and got %result.', ['%original' => $original, '%final' => $final, '%result' => $result]));
}
}
diff --git a/web/core/modules/system/src/Tests/Render/AjaxPageStateTest.php b/web/core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php
similarity index 92%
rename from web/core/modules/system/src/Tests/Render/AjaxPageStateTest.php
rename to web/core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php
index 19e623775..6f5dc7da6 100644
--- a/web/core/modules/system/src/Tests/Render/AjaxPageStateTest.php
+++ b/web/core/modules/system/tests/src/Functional/Render/AjaxPageStateTest.php
@@ -1,15 +1,15 @@
drupalGet('node', array());
+ $this->drupalGet('node', []);
$this->assertRaw(
'/core/assets/vendor/html5shiv/html5shiv.min.js',
'The html5shiv library from core should be loaded.'
@@ -63,14 +63,14 @@ class AjaxPageStateTest extends WebTestBase {
*/
public function testHtml5ShivIsNotLoaded() {
$this->drupalGet('node',
- array(
+ [
"query" =>
- array(
- 'ajax_page_state' => array(
+ [
+ 'ajax_page_state' => [
'libraries' => 'core/html5shiv'
- )
- )
- )
+ ]
+ ]
+ ]
);
$this->assertNoRaw(
'/core/assets/vendor/html5shiv/html5shiv.min.js',
diff --git a/web/core/modules/system/src/Tests/Render/DisplayVariantTest.php b/web/core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php
similarity index 70%
rename from web/core/modules/system/src/Tests/Render/DisplayVariantTest.php
rename to web/core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php
index 09f54d9a5..2f5415ba7 100644
--- a/web/core/modules/system/src/Tests/Render/DisplayVariantTest.php
+++ b/web/core/modules/system/tests/src/Functional/Render/DisplayVariantTest.php
@@ -1,27 +1,27 @@
drupalGet('router_test/test8');
$this->assertResponse(403, 'Access denied by default if no access specified');
- $user = $this->drupalCreateUser(array('access test7'));
+ $user = $this->drupalCreateUser(['access test7']);
$this->drupalLogin($user);
$this->drupalGet('router_test/test7');
$this->assertResponse(200);
diff --git a/web/core/modules/system/src/Tests/ServiceProvider/ServiceProviderWebTest.php b/web/core/modules/system/tests/src/Functional/ServiceProvider/ServiceProviderWebTest.php
similarity index 81%
rename from web/core/modules/system/src/Tests/ServiceProvider/ServiceProviderWebTest.php
rename to web/core/modules/system/tests/src/Functional/ServiceProvider/ServiceProviderWebTest.php
index 5d2505aed..73d691008 100644
--- a/web/core/modules/system/src/Tests/ServiceProvider/ServiceProviderWebTest.php
+++ b/web/core/modules/system/tests/src/Functional/ServiceProvider/ServiceProviderWebTest.php
@@ -1,22 +1,22 @@
drupalCreateUser(array('administer site configuration'));
+ $admin = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($admin);
}
@@ -28,49 +28,49 @@ class DateFormatsMachineNameTest extends WebTestBase {
public function testDateFormatsMachineNameAllowedValues() {
// Try to create a date format with a not allowed character to test the date
// format specific machine name replace pattern.
- $edit = array(
+ $edit = [
'label' => 'Something Not Allowed',
'id' => 'something.bad',
'date_format_pattern' => 'Y-m-d',
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertText(t('The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'), 'It is not possible to create a date format with the machine name that has any character other than lowercase letters, digits or underscore.');
// Try to create a date format with the reserved machine name "custom".
- $edit = array(
+ $edit = [
'label' => 'Custom',
'id' => 'custom',
'date_format_pattern' => 'Y-m-d',
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertText(t('The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'), 'It is not possible to create a date format with the machine name "custom".');
// Try to create a date format with a machine name, "fallback", that
// already exists.
- $edit = array(
+ $edit = [
'label' => 'Fallback',
'id' => 'fallback',
'date_format_pattern' => 'j/m/Y',
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertText(t('The machine-readable name is already in use. It must be unique.'), 'It is not possible to create a date format with the machine name "fallback". It is a built-in format that already exists.');
// Create a date format with a machine name distinct from the previous two.
$id = Unicode::strtolower($this->randomMachineName(16));
- $edit = array(
+ $edit = [
'label' => $this->randomMachineName(16),
'id' => $id,
'date_format_pattern' => 'd/m/Y',
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertText(t('Custom date format added.'), 'It is possible to create a date format with a new machine name.');
// Try to create a date format with same machine name as the previous one.
- $edit = array(
+ $edit = [
'label' => $this->randomMachineName(16),
'id' => $id,
'date_format_pattern' => 'd-m-Y',
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertText(t('The machine-readable name is already in use. It must be unique.'), 'It is not possible to create a new date format with an existing machine name.');
}
diff --git a/web/core/modules/system/src/Tests/System/DateTimeTest.php b/web/core/modules/system/tests/src/Functional/System/DateTimeTest.php
similarity index 86%
rename from web/core/modules/system/src/Tests/System/DateTimeTest.php
rename to web/core/modules/system/tests/src/Functional/System/DateTimeTest.php
index 9ca050f40..3d35f96e2 100644
--- a/web/core/modules/system/src/Tests/System/DateTimeTest.php
+++ b/web/core/modules/system/tests/src/Functional/System/DateTimeTest.php
@@ -1,10 +1,10 @@
drupalLogin ($this->drupalCreateUser(array(
+ $this->drupalLogin ($this->drupalCreateUser([
'administer site configuration',
'administer content types',
'administer nodes',
'administer node fields',
'administer node form display',
'administer node display',
- )));
+ ]));
$this->drupalPlaceBlock('local_actions_block');
}
/**
* Test time zones and DST handling.
*/
- function testTimeZoneHandling() {
+ public function testTimeZoneHandling() {
// Setup date/time settings for Honolulu time.
$config = $this->config('system.date')
->set('timezone.default', 'Pacific/Honolulu')
@@ -52,9 +52,9 @@ class DateTimeTest extends WebTestBase {
// Create some nodes with different authored-on dates.
$date1 = '2007-01-31 21:00:00 -1000';
$date2 = '2007-07-31 21:00:00 -1000';
- $this->drupalCreateContentType(array('type' => 'article'));
- $node1 = $this->drupalCreateNode(array('created' => strtotime($date1), 'type' => 'article'));
- $node2 = $this->drupalCreateNode(array('created' => strtotime($date2), 'type' => 'article'));
+ $this->drupalCreateContentType(['type' => 'article']);
+ $node1 = $this->drupalCreateNode(['created' => strtotime($date1), 'type' => 'article']);
+ $node2 = $this->drupalCreateNode(['created' => strtotime($date2), 'type' => 'article']);
// Confirm date format and time zone.
$this->drupalGet('node/' . $node1->id());
@@ -64,7 +64,7 @@ class DateTimeTest extends WebTestBase {
// Set time zone to Los Angeles time.
$config->set('timezone.default', 'America/Los_Angeles')->save();
- \Drupal::entityManager()->getViewBuilder('node')->resetCache(array($node1, $node2));
+ \Drupal::entityManager()->getViewBuilder('node')->resetCache([$node1, $node2]);
// Confirm date format and time zone.
$this->drupalGet('node/' . $node1->id());
@@ -76,7 +76,7 @@ class DateTimeTest extends WebTestBase {
/**
* Test date format configuration.
*/
- function testDateFormatConfiguration() {
+ public function testDateFormatConfiguration() {
// Confirm 'no custom date formats available' message appears.
$this->drupalGet('admin/config/regional/date-time');
@@ -85,11 +85,11 @@ class DateTimeTest extends WebTestBase {
$date_format_id = strtolower($this->randomMachineName(8));
$name = ucwords($date_format_id);
$date_format = 'd.m.Y - H:i';
- $edit = array(
+ $edit = [
'id' => $date_format_id,
'label' => $name,
'date_format_pattern' => $date_format,
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertUrl(\Drupal::url('entity.date_format.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
$this->assertText(t('Custom date format added.'), 'Date format added confirmation message appears.');
@@ -100,24 +100,24 @@ class DateTimeTest extends WebTestBase {
$this->drupalGet('admin/config/regional/date-time');
$this->clickLink(t('Edit'));
$this->drupalPostForm(NULL, NULL, t('Save format'));
- $this->assertUrl('admin/config/regional/date-time', array('absolute' => TRUE), 'Correct page redirection.');
+ $this->assertUrl('admin/config/regional/date-time', ['absolute' => TRUE], 'Correct page redirection.');
$this->assertText(t('Custom date format updated.'), 'Custom date format successfully updated.');
// Edit custom date format.
$this->drupalGet('admin/config/regional/date-time');
$this->clickLink(t('Edit'));
- $edit = array(
+ $edit = [
'date_format_pattern' => 'Y m',
- );
+ ];
$this->drupalPostForm($this->getUrl(), $edit, t('Save format'));
$this->assertUrl(\Drupal::url('entity.date_format.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
$this->assertText(t('Custom date format updated.'), 'Custom date format successfully updated.');
// Delete custom date format.
$this->clickLink(t('Delete'));
- $this->drupalPostForm('admin/config/regional/date-time/formats/manage/' . $date_format_id . '/delete', array(), t('Delete'));
+ $this->drupalPostForm('admin/config/regional/date-time/formats/manage/' . $date_format_id . '/delete', [], t('Delete'));
$this->assertUrl(\Drupal::url('entity.date_format.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
- $this->assertRaw(t('The date format %format has been deleted.', array('%format' => $name)), 'Custom date format removed.');
+ $this->assertRaw(t('The date format %format has been deleted.', ['%format' => $name]), 'Custom date format removed.');
// Make sure the date does not exist in config.
$date_format = DateFormat::load($date_format_id);
@@ -127,22 +127,22 @@ class DateTimeTest extends WebTestBase {
$date_format_id = strtolower($this->randomMachineName(8));
$name = ucwords($date_format_id);
$date_format = 'Y';
- $edit = array(
+ $edit = [
'id' => $date_format_id,
'label' => $name,
'date_format_pattern' => $date_format,
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertUrl(\Drupal::url('entity.date_format.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
$this->assertText(t('Custom date format added.'), 'Date format added confirmation message appears.');
$this->assertText($name, 'Custom date format appears in the date format list.');
$this->assertText(t('Delete'), 'Delete link for custom date format appears.');
- $date_format = DateFormat::create(array(
+ $date_format = DateFormat::create([
'id' => 'xss_short',
'label' => 'XSS format',
'pattern' => '\<\s\c\r\i\p\t\>\a\l\e\r\t\(\'\X\S\S\'\)\;\<\/\s\c\r\i\p\t\>',
- ));
+ ]);
$date_format->save();
$this->drupalGet(Url::fromRoute('entity.date_format.collection'));
@@ -152,11 +152,11 @@ class DateTimeTest extends WebTestBase {
$date_format_id = strtolower($this->randomMachineName(8));
$name = ucwords($date_format_id);
$date_format = '& \<\e\m\>Y\<\/\e\m\>';
- $edit = array(
+ $edit = [
'id' => $date_format_id,
'label' => $name,
'date_format_pattern' => $date_format,
- );
+ ];
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertUrl(\Drupal::url('entity.date_format.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.');
$this->assertText(t('Custom date format added.'), 'Date format added confirmation message appears.');
@@ -167,52 +167,53 @@ class DateTimeTest extends WebTestBase {
/**
* Test handling case with invalid data in selectors (like February, 31st).
*/
- function testEnteringDateTimeViaSelectors() {
+ public function testEnteringDateTimeViaSelectors() {
- $this->drupalCreateContentType(array('type' => 'page_with_date', 'name' => 'Page with date'));
+ $this->drupalCreateContentType(['type' => 'page_with_date', 'name' => 'Page with date']);
$this->drupalGet('admin/structure/types/manage/page_with_date');
$this->assertResponse(200, 'Content type created.');
$this->drupalGet('admin/structure/types/manage/page_with_date/fields/add-field');
- $edit = array(
+ $edit = [
'new_storage_type' => 'datetime',
'label' => 'dt',
'field_name' => 'dt',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/page_with_date/fields/add-field', $edit, t('Save and continue'));
$this->assertText(t('These settings apply to the'), 'New datetime field created, now configuring');
$this->drupalGet('admin/structure/types/manage/page_with_date/fields/node.page_with_date.field_dt/storage');
- $edit = array(
+ $edit = [
'settings[datetime_type]' => 'datetime',
'cardinality' => 'number',
'cardinality_number' => '1',
- );
+ ];
$this->drupalPostForm('admin/structure/types/manage/page_with_date/fields/node.page_with_date.field_dt/storage', $edit, t('Save field settings'));
$this->drupalGet('admin/structure/types/manage/page_with_date/fields');
$this->assertText('field_dt', 'New field is in place');
$this->drupalGet('admin/structure/types/manage/page_with_date/form-display');
- $edit = array(
+ $edit = [
'fields[field_dt][type]' => 'datetime_datelist',
- );
+ 'fields[field_dt][region]' => 'content',
+ ];
$this->drupalPostForm('admin/structure/types/manage/page_with_date/form-display', $edit, t('Save'));
$this->drupalLogout();
// Now log in as a regular editor.
- $this->drupalLogin($this->drupalCreateUser(array('create page_with_date content')));
+ $this->drupalLogin($this->drupalCreateUser(['create page_with_date content']));
$this->drupalGet('node/add/page_with_date');
- $edit = array(
+ $edit = [
'title[0][value]' => 'sample doc',
'field_dt[0][value][year]' => '2016',
'field_dt[0][value][month]' => '2',
'field_dt[0][value][day]' => '31',
'field_dt[0][value][hour]' => '1',
'field_dt[0][value][minute]' => '30',
- );
+ ];
$this->drupalPostForm('node/add/page_with_date', $edit, t('Save'));
$this->assertText(t('Selected combination of day and month is not valid.'), 'Inorrect date failed validation');
diff --git a/web/core/modules/system/src/Tests/System/IndexPhpTest.php b/web/core/modules/system/tests/src/Functional/System/IndexPhpTest.php
similarity index 58%
rename from web/core/modules/system/src/Tests/System/IndexPhpTest.php
rename to web/core/modules/system/tests/src/Functional/System/IndexPhpTest.php
index 72811a8a3..2bf098931 100644
--- a/web/core/modules/system/src/Tests/System/IndexPhpTest.php
+++ b/web/core/modules/system/tests/src/Functional/System/IndexPhpTest.php
@@ -1,15 +1,15 @@
drupalGet($index_php, array('external' => TRUE));
+ $this->drupalGet($index_php, ['external' => TRUE]);
$this->assertResponse(200, 'Make sure index.php returns a valid page.');
- $this->drupalGet($index_php . '/user', array('external' => TRUE));
+ $this->drupalGet($index_php . '/user', ['external' => TRUE]);
$this->assertResponse(200, 'Make sure index.php/user returns a valid page.');
}
diff --git a/web/core/modules/system/src/Tests/System/MainContentFallbackTest.php b/web/core/modules/system/tests/src/Functional/System/MainContentFallbackTest.php
similarity index 82%
rename from web/core/modules/system/src/Tests/System/MainContentFallbackTest.php
rename to web/core/modules/system/tests/src/Functional/System/MainContentFallbackTest.php
index 551e4c744..931b84ce2 100644
--- a/web/core/modules/system/src/Tests/System/MainContentFallbackTest.php
+++ b/web/core/modules/system/tests/src/Functional/System/MainContentFallbackTest.php
@@ -1,22 +1,22 @@
adminUser = $this->drupalCreateUser(array(
+ $this->adminUser = $this->drupalCreateUser([
'access administration pages',
'administer site configuration',
'administer modules',
- ));
+ ]);
$this->drupalLogin($this->adminUser);
// Create a web user.
- $this->webUser = $this->drupalCreateUser(array('access user profiles'));
+ $this->webUser = $this->drupalCreateUser(['access user profiles']);
}
/**
* Test availability of main content: Drupal falls back to SimplePageVariant.
*/
- function testMainContentFallback() {
- $edit = array();
+ public function testMainContentFallback() {
+ $edit = [];
// Uninstall the block module.
$edit['uninstall[block]'] = 'block';
$this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
@@ -63,8 +63,8 @@ class MainContentFallbackTest extends WebTestBase {
// Enable the block module again.
$this->drupalLogin($this->adminUser);
- $edit = array();
- $edit['modules[Core][block][enable]'] = 'block';
+ $edit = [];
+ $edit['modules[block][enable]'] = 'block';
$this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->assertText(t('Module Block has been enabled.'), 'Modules status has been updated.');
$this->rebuildContainer();
diff --git a/web/core/modules/system/src/Tests/System/RetrieveFileTest.php b/web/core/modules/system/tests/src/Functional/System/RetrieveFileTest.php
similarity index 92%
rename from web/core/modules/system/src/Tests/System/RetrieveFileTest.php
rename to web/core/modules/system/tests/src/Functional/System/RetrieveFileTest.php
index 8f6fe4af1..ef12a51ad 100644
--- a/web/core/modules/system/src/Tests/System/RetrieveFileTest.php
+++ b/web/core/modules/system/tests/src/Functional/System/RetrieveFileTest.php
@@ -1,19 +1,19 @@
randomMachineName());
$filename = 'Файл для тестирования ' . $this->randomMachineName();
diff --git a/web/core/modules/system/src/Tests/System/SitesDirectoryHardeningTest.php b/web/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php
similarity index 91%
rename from web/core/modules/system/src/Tests/System/SitesDirectoryHardeningTest.php
rename to web/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php
index f9331ba8c..fbe97f4da 100644
--- a/web/core/modules/system/src/Tests/System/SitesDirectoryHardeningTest.php
+++ b/web/core/modules/system/tests/src/Functional/System/SitesDirectoryHardeningTest.php
@@ -1,18 +1,18 @@
settingsFile($site_path);
// First, we check based on what the initial install has set.
- $this->assertTrue(drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir'), new FormattableMarkup('Verified permissions for @file.', array('@file' => $site_path)));
+ $this->assertTrue(drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir'), new FormattableMarkup('Verified permissions for @file.', ['@file' => $site_path]));
// We intentionally don't check for settings.local.php as that file is
// not created by Drupal.
- $this->assertTrue(drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE), new FormattableMarkup('Verified permissions for @file.', array('@file' => $settings_file)));
+ $this->assertTrue(drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE), new FormattableMarkup('Verified permissions for @file.', ['@file' => $settings_file]));
$this->makeWritable($site_path);
$this->checkSystemRequirements();
- $this->assertTrue(drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir'), new FormattableMarkup('Verified permissions for @file after manual permissions change.', array('@file' => $site_path)));
- $this->assertTrue(drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE), new FormattableMarkup('Verified permissions for @file after manual permissions change.', array('@file' => $settings_file)));
+ $this->assertTrue(drupal_verify_install_file($site_path, FILE_NOT_WRITABLE, 'dir'), new FormattableMarkup('Verified permissions for @file after manual permissions change.', ['@file' => $site_path]));
+ $this->assertTrue(drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE), new FormattableMarkup('Verified permissions for @file after manual permissions change.', ['@file' => $settings_file]));
}
/**
diff --git a/web/core/modules/system/src/Tests/System/StatusTest.php b/web/core/modules/system/tests/src/Functional/System/StatusTest.php
similarity index 87%
rename from web/core/modules/system/src/Tests/System/StatusTest.php
rename to web/core/modules/system/tests/src/Functional/System/StatusTest.php
index c17031663..cb81d0521 100644
--- a/web/core/modules/system/src/Tests/System/StatusTest.php
+++ b/web/core/modules/system/tests/src/Functional/System/StatusTest.php
@@ -1,9 +1,9 @@
(object) array(
+ $settings['config_directories'] = [
+ CONFIG_SYNC_DIRECTORY => (object) [
'value' => '',
'required' => TRUE,
- ),
- );
+ ],
+ ];
$this->writeSettings($settings);
- $admin_user = $this->drupalCreateUser(array(
+ $admin_user = $this->drupalCreateUser([
'administer site configuration',
- ));
+ ]);
$this->drupalLogin($admin_user);
}
@@ -71,7 +71,7 @@ class StatusTest extends WebTestBase {
$this->assertNoText(t('Out of date'));
// The global $config_directories is not properly formed.
- $this->assertRaw(t('Your %file file must define the $config_directories variable as an array containing the names of directories in which configuration files can be found. It must contain a %sync_key key.', array('%file' => $this->siteDirectory . '/settings.php', '%sync_key' => CONFIG_SYNC_DIRECTORY)));
+ $this->assertRaw(t('Your %file file must define the $config_directories variable as an array containing the names of directories in which configuration files can be found. It must contain a %sync_key key.', ['%file' => $this->siteDirectory . '/settings.php', '%sync_key' => CONFIG_SYNC_DIRECTORY]));
// Set the schema version of update_test_postupdate to a lower version, so
// update_test_postupdate_update_8001() needs to be executed.
diff --git a/web/core/modules/system/src/Tests/System/SystemAuthorizeTest.php b/web/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php
similarity index 75%
rename from web/core/modules/system/src/Tests/System/SystemAuthorizeTest.php
rename to web/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php
index 5e278d723..8fa81ac29 100644
--- a/web/core/modules/system/src/Tests/System/SystemAuthorizeTest.php
+++ b/web/core/modules/system/tests/src/Functional/System/SystemAuthorizeTest.php
@@ -1,28 +1,28 @@
drupalLogin ($this->drupalCreateUser(array('administer software updates')));
+ $this->drupalLogin ($this->drupalCreateUser(['administer software updates']));
}
/**
@@ -36,17 +36,17 @@ class SystemAuthorizeTest extends WebTestBase {
*
* @see system_authorized_init()
*/
- function drupalGetAuthorizePHP($page_title = 'system-test-auth') {
+ public function drupalGetAuthorizePHP($page_title = 'system-test-auth') {
$this->drupalGet('system-test/authorize-init/' . $page_title);
}
/**
* Tests the FileTransfer hooks
*/
- function testFileTransferHooks() {
+ public function testFileTransferHooks() {
$page_title = $this->randomMachineName(16);
$this->drupalGetAuthorizePHP($page_title);
- $this->assertTitle(strtr('@title | Drupal', array('@title' => $page_title)), 'authorize.php page title is correct.');
+ $this->assertTitle(strtr('@title | Drupal', ['@title' => $page_title]), 'authorize.php page title is correct.');
$this->assertNoText('It appears you have reached this page in error.');
$this->assertText('To continue, provide your server connection details');
// Make sure we see the new connection method added by system_test.
diff --git a/web/core/modules/system/src/Tests/System/TokenScanTest.php b/web/core/modules/system/tests/src/Functional/System/TokenScanTest.php
similarity index 89%
rename from web/core/modules/system/src/Tests/System/TokenScanTest.php
rename to web/core/modules/system/tests/src/Functional/System/TokenScanTest.php
index 89f2abda4..f284aa978 100644
--- a/web/core/modules/system/src/Tests/System/TokenScanTest.php
+++ b/web/core/modules/system/tests/src/Functional/System/TokenScanTest.php
@@ -1,20 +1,20 @@
drupalCreateUser(array(
+ $admin_user = $this->drupalCreateUser([
'administer site configuration',
- ));
+ ]);
$this->drupalLogin($admin_user);
}
@@ -39,10 +39,10 @@ class TrustedHostsTest extends WebTestBase {
* Tests that the status page shows the trusted patterns from settings.php.
*/
public function testStatusPageWithConfiguration() {
- $settings['settings']['trusted_host_patterns'] = (object) array(
- 'value' => array('^' . preg_quote(\Drupal::request()->getHost()) . '$'),
+ $settings['settings']['trusted_host_patterns'] = (object) [
+ 'value' => ['^' . preg_quote(\Drupal::request()->getHost()) . '$'],
'required' => TRUE,
- );
+ ];
$this->writeSettings($settings);
@@ -63,10 +63,10 @@ class TrustedHostsTest extends WebTestBase {
$this->container->get('router.builder')->rebuild();
$host = $this->container->get('request_stack')->getCurrentRequest()->getHost();
- $settings['settings']['trusted_host_patterns'] = (object) array(
- 'value' => array('^' . preg_quote($host) . '$'),
+ $settings['settings']['trusted_host_patterns'] = (object) [
+ 'value' => ['^' . preg_quote($host) . '$'],
'required' => TRUE,
- );
+ ];
$this->writeSettings($settings);
diff --git a/web/core/modules/system/src/Tests/Theme/EngineNyanCatTest.php b/web/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php
similarity index 65%
rename from web/core/modules/system/src/Tests/Theme/EngineNyanCatTest.php
rename to web/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php
index 0eb43b7d5..6dca1b38d 100644
--- a/web/core/modules/system/src/Tests/Theme/EngineNyanCatTest.php
+++ b/web/core/modules/system/tests/src/Functional/Theme/EngineNyanCatTest.php
@@ -1,32 +1,32 @@
install(array('test_theme_nyan_cat_engine'));
+ \Drupal::service('theme_handler')->install(['test_theme_nyan_cat_engine']);
}
/**
* Ensures a theme's template is overridable based on the 'template' filename.
*/
- function testTemplateOverride() {
+ public function testTemplateOverride() {
$this->config('system.theme')
->set('default', 'test_theme_nyan_cat_engine')
->save();
diff --git a/web/core/modules/system/src/Tests/Theme/FastTest.php b/web/core/modules/system/tests/src/Functional/Theme/FastTest.php
similarity index 55%
rename from web/core/modules/system/src/Tests/Theme/FastTest.php
rename to web/core/modules/system/tests/src/Functional/Theme/FastTest.php
index a05666fe0..d8f85f1f4 100644
--- a/web/core/modules/system/src/Tests/Theme/FastTest.php
+++ b/web/core/modules/system/tests/src/Functional/Theme/FastTest.php
@@ -1,34 +1,34 @@
account = $this->drupalCreateUser(array('access user profiles'));
+ $this->account = $this->drupalCreateUser(['access user profiles']);
}
/**
* Tests access to user autocompletion and verify the correct results.
*/
- function testUserAutocomplete() {
+ public function testUserAutocomplete() {
$this->drupalLogin($this->account);
- $this->drupalGet('user/autocomplete', array('query' => array('q' => $this->account->getUsername())));
+ $this->drupalGet('user/autocomplete', ['query' => ['q' => $this->account->getUsername()]]);
$this->assertRaw($this->account->getUsername());
$this->assertNoText('registry initialized', 'The registry was not initialized');
}
diff --git a/web/core/modules/system/src/Tests/Theme/ThemeEarlyInitializationTest.php b/web/core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php
similarity index 74%
rename from web/core/modules/system/src/Tests/Theme/ThemeEarlyInitializationTest.php
rename to web/core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php
index ddbb770aa..040dfabfc 100644
--- a/web/core/modules/system/src/Tests/Theme/ThemeEarlyInitializationTest.php
+++ b/web/core/modules/system/tests/src/Functional/Theme/ThemeEarlyInitializationTest.php
@@ -1,8 +1,8 @@
drupalGet('theme-test/request-listener');
// Verify that themed output generated in the request listener appears.
$this->assertRaw('Themed output generated in a KernelEvents::REQUEST listener');
diff --git a/web/core/modules/system/src/Tests/Theme/ThemeInfoTest.php b/web/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php
similarity index 71%
rename from web/core/modules/system/src/Tests/Theme/ThemeInfoTest.php
rename to web/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php
index 043986a61..ee41968a5 100644
--- a/web/core/modules/system/src/Tests/Theme/ThemeInfoTest.php
+++ b/web/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php
@@ -1,22 +1,22 @@
themeHandler->install(array('test_basetheme', 'test_subtheme'));
+ public function testStylesheets() {
+ $this->themeHandler->install(['test_basetheme', 'test_subtheme']);
$this->config('system.theme')
->set('default', 'test_subtheme')
->save();
@@ -66,16 +66,16 @@ class ThemeInfoTest extends WebTestBase {
// should work nevertheless.
$this->drupalGet('theme-test/info/stylesheets');
- $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "$base/base-add.css"))), "$base/base-add.css found");
- $this->assertIdentical(0, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "base-remove.css"))), "base-remove.css not found");
+ $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', [':href' => "$base/base-add.css"])), "$base/base-add.css found");
+ $this->assertIdentical(0, count($this->xpath('//link[contains(@href, :href)]', [':href' => "base-remove.css"])), "base-remove.css not found");
- $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "$sub/sub-add.css"))), "$sub/sub-add.css found");
- $this->assertIdentical(0, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "sub-remove.css"))), "sub-remove.css not found");
- $this->assertIdentical(0, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "base-add.sub-remove.css"))), "base-add.sub-remove.css not found");
+ $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', [':href' => "$sub/sub-add.css"])), "$sub/sub-add.css found");
+ $this->assertIdentical(0, count($this->xpath('//link[contains(@href, :href)]', [':href' => "sub-remove.css"])), "sub-remove.css not found");
+ $this->assertIdentical(0, count($this->xpath('//link[contains(@href, :href)]', [':href' => "base-add.sub-remove.css"])), "base-add.sub-remove.css not found");
// Verify that CSS files with the same name are loaded from both the base theme and subtheme.
- $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "$base/samename.css"))), "$base/samename.css found");
- $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "$sub/samename.css"))), "$sub/samename.css found");
+ $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', [':href' => "$base/samename.css"])), "$base/samename.css found");
+ $this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', [':href' => "$sub/samename.css"])), "$sub/samename.css found");
}
@@ -83,8 +83,8 @@ class ThemeInfoTest extends WebTestBase {
* Tests that changes to the info file are picked up.
*/
public function testChanges() {
- $this->themeHandler->install(array('test_theme'));
- $this->themeHandler->setDefault('test_theme');
+ $this->themeHandler->install(['test_theme']);
+ $this->config('system.theme')->set('default', 'test_theme')->save();
$this->themeManager->resetActiveTheme();
$active_theme = $this->themeManager->getActiveTheme();
diff --git a/web/core/modules/system/src/Tests/Theme/ThemeTokenTest.php b/web/core/modules/system/tests/src/Functional/Theme/ThemeTokenTest.php
similarity index 92%
rename from web/core/modules/system/src/Tests/Theme/ThemeTokenTest.php
rename to web/core/modules/system/tests/src/Functional/Theme/ThemeTokenTest.php
index c3b1f8c6f..1488c5b3e 100644
--- a/web/core/modules/system/src/Tests/Theme/ThemeTokenTest.php
+++ b/web/core/modules/system/tests/src/Functional/Theme/ThemeTokenTest.php
@@ -1,15 +1,15 @@
install(array('test_theme'));
+ \Drupal::service('theme_handler')->install(['test_theme']);
}
/**
* Tests that the provided Twig extension loads the service appropriately.
*/
- function testTwigExtensionLoaded() {
+ public function testTwigExtensionLoaded() {
$twigService = \Drupal::service('twig');
$ext = $twigService->getExtension('twig_extension_test.test_extension');
$this->assertEqual(get_class($ext), 'Drupal\twig_extension_test\TwigExtension\TestExtension', 'TestExtension loaded successfully.');
@@ -35,7 +35,7 @@ class TwigExtensionTest extends WebTestBase {
/**
* Tests that the Twig extension's filter produces expected output.
*/
- function testTwigExtensionFilter() {
+ public function testTwigExtensionFilter() {
$this->config('system.theme')
->set('default', 'test_theme')
->save();
@@ -49,7 +49,7 @@ class TwigExtensionTest extends WebTestBase {
/**
* Tests that the Twig extension's function produces expected output.
*/
- function testTwigExtensionFunction() {
+ public function testTwigExtensionFunction() {
$this->config('system.theme')
->set('default', 'test_theme')
->save();
diff --git a/web/core/modules/system/src/Tests/Theme/TwigLoaderTest.php b/web/core/modules/system/tests/src/Functional/Theme/TwigLoaderTest.php
similarity index 53%
rename from web/core/modules/system/src/Tests/Theme/TwigLoaderTest.php
rename to web/core/modules/system/tests/src/Functional/Theme/TwigLoaderTest.php
index 84a112c00..d2b0b5465 100644
--- a/web/core/modules/system/src/Tests/Theme/TwigLoaderTest.php
+++ b/web/core/modules/system/tests/src/Functional/Theme/TwigLoaderTest.php
@@ -1,15 +1,15 @@
loadTemplate('kittens');
- $this->assertEqual($template->render(array()), 'kittens', 'Passing "kittens" to the custom Twig loader returns "kittens".');
+ $this->assertEqual($template->render([]), 'kittens', 'Passing "kittens" to the custom Twig loader returns "kittens".');
$template = $environment->loadTemplate('meow');
- $this->assertEqual($template->render(array()), 'cats', 'Passing something other than "kittens" to the custom Twig loader returns "cats".');
+ $this->assertEqual($template->render([]), 'cats', 'Passing something other than "kittens" to the custom Twig loader returns "cats".');
}
}
diff --git a/web/core/modules/system/src/Tests/Theme/TwigRegistryLoaderTest.php b/web/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php
similarity index 89%
rename from web/core/modules/system/src/Tests/Theme/TwigRegistryLoaderTest.php
rename to web/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php
index 5cbca9f33..244628998 100644
--- a/web/core/modules/system/src/Tests/Theme/TwigRegistryLoaderTest.php
+++ b/web/core/modules/system/tests/src/Functional/Theme/TwigRegistryLoaderTest.php
@@ -1,22 +1,22 @@
install(array('test_theme_twig_registry_loader', 'test_theme_twig_registry_loader_theme', 'test_theme_twig_registry_loader_subtheme'));
+ \Drupal::service('theme_handler')->install(['test_theme_twig_registry_loader', 'test_theme_twig_registry_loader_theme', 'test_theme_twig_registry_loader_subtheme']);
$this->twig = \Drupal::service('twig');
}
diff --git a/web/core/modules/system/src/Tests/Theme/TwigSettingsTest.php b/web/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php
similarity index 91%
rename from web/core/modules/system/src/Tests/Theme/TwigSettingsTest.php
rename to web/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php
index b776639fe..0ad88ce32 100644
--- a/web/core/modules/system/src/Tests/Theme/TwigSettingsTest.php
+++ b/web/core/modules/system/tests/src/Functional/Theme/TwigSettingsTest.php
@@ -1,8 +1,8 @@
container->getParameter('twig.config');
$parameters['auto_reload'] = TRUE;
@@ -44,7 +44,7 @@ class TwigSettingsTest extends WebTestBase {
/**
* Ensures Twig engine debug setting can be overridden.
*/
- function testTwigDebugOverride() {
+ public function testTwigDebugOverride() {
// Enable debug and rebuild the service container.
$parameters = $this->container->getParameter('twig.config');
$parameters['debug'] = TRUE;
@@ -74,11 +74,11 @@ class TwigSettingsTest extends WebTestBase {
/**
* Ensures Twig template cache setting can be overridden.
*/
- function testTwigCacheOverride() {
+ public function testTwigCacheOverride() {
$extension = twig_extension();
$theme_handler = $this->container->get('theme_handler');
- $theme_handler->install(array('test_theme'));
- $theme_handler->setDefault('test_theme');
+ $theme_handler->install(['test_theme']);
+ $this->config('system.theme')->set('default', 'test_theme')->save();
// The registry still works on theme globals, so set them here.
\Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->getActiveThemeByName('test_theme'));
diff --git a/web/core/modules/system/tests/src/Kernel/Action/ActionTest.php b/web/core/modules/system/tests/src/Kernel/Action/ActionTest.php
index 4ca24fb5a..6c381d7c8 100644
--- a/web/core/modules/system/tests/src/Kernel/Action/ActionTest.php
+++ b/web/core/modules/system/tests/src/Kernel/Action/ActionTest.php
@@ -17,7 +17,7 @@ class ActionTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('system', 'field', 'user', 'action_test');
+ public static $modules = ['system', 'field', 'user', 'action_test'];
/**
* The action manager.
@@ -34,7 +34,7 @@ class ActionTest extends KernelTestBase {
$this->actionManager = $this->container->get('plugin.manager.action');
$this->installEntitySchema('user');
- $this->installSchema('system', array('sequences'));
+ $this->installSchema('system', ['sequences']);
}
/**
@@ -59,7 +59,7 @@ class ActionTest extends KernelTestBase {
// Create a new unsaved user.
$name = $this->randomMachineName();
$user_storage = $this->container->get('entity.manager')->getStorage('user');
- $account = $user_storage->create(array('name' => $name, 'bundle' => 'user'));
+ $account = $user_storage->create(['name' => $name, 'bundle' => 'user']);
$loaded_accounts = $user_storage->loadMultiple();
$this->assertEqual(count($loaded_accounts), 0);
@@ -76,25 +76,25 @@ class ActionTest extends KernelTestBase {
*/
public function testDependencies() {
// Create a new action that depends on a user role.
- $action = Action::create(array(
+ $action = Action::create([
'id' => 'user_add_role_action.' . RoleInterface::ANONYMOUS_ID,
'type' => 'user',
'label' => t('Add the anonymous role to the selected users'),
- 'configuration' => array(
+ 'configuration' => [
'rid' => RoleInterface::ANONYMOUS_ID,
- ),
+ ],
'plugin' => 'user_add_role_action',
- ));
+ ]);
$action->save();
- $expected = array(
- 'config' => array(
+ $expected = [
+ 'config' => [
'user.role.' . RoleInterface::ANONYMOUS_ID,
- ),
- 'module' => array(
+ ],
+ 'module' => [
'user',
- ),
- );
+ ],
+ ];
$this->assertIdentical($expected, $action->calculateDependencies()->getDependencies());
}
diff --git a/web/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php b/web/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
index ca1c5afff..6a9825e12 100644
--- a/web/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
+++ b/web/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
@@ -31,7 +31,7 @@ class SystemMenuBlockTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array(
+ public static $modules = [
'system',
'block',
'menu_test',
@@ -39,7 +39,7 @@ class SystemMenuBlockTest extends KernelTestBase {
'field',
'user',
'link',
- );
+ ];
/**
* The block under test.
@@ -97,16 +97,16 @@ class SystemMenuBlockTest extends KernelTestBase {
$this->blockManager = $this->container->get('plugin.manager.block');
$routes = new RouteCollection();
- $requirements = array('_access' => 'TRUE');
- $options = array('_access_checks' => array('access_check.default'));
- $routes->add('example1', new Route('/example1', array(), $requirements, $options));
- $routes->add('example2', new Route('/example2', array(), $requirements, $options));
- $routes->add('example3', new Route('/example3', array(), $requirements, $options));
- $routes->add('example4', new Route('/example4', array(), $requirements, $options));
- $routes->add('example5', new Route('/example5', array(), $requirements, $options));
- $routes->add('example6', new Route('/example6', array(), $requirements, $options));
- $routes->add('example7', new Route('/example7', array(), $requirements, $options));
- $routes->add('example8', new Route('/example8', array(), $requirements, $options));
+ $requirements = ['_access' => 'TRUE'];
+ $options = ['_access_checks' => ['access_check.default']];
+ $routes->add('example1', new Route('/example1', [], $requirements, $options));
+ $routes->add('example2', new Route('/example2', [], $requirements, $options));
+ $routes->add('example3', new Route('/example3', [], $requirements, $options));
+ $routes->add('example4', new Route('/example4', [], $requirements, $options));
+ $routes->add('example5', new Route('/example5', [], $requirements, $options));
+ $routes->add('example6', new Route('/example6', [], $requirements, $options));
+ $routes->add('example7', new Route('/example7', [], $requirements, $options));
+ $routes->add('example8', new Route('/example8', [], $requirements, $options));
$mock_route_provider = new MockRouteProvider($routes);
$this->container->set('router.route_provider', $mock_route_provider);
@@ -115,11 +115,11 @@ class SystemMenuBlockTest extends KernelTestBase {
$menu_name = 'mock';
$label = $this->randomMachineName(16);
- $this->menu = Menu::create(array(
+ $this->menu = Menu::create([
'id' => $menu_name,
'label' => $label,
'description' => 'Description text',
- ));
+ ]);
$this->menu->save();
// This creates a tree with the following structure:
@@ -132,16 +132,16 @@ class SystemMenuBlockTest extends KernelTestBase {
// - 6
// - 8
// With link 6 being the only external link.
- $links = array(
- 1 => MenuLinkMock::create(array('id' => 'test.example1', 'route_name' => 'example1', 'title' => 'foo', 'parent' => '', 'weight' => 0)),
- 2 => MenuLinkMock::create(array('id' => 'test.example2', 'route_name' => 'example2', 'title' => 'bar', 'parent' => '', 'route_parameters' => array('foo' => 'bar'), 'weight' => 1)),
- 3 => MenuLinkMock::create(array('id' => 'test.example3', 'route_name' => 'example3', 'title' => 'baz', 'parent' => 'test.example2', 'weight' => 2)),
- 4 => MenuLinkMock::create(array('id' => 'test.example4', 'route_name' => 'example4', 'title' => 'qux', 'parent' => 'test.example3', 'weight' => 3)),
- 5 => MenuLinkMock::create(array('id' => 'test.example5', 'route_name' => 'example5', 'title' => 'foofoo', 'parent' => '', 'expanded' => TRUE, 'weight' => 4)),
- 6 => MenuLinkMock::create(array('id' => 'test.example6', 'route_name' => '', 'url' => 'https://www.drupal.org/', 'title' => 'barbar', 'parent' => '', 'weight' => 5)),
- 7 => MenuLinkMock::create(array('id' => 'test.example7', 'route_name' => 'example7', 'title' => 'bazbaz', 'parent' => 'test.example5', 'weight' => 6)),
- 8 => MenuLinkMock::create(array('id' => 'test.example8', 'route_name' => 'example8', 'title' => 'quxqux', 'parent' => '', 'weight' => 7)),
- );
+ $links = [
+ 1 => MenuLinkMock::create(['id' => 'test.example1', 'route_name' => 'example1', 'title' => 'foo', 'parent' => '', 'weight' => 0]),
+ 2 => MenuLinkMock::create(['id' => 'test.example2', 'route_name' => 'example2', 'title' => 'bar', 'parent' => '', 'route_parameters' => ['foo' => 'bar'], 'weight' => 1]),
+ 3 => MenuLinkMock::create(['id' => 'test.example3', 'route_name' => 'example3', 'title' => 'baz', 'parent' => 'test.example2', 'weight' => 2]),
+ 4 => MenuLinkMock::create(['id' => 'test.example4', 'route_name' => 'example4', 'title' => 'qux', 'parent' => 'test.example3', 'weight' => 3]),
+ 5 => MenuLinkMock::create(['id' => 'test.example5', 'route_name' => 'example5', 'title' => 'foofoo', 'parent' => '', 'expanded' => TRUE, 'weight' => 4]),
+ 6 => MenuLinkMock::create(['id' => 'test.example6', 'route_name' => '', 'url' => 'https://www.drupal.org/', 'title' => 'barbar', 'parent' => '', 'weight' => 5]),
+ 7 => MenuLinkMock::create(['id' => 'test.example7', 'route_name' => 'example7', 'title' => 'bazbaz', 'parent' => 'test.example5', 'weight' => 6]),
+ 8 => MenuLinkMock::create(['id' => 'test.example8', 'route_name' => 'example8', 'title' => 'quxqux', 'parent' => '', 'weight' => 7]),
+ ];
foreach ($links as $instance) {
$this->menuLinkManager->addDefinition($instance->getPluginId(), $instance->getPluginDefinition());
}
@@ -152,25 +152,25 @@ class SystemMenuBlockTest extends KernelTestBase {
*/
public function testSystemMenuBlockConfigDependencies() {
- $block = Block::create(array(
+ $block = Block::create([
'plugin' => 'system_menu_block:' . $this->menu->id(),
'region' => 'footer',
'id' => 'machinename',
'theme' => 'stark',
- ));
+ ]);
$dependencies = $block->calculateDependencies()->getDependencies();
- $expected = array(
- 'config' => array(
+ $expected = [
+ 'config' => [
'system.menu.' . $this->menu->id()
- ),
- 'module' => array(
+ ],
+ 'module' => [
'system'
- ),
- 'theme' => array(
+ ],
+ 'theme' => [
'stark'
- ),
- );
+ ],
+ ];
$this->assertIdentical($expected, $dependencies);
}
@@ -180,13 +180,13 @@ class SystemMenuBlockTest extends KernelTestBase {
public function testConfigLevelDepth() {
// Helper function to generate a configured block instance.
$place_block = function ($level, $depth) {
- return $this->blockManager->createInstance('system_menu_block:' . $this->menu->id(), array(
+ return $this->blockManager->createInstance('system_menu_block:' . $this->menu->id(), [
'region' => 'footer',
'id' => 'machinename',
'theme' => 'stark',
'level' => $level,
'depth' => $depth,
- ));
+ ]);
};
// All the different block instances we're going to test.
diff --git a/web/core/modules/system/tests/src/Kernel/Common/PageRenderTest.php b/web/core/modules/system/tests/src/Kernel/Common/PageRenderTest.php
index 80729448d..fa1694734 100644
--- a/web/core/modules/system/tests/src/Kernel/Common/PageRenderTest.php
+++ b/web/core/modules/system/tests/src/Kernel/Common/PageRenderTest.php
@@ -14,7 +14,7 @@ class PageRenderTest extends KernelTestBase {
/**
* Tests hook_page_attachments() exceptions.
*/
- function testHookPageAttachmentsExceptions() {
+ public function testHookPageAttachmentsExceptions() {
$this->enableModules(['common_test', 'system']);
\Drupal::service('router.builder')->rebuild();
@@ -24,7 +24,7 @@ class PageRenderTest extends KernelTestBase {
/**
* Tests hook_page_attachments_alter() exceptions.
*/
- function testHookPageAlter() {
+ public function testHookPageAlter() {
$this->enableModules(['common_test', 'system']);
\Drupal::service('router.builder')->rebuild();
@@ -39,7 +39,7 @@ class PageRenderTest extends KernelTestBase {
* @param string $hook
* The page render hook to assert expected exceptions for.
*/
- function assertPageRenderHookExceptions($module, $hook) {
+ public function assertPageRenderHookExceptions($module, $hook) {
$html_renderer = \Drupal::getContainer()->get('main_content_renderer.html');
// Assert a valid hook implementation doesn't trigger an exception.
diff --git a/web/core/modules/system/tests/src/Kernel/Common/SystemListingTest.php b/web/core/modules/system/tests/src/Kernel/Common/SystemListingTest.php
index 7de7ecfb6..b0412b433 100644
--- a/web/core/modules/system/tests/src/Kernel/Common/SystemListingTest.php
+++ b/web/core/modules/system/tests/src/Kernel/Common/SystemListingTest.php
@@ -14,17 +14,17 @@ class SystemListingTest extends KernelTestBase {
/**
* Tests that files in different directories take precedence as expected.
*/
- function testDirectoryPrecedence() {
+ public function testDirectoryPrecedence() {
// Define the module files we will search for, and the directory precedence
// we expect.
- $expected_directories = array(
+ $expected_directories = [
// When both copies of the module are compatible with Drupal core, the
// copy in the profile directory takes precedence.
- 'drupal_system_listing_compatible_test' => array(
+ 'drupal_system_listing_compatible_test' => [
'core/profiles/testing/modules',
'core/modules/system/tests/modules',
- ),
- );
+ ],
+ ];
// This test relies on two versions of the same module existing in
// different places in the filesystem. Without that, the test has no
@@ -32,22 +32,22 @@ class SystemListingTest extends KernelTestBase {
foreach ($expected_directories as $module => $directories) {
foreach ($directories as $directory) {
$filename = "$directory/$module/$module.info.yml";
- $this->assertTrue(file_exists(\Drupal::root() . '/' . $filename), format_string('@filename exists.', array('@filename' => $filename)));
+ $this->assertTrue(file_exists(\Drupal::root() . '/' . $filename), format_string('@filename exists.', ['@filename' => $filename]));
}
}
// Now scan the directories and check that the files take precedence as
// expected.
$listing = new ExtensionDiscovery(\Drupal::root());
- $listing->setProfileDirectories(array('core/profiles/testing'));
+ $listing->setProfileDirectories(['core/profiles/testing']);
$files = $listing->scan('module');
foreach ($expected_directories as $module => $directories) {
$expected_directory = array_shift($directories);
$expected_uri = "$expected_directory/$module/$module.info.yml";
- $this->assertEqual($files[$module]->getPathname(), $expected_uri, format_string('Module @actual was found at @expected.', array(
+ $this->assertEqual($files[$module]->getPathname(), $expected_uri, format_string('Module @actual was found at @expected.', [
'@actual' => $files[$module]->getPathname(),
'@expected' => $expected_uri,
- )));
+ ]));
}
}
@@ -56,7 +56,7 @@ class SystemListingTest extends KernelTestBase {
*/
public function testFileScanIgnoreDirectory() {
$listing = new ExtensionDiscovery(\Drupal::root(), FALSE);
- $listing->setProfileDirectories(array('core/profiles/testing'));
+ $listing->setProfileDirectories(['core/profiles/testing']);
$files = $listing->scan('module');
$this->assertArrayHasKey('drupal_system_listing_compatible_test', $files);
@@ -68,7 +68,7 @@ class SystemListingTest extends KernelTestBase {
$this->setSetting('file_scan_ignore_directories', ['drupal_system_listing_compatible_test']);
$listing = new ExtensionDiscovery(\Drupal::root(), FALSE);
- $listing->setProfileDirectories(array('core/profiles/testing'));
+ $listing->setProfileDirectories(['core/profiles/testing']);
$files = $listing->scan('module');
$this->assertArrayNotHasKey('drupal_system_listing_compatible_test', $files);
}
diff --git a/web/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/web/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
index 8a3e98ed8..22648a639 100644
--- a/web/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
+++ b/web/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
@@ -38,13 +38,13 @@ class ModuleHandlerTest extends KernelTestBase {
/**
* The basic functionality of retrieving enabled modules.
*/
- function testModuleList() {
+ public function testModuleList() {
$module_list = ['system'];
$this->assertModuleList($module_list, 'Initial');
// Try to install a new module.
- $this->moduleInstaller()->install(array('ban'));
+ $this->moduleInstaller()->install(['ban']);
$module_list[] = 'ban';
sort($module_list);
$this->assertModuleList($module_list, 'After adding a module');
@@ -58,10 +58,10 @@ class ModuleHandlerTest extends KernelTestBase {
$this->assertModuleList($module_list, 'After changing weights');
// Test the fixed list feature.
- $fixed_list = array(
+ $fixed_list = [
'system' => 'core/modules/system/system.module',
'menu' => 'core/modules/menu/menu.module',
- );
+ ];
$this->moduleHandler()->setModuleList($fixed_list);
$new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list));
$this->assertModuleList($new_module_list, t('When using a fixed list'));
@@ -77,7 +77,7 @@ class ModuleHandlerTest extends KernelTestBase {
protected function assertModuleList(array $expected_values, $condition) {
$expected_values = array_values(array_unique($expected_values));
$enabled_modules = array_keys($this->container->get('module_handler')->getModuleList());
- $this->assertEqual($expected_values, $enabled_modules, format_string('@condition: extension handler returns correct results', array('@condition' => $condition)));
+ $this->assertEqual($expected_values, $enabled_modules, format_string('@condition: extension handler returns correct results', ['@condition' => $condition]));
}
/**
@@ -92,8 +92,8 @@ class ModuleHandlerTest extends KernelTestBase {
* @see module_test_system_info_alter()
* @see https://www.drupal.org/files/issues/dep.gv__0.png
*/
- function testDependencyResolution() {
- $this->enableModules(array('module_test'));
+ public function testDependencyResolution() {
+ $this->enableModules(['module_test']);
$this->assertTrue($this->moduleHandler()->moduleExists('module_test'), 'Test module is enabled.');
// Ensure that modules are not enabled.
@@ -108,7 +108,7 @@ class ModuleHandlerTest extends KernelTestBase {
drupal_static_reset('system_rebuild_module_data');
try {
- $result = $this->moduleInstaller()->install(array('color'));
+ $result = $this->moduleInstaller()->install(['color']);
$this->fail(t('ModuleInstaller::install() throws an exception if dependencies are missing.'));
}
catch (MissingDependencyException $e) {
@@ -122,7 +122,7 @@ class ModuleHandlerTest extends KernelTestBase {
\Drupal::state()->set('module_test.dependency', 'dependency');
drupal_static_reset('system_rebuild_module_data');
- $result = $this->moduleInstaller()->install(array('color'));
+ $result = $this->moduleInstaller()->install(['color']);
$this->assertTrue($result, 'ModuleInstaller::install() returns the correct value.');
// Verify that the fake dependency chain was installed.
@@ -132,20 +132,20 @@ class ModuleHandlerTest extends KernelTestBase {
$this->assertTrue($this->moduleHandler()->moduleExists('color'), 'Module installation with dependencies succeeded.');
// Verify that the modules were enabled in the correct order.
- $module_order = \Drupal::state()->get('module_test.install_order') ?: array();
- $this->assertEqual($module_order, array('help', 'config', 'color'));
+ $module_order = \Drupal::state()->get('module_test.install_order') ?: [];
+ $this->assertEqual($module_order, ['help', 'config', 'color']);
// Uninstall all three modules explicitly, but in the incorrect order,
// and make sure that ModuleInstaller::uninstall() uninstalled them in the
// correct sequence.
- $result = $this->moduleInstaller()->uninstall(array('config', 'help', 'color'));
+ $result = $this->moduleInstaller()->uninstall(['config', 'help', 'color']);
$this->assertTrue($result, 'ModuleInstaller::uninstall() returned TRUE.');
- foreach (array('color', 'config', 'help') as $module) {
+ foreach (['color', 'config', 'help'] as $module) {
$this->assertEqual(drupal_get_installed_schema_version($module), SCHEMA_UNINSTALLED, "$module module was uninstalled.");
}
- $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: array();
- $this->assertEqual($uninstalled_modules, array('color', 'config', 'help'), 'Modules were uninstalled in the correct order.');
+ $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: [];
+ $this->assertEqual($uninstalled_modules, ['color', 'config', 'help'], 'Modules were uninstalled in the correct order.');
// Enable Color module again, which should enable both the Config module and
// Help module. But, this time do it with Config module declaring a
@@ -154,7 +154,7 @@ class ModuleHandlerTest extends KernelTestBase {
\Drupal::state()->set('module_test.dependency', 'version dependency');
drupal_static_reset('system_rebuild_module_data');
- $result = $this->moduleInstaller()->install(array('color'));
+ $result = $this->moduleInstaller()->install(['color']);
$this->assertTrue($result, 'ModuleInstaller::install() returns the correct value.');
// Verify that the fake dependency chain was installed.
@@ -164,14 +164,14 @@ class ModuleHandlerTest extends KernelTestBase {
$this->assertTrue($this->moduleHandler()->moduleExists('color'), 'Module installation with version dependencies succeeded.');
// Finally, verify that the modules were enabled in the correct order.
- $enable_order = \Drupal::state()->get('module_test.install_order') ?: array();
- $this->assertIdentical($enable_order, array('help', 'config', 'color'));
+ $enable_order = \Drupal::state()->get('module_test.install_order') ?: [];
+ $this->assertIdentical($enable_order, ['help', 'config', 'color']);
}
/**
* Tests uninstalling a module that is a "dependency" of a profile.
*/
- function testUninstallProfileDependency() {
+ public function testUninstallProfileDependency() {
$profile = 'minimal';
$dependency = 'dblog';
$this->setSetting('install_profile', $profile);
@@ -180,23 +180,23 @@ class ModuleHandlerTest extends KernelTestBase {
// yet have any cached way to retrieve its location.
// @todo Remove as part of https://www.drupal.org/node/2186491
drupal_get_filename('profile', $profile, 'core/profiles/' . $profile . '/' . $profile . '.info.yml');
- $this->enableModules(array('module_test', $profile));
+ $this->enableModules(['module_test', $profile]);
drupal_static_reset('system_rebuild_module_data');
$data = system_rebuild_module_data();
$this->assertTrue(isset($data[$profile]->requires[$dependency]));
- $this->moduleInstaller()->install(array($dependency));
+ $this->moduleInstaller()->install([$dependency]);
$this->assertTrue($this->moduleHandler()->moduleExists($dependency));
// Uninstall the profile module "dependency".
- $result = $this->moduleInstaller()->uninstall(array($dependency));
+ $result = $this->moduleInstaller()->uninstall([$dependency]);
$this->assertTrue($result, 'ModuleInstaller::uninstall() returns TRUE.');
$this->assertFalse($this->moduleHandler()->moduleExists($dependency));
$this->assertEqual(drupal_get_installed_schema_version($dependency), SCHEMA_UNINSTALLED, "$dependency module was uninstalled.");
// Verify that the installation profile itself was not uninstalled.
- $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: array();
+ $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: [];
$this->assertTrue(in_array($dependency, $uninstalled_modules), "$dependency module is in the list of uninstalled modules.");
$this->assertFalse(in_array($profile, $uninstalled_modules), 'The installation profile is not in the list of uninstalled modules.');
}
@@ -204,8 +204,8 @@ class ModuleHandlerTest extends KernelTestBase {
/**
* Tests uninstalling a module that has content.
*/
- function testUninstallContentDependency() {
- $this->enableModules(array('module_test', 'entity_test', 'text', 'user', 'help'));
+ public function testUninstallContentDependency() {
+ $this->enableModules(['module_test', 'entity_test', 'text', 'user', 'help']);
$this->assertTrue($this->moduleHandler()->moduleExists('entity_test'), 'Test module is enabled.');
$this->assertTrue($this->moduleHandler()->moduleExists('module_test'), 'Test module is enabled.');
@@ -224,13 +224,13 @@ class ModuleHandlerTest extends KernelTestBase {
drupal_static_reset('system_rebuild_module_data');
// Create an entity so that the modules can not be disabled.
- $entity = EntityTest::create(array('name' => $this->randomString()));
+ $entity = EntityTest::create(['name' => $this->randomString()]);
$entity->save();
// Uninstalling entity_test is not possible when there is content.
try {
$message = 'ModuleInstaller::uninstall() throws ModuleUninstallValidatorException upon uninstalling a module which does not pass validation.';
- $this->moduleInstaller()->uninstall(array('entity_test'));
+ $this->moduleInstaller()->uninstall(['entity_test']);
$this->fail($message);
}
catch (ModuleUninstallValidatorException $e) {
@@ -240,7 +240,7 @@ class ModuleHandlerTest extends KernelTestBase {
// Uninstalling help needs entity_test to be un-installable.
try {
$message = 'ModuleInstaller::uninstall() throws ModuleUninstallValidatorException upon uninstalling a module which does not pass validation.';
- $this->moduleInstaller()->uninstall(array('help'));
+ $this->moduleInstaller()->uninstall(['help']);
$this->fail($message);
}
catch (ModuleUninstallValidatorException $e) {
@@ -250,7 +250,7 @@ class ModuleHandlerTest extends KernelTestBase {
// Deleting the entity.
$entity->delete();
- $result = $this->moduleInstaller()->uninstall(array('help'));
+ $result = $this->moduleInstaller()->uninstall(['help']);
$this->assertTrue($result, 'ModuleInstaller::uninstall() returns TRUE.');
$this->assertEqual(drupal_get_installed_schema_version('entity_test'), SCHEMA_UNINSTALLED, "entity_test module was uninstalled.");
}
@@ -258,7 +258,7 @@ class ModuleHandlerTest extends KernelTestBase {
/**
* Tests whether the correct module metadata is returned.
*/
- function testModuleMetaData() {
+ public function testModuleMetaData() {
// Generate the list of available modules.
$modules = system_rebuild_module_data();
// Check that the mtime field exists for the system module.
@@ -289,7 +289,7 @@ class ModuleHandlerTest extends KernelTestBase {
/**
* Tests whether the correct theme metadata is returned.
*/
- function testThemeMetaData() {
+ public function testThemeMetaData() {
// Generate the list of available themes.
$themes = \Drupal::service('theme_handler')->rebuildThemeData();
// Check that the mtime field exists for the bartik theme.
diff --git a/web/core/modules/system/tests/src/Kernel/Form/FormElementLabelTest.php b/web/core/modules/system/tests/src/Kernel/Form/FormElementLabelTest.php
index f93d461bc..2bc895f8a 100644
--- a/web/core/modules/system/tests/src/Kernel/Form/FormElementLabelTest.php
+++ b/web/core/modules/system/tests/src/Kernel/Form/FormElementLabelTest.php
@@ -31,6 +31,16 @@ class FormElementLabelTest extends KernelTestBase {
$this->render($render_array);
$elements = $this->xpath($css_selector_converter->toXPath('.kitten'));
$this->assertCount(1, $elements);
+
+ // Add label attributes to a form element.
+ $render_array = [
+ '#type' => 'textfield',
+ '#label_attributes' => ['class' => ['meow']],
+ '#title' => 'Kitten sounds',
+ ];
+ $this->render($render_array);
+ $elements = $this->xpath($css_selector_converter->toXPath('label.meow'));
+ $this->assertCount(1, $elements);
}
}
diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php
index 54aaac277..b45a36050 100644
--- a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php
+++ b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateDateFormatTest.php
@@ -37,7 +37,7 @@ class MigrateDateFormatTest extends MigrateDrupal6TestBase {
// Test that we can re-import using the EntityDateFormat destination.
Database::getConnection('default', 'migrate')
->update('variable')
- ->fields(array('value' => serialize('\S\H\O\R\T d/m/Y - H:i')))
+ ->fields(['value' => serialize('\S\H\O\R\T d/m/Y - H:i')])
->condition('name', 'date_format_short')
->execute();
diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateMenuTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateMenuTest.php
index e6ac30c88..51c937789 100644
--- a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateMenuTest.php
+++ b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateMenuTest.php
@@ -36,14 +36,14 @@ EOT;
// Test that we can re-import using the ConfigEntityBase destination.
Database::getConnection('default', 'migrate')
->update('menu_custom')
- ->fields(array('title' => 'Home Navigation'))
+ ->fields(['title' => 'Home Navigation'])
->condition('menu_name', 'navigation')
->execute();
$migration = $this->getMigration('d6_menu');
\Drupal::database()
- ->truncate($migration->getIdMap()->mapTableName())
- ->execute();
+ ->truncate($migration->getIdMap()->mapTableName())
+ ->execute();
$this->executeMigration($migration);
$navigation_menu = Menu::load('navigation');
diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemConfigurationTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemConfigurationTest.php
new file mode 100644
index 000000000..c8e800b61
--- /dev/null
+++ b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemConfigurationTest.php
@@ -0,0 +1,162 @@
+ [
+ 'threshold' => [
+ 'requirements_warning' => 172800,
+ 'requirements_error' => 1209600,
+ ],
+ // logging is not handled by the migration.
+ 'logging' => 1,
+ ],
+ 'system.date' => [
+ // country is not handled by the migration.
+ 'country' => [
+ 'default' => '',
+ ],
+ 'first_day' => 4,
+ // timezone is not handled by the migration.
+ 'timezone' => [
+ 'default' => 'Europe/Paris',
+ 'user' => [
+ 'configurable' => FALSE,
+ // warn is not handled by the migration.
+ 'warn' => FALSE,
+ // default is not handled by the migration.
+ 'default' => 0,
+ ],
+ ],
+ ],
+ 'system.file' => [
+ 'allow_insecure_uploads' => TRUE,
+ // default_scheme is not handled by the migration.
+ 'default_scheme' => 'public',
+ 'path' => [
+ 'temporary' => 'files/temp',
+ ],
+ // temporary_maximum_age is not handled by the migration.
+ 'temporary_maximum_age' => 21600,
+ ],
+ 'system.image.gd' => [
+ 'jpeg_quality' => 75,
+ ],
+ 'system.image' => [
+ 'toolkit' => 'gd',
+ ],
+ 'system.logging' => [
+ 'error_level' => 'some',
+ ],
+ 'system.maintenance' => [
+ 'message' => 'Drupal is currently under maintenance. We should be back shortly. Thank you for your patience.',
+ // langcode is not handled by the migration.
+ 'langcode' => 'en',
+ ],
+ 'system.performance' => [
+ 'cache' => [
+ 'page' => [
+ 'max_age' => 0,
+ ],
+ ],
+ 'css' => [
+ 'preprocess' => FALSE,
+ // gzip is not handled by the migration.
+ 'gzip' => TRUE,
+ ],
+ // fast_404 is not handled by the migration.
+ 'fast_404' => [
+ 'enabled' => TRUE,
+ 'paths' => '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i',
+ 'exclude_paths' => '/\/(?:styles|imagecache)\//',
+ 'html' => '404 Not FoundNot Found
The requested URL "@path" was not found on this server.
',
+ ],
+ 'js' => [
+ 'preprocess' => FALSE,
+ // gzip is not handled by the migration.
+ 'gzip' => TRUE,
+ ],
+ // stale_file_threshold is not handled by the migration.
+ 'stale_file_threshold' => 2592000,
+ 'response' => [
+ 'gzip' => TRUE,
+ ],
+ ],
+ 'system.rss' => [
+ // channel is not handled by the migration.
+ 'channel' => [
+ 'description' => '',
+ ],
+ 'items' => [
+ 'limit' => 10,
+ 'view_mode' => 'title',
+ ],
+ // langcode is not handled by the migration.
+ 'langcode' => 'en',
+ ],
+ 'system.site' => [
+ // uuid is not handled by the migration.
+ 'uuid' => '',
+ 'name' => 'site_name',
+ 'mail' => 'site_mail@example.com',
+ 'slogan' => 'Migrate rocks',
+ 'page' => [
+ '403' => '/user',
+ '404' => '/page-not-found',
+ 'front' => '/node',
+ ],
+ 'admin_compact_mode' => FALSE,
+ 'weight_select_max' => 100,
+ // langcode and default_langcode are not handled by the migration.
+ 'langcode' => 'en',
+ 'default_langcode' => 'en',
+ ],
+ ];
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+
+ $migrations = [
+ 'd6_system_cron',
+ 'd6_system_date',
+ 'd6_system_file',
+ 'system_image_gd',
+ 'system_image',
+ 'system_logging',
+ 'system_maintenance',
+ 'd6_system_performance',
+ 'system_rss',
+ 'system_site',
+ ];
+ $this->executeMigrations($migrations);
+ }
+
+ /**
+ * Tests that all expected configuration gets migrated.
+ */
+ public function testConfigurationMigration() {
+ foreach ($this->expectedConfig as $config_id => $values) {
+ $actual = \Drupal::config($config_id)->get();
+ unset($actual['_core']);
+ $this->assertSame($actual, $values, $config_id . ' matches expected values.');
+ }
+ }
+
+}
diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemCronTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemCronTest.php
deleted file mode 100644
index 0df5df1b3..000000000
--- a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemCronTest.php
+++ /dev/null
@@ -1,31 +0,0 @@
-executeMigration('d6_system_cron');
- }
-
- /**
- * Tests migration of system (cron) variables to system.cron.yml.
- */
- public function testSystemCron() {
- $config = $this->config('system.cron');
- $this->assertIdentical(172800, $config->get('threshold.requirements_warning'));
- $this->assertIdentical(1209600, $config->get('threshold.requirements_error'));
- }
-
-}
diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemDateTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemDateTest.php
deleted file mode 100644
index c1d0c719a..000000000
--- a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemDateTest.php
+++ /dev/null
@@ -1,32 +0,0 @@
-executeMigration('d6_system_date');
- }
-
- /**
- * Tests migration of user variables to system_date.yml.
- */
- public function testSystemDate() {
- $config = $this->config('system.date');
- $this->assertIdentical(4, $config->get('first_day'));
- $this->assertIdentical(FALSE, $config->get('timezone.user.configurable'));
- $this->assertIdentical("Europe/Paris", $config->get('timezone.default'));
- }
-
-}
diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemFileTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemFileTest.php
deleted file mode 100644
index d96909bf7..000000000
--- a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemFileTest.php
+++ /dev/null
@@ -1,31 +0,0 @@
-executeMigration('d6_system_file');
- }
-
- /**
- * Tests migration of system (file) variables to system.file.yml.
- */
- public function testSystemFile() {
- $config = \Drupal::configFactory()->getEditable('system.file');
- $this->assertIdentical('files/temp', $config->get('path.temporary'));
- $this->assertIdentical(TRUE, $config->get('allow_insecure_uploads'));
- }
-
-}
diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemImageGdTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemImageGdTest.php
deleted file mode 100644
index 4a3b5a24d..000000000
--- a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemImageGdTest.php
+++ /dev/null
@@ -1,30 +0,0 @@
-executeMigration('system_image_gd');
- }
-
- /**
- * Tests migration of system (image GD) variables to system.image.gd.yml.
- */
- public function testSystemImageGd() {
- $config = $this->config('system.image.gd');
- $this->assertIdentical(75, $config->get('jpeg_quality'));
- }
-
-}
diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemImageTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemImageTest.php
deleted file mode 100644
index c714ff850..000000000
--- a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemImageTest.php
+++ /dev/null
@@ -1,30 +0,0 @@
-executeMigration('system_image');
- }
-
- /**
- * Tests migration of system (image) variables to system.image.yml.
- */
- public function testSystemImage() {
- $config = $this->config('system.image');
- $this->assertIdentical('gd', $config->get('toolkit'));
- }
-
-}
diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemLoggingTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemLoggingTest.php
deleted file mode 100644
index f56a7f5c1..000000000
--- a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemLoggingTest.php
+++ /dev/null
@@ -1,34 +0,0 @@
-executeMigration('system_logging');
- }
-
- /**
- * Tests migration of system error_level variables to system.logging.yml.
- */
- public function testSystemLogging() {
- $config = $this->config('system.logging');
- $this->assertIdentical('some', $config->get('error_level'));
- $this->assertConfigSchema(\Drupal::service('config.typed'), 'system.logging', $config->get());
- }
-
-}
diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemMaintenanceTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemMaintenanceTest.php
deleted file mode 100644
index 72898027e..000000000
--- a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemMaintenanceTest.php
+++ /dev/null
@@ -1,30 +0,0 @@
-executeMigration('system_maintenance');
- }
-
- /**
- * Tests migration of system (maintenance) variables to system.maintenance.yml.
- */
- public function testSystemMaintenance() {
- $config = $this->config('system.maintenance');
- $this->assertIdentical('Drupal is currently under maintenance. We should be back shortly. Thank you for your patience.', $config->get('message'));
- }
-
-}
diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemPerformanceTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemPerformanceTest.php
deleted file mode 100644
index d341f8389..000000000
--- a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemPerformanceTest.php
+++ /dev/null
@@ -1,32 +0,0 @@
-executeMigration('d6_system_performance');
- }
-
- /**
- * Tests migration of system (Performance) variables to system.performance.yml.
- */
- public function testSystemPerformance() {
- $config = $this->config('system.performance');
- $this->assertIdentical(FALSE, $config->get('css.preprocess'));
- $this->assertIdentical(FALSE, $config->get('js.preprocess'));
- $this->assertIdentical(0, $config->get('cache.page.max_age'));
- }
-
-}
diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemRssTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemRssTest.php
deleted file mode 100644
index a22864eb7..000000000
--- a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemRssTest.php
+++ /dev/null
@@ -1,31 +0,0 @@
-executeMigration('system_rss');
- }
-
- /**
- * Tests migration of system (rss) variables to system.rss.yml.
- */
- public function testSystemRss() {
- $config = $this->config('system.rss');
- $this->assertIdentical(10, $config->get('items.limit'));
- $this->assertIdentical('title', $config->get('items.view_mode'));
- }
-
-}
diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemSiteTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemSiteTest.php
deleted file mode 100644
index a634ddb6f..000000000
--- a/web/core/modules/system/tests/src/Kernel/Migrate/d6/MigrateSystemSiteTest.php
+++ /dev/null
@@ -1,36 +0,0 @@
-executeMigration('system_site');
- }
-
- /**
- * Tests migration of system (site) variables to system.site.yml.
- */
- public function testSystemSite() {
- $config = $this->config('system.site');
- $this->assertIdentical('site_name', $config->get('name'));
- $this->assertIdentical('site_mail@example.com', $config->get('mail'));
- $this->assertIdentical('Migrate rocks', $config->get('slogan'));
- $this->assertIdentical('/user', $config->get('page.403'));
- $this->assertIdentical('/page-not-found', $config->get('page.404'));
- $this->assertIdentical('/node', $config->get('page.front'));
- $this->assertIdentical(FALSE, $config->get('admin_compact_mode'));
- }
-
-}
diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateMenuTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateMenuTest.php
index 987084539..455be2ad1 100644
--- a/web/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateMenuTest.php
+++ b/web/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateMenuTest.php
@@ -51,14 +51,14 @@ class MigrateMenuTest extends MigrateDrupal7TestBase {
// Test that we can re-import using the ConfigEntityBase destination.
Database::getConnection('default', 'migrate')
->update('menu_custom')
- ->fields(array('title' => 'Home Navigation'))
+ ->fields(['title' => 'Home Navigation'])
->condition('menu_name', 'navigation')
->execute();
$migration = $this->getMigration('d7_menu');
\Drupal::database()
- ->truncate($migration->getIdMap()->mapTableName())
- ->execute();
+ ->truncate($migration->getIdMap()->mapTableName())
+ ->execute();
$this->executeMigration($migration);
$navigation_menu = Menu::load('tools');
diff --git a/web/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateSystemConfigurationTest.php b/web/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateSystemConfigurationTest.php
index 59d7b01b8..22e9ba759 100644
--- a/web/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateSystemConfigurationTest.php
+++ b/web/core/modules/system/tests/src/Kernel/Migrate/d7/MigrateSystemConfigurationTest.php
@@ -24,6 +24,7 @@ class MigrateSystemConfigurationTest extends MigrateDrupal7TestBase {
'requirements_warning' => 172800,
'requirements_error' => 1209600,
],
+ 'logging' => 1,
],
'system.date' => [
'country' => [
diff --git a/web/core/modules/system/tests/src/Kernel/PhpStorage/PhpStorageFactoryTest.php b/web/core/modules/system/tests/src/Kernel/PhpStorage/PhpStorageFactoryTest.php
index 8adee9d92..4d1c258b5 100644
--- a/web/core/modules/system/tests/src/Kernel/PhpStorage/PhpStorageFactoryTest.php
+++ b/web/core/modules/system/tests/src/Kernel/PhpStorage/PhpStorageFactoryTest.php
@@ -57,19 +57,19 @@ class PhpStorageFactoryTest extends KernelTestBase {
$this->assertTrue($php instanceof MockPhpStorage, 'A MockPhpStorage instance was returned from overridden settings.');
// Test that the name is used for the bin when it is NULL.
- $this->setSettings('test', array('bin' => NULL));
+ $this->setSettings('test', ['bin' => NULL]);
$php = PhpStorageFactory::get('test');
$this->assertTrue($php instanceof MockPhpStorage, 'An MockPhpStorage instance was returned from overridden settings.');
$this->assertSame('test', $php->getConfigurationValue('bin'), 'Name value was used for bin.');
// Test that a default directory is set if it's empty.
- $this->setSettings('test', array('directory' => NULL));
+ $this->setSettings('test', ['directory' => NULL]);
$php = PhpStorageFactory::get('test');
$this->assertTrue($php instanceof MockPhpStorage, 'An MockPhpStorage instance was returned from overridden settings.');
$this->assertSame(PublicStream::basePath() . '/php', $php->getConfigurationValue('directory'), 'Default file directory was used.');
// Test that a default storage class is set if it's empty.
- $this->setSettings('test', array('class' => NULL));
+ $this->setSettings('test', ['class' => NULL]);
$php = PhpStorageFactory::get('test');
$this->assertTrue($php instanceof MTimeProtectedFileStorage, 'An MTimeProtectedFileStorage instance was returned from overridden settings with no class.');
@@ -79,7 +79,7 @@ class PhpStorageFactoryTest extends KernelTestBase {
$this->assertNotEquals('mock hash salt', $php->getConfigurationValue('secret'), 'The default secret is not used if a secret is set in the overridden settings.');
// Test that a default secret is set if it's empty.
- $this->setSettings('test', array('secret' => NULL));
+ $this->setSettings('test', ['secret' => NULL]);
$php = PhpStorageFactory::get('test');
$this->assertSame('mock hash salt', $php->getConfigurationValue('secret'), 'The default secret is used if one is not set in the overridden settings.');
}
@@ -92,13 +92,13 @@ class PhpStorageFactoryTest extends KernelTestBase {
* @param array $configuration
* An array of configuration to set. Will be merged with default values.
*/
- protected function setSettings($name = 'default', array $configuration = array()) {
- $settings['php_storage'][$name] = $configuration + array(
+ protected function setSettings($name = 'default', array $configuration = []) {
+ $settings['php_storage'][$name] = $configuration + [
'class' => 'Drupal\system\PhpStorage\MockPhpStorage',
'directory' => 'tmp://',
'secret' => $this->randomString(),
'bin' => 'test',
- );
+ ];
$settings['hash_salt'] = 'mock hash salt';
new Settings($settings);
}
diff --git a/web/core/modules/system/tests/src/Kernel/Render/ClassyTest.php b/web/core/modules/system/tests/src/Kernel/Render/ClassyTest.php
index 76cf23ee6..8dbb01e5d 100644
--- a/web/core/modules/system/tests/src/Kernel/Render/ClassyTest.php
+++ b/web/core/modules/system/tests/src/Kernel/Render/ClassyTest.php
@@ -14,7 +14,7 @@ class ClassyTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('system', 'twig_theme_test');
+ public static $modules = ['system', 'twig_theme_test'];
/**
* {@inheritdoc}
@@ -36,12 +36,12 @@ class ClassyTest extends KernelTestBase {
/**
* Test the classy theme.
*/
- function testClassyTheme() {
+ public function testClassyTheme() {
drupal_set_message('An error occurred', 'error');
drupal_set_message('But then something nice happened');
- $messages = array(
+ $messages = [
'#type' => 'status_messages',
- );
+ ];
$this->render($messages);
$this->assertNoText('custom-test-messages-class', 'The custom class attribute value added in the status messages preprocess function is not displayed as page content.');
}
diff --git a/web/core/modules/system/tests/src/Kernel/Scripts/DbCommandBaseTest.php b/web/core/modules/system/tests/src/Kernel/Scripts/DbCommandBaseTest.php
index 1aa2f667a..cb7f5eb7c 100644
--- a/web/core/modules/system/tests/src/Kernel/Scripts/DbCommandBaseTest.php
+++ b/web/core/modules/system/tests/src/Kernel/Scripts/DbCommandBaseTest.php
@@ -8,6 +8,7 @@
namespace Drupal\Tests\system\Kernel\Scripts;
use Drupal\Core\Command\DbCommandBase;
+use Drupal\Core\Database\ConnectionNotDefinedException;
use Drupal\Core\Database\Database;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\Console\Input\InputInterface;
@@ -42,8 +43,6 @@ class DbCommandBaseTest extends KernelTestBase {
/**
* Invalid database names will throw a useful exception.
- *
- * @expectedException \Drupal\Core\Database\ConnectionNotDefinedException
*/
public function testSpecifyDatabaseDoesNotExist() {
$command = new DbCommandBaseTester();
@@ -51,6 +50,7 @@ class DbCommandBaseTest extends KernelTestBase {
$command_tester->execute([
'--database' => 'dne'
]);
+ $this->setExpectedException(ConnectionNotDefinedException::class);
$command->getDatabaseConnection($command_tester->getInput());
}
diff --git a/web/core/modules/system/tests/src/Kernel/Scripts/DbImportCommandTest.php b/web/core/modules/system/tests/src/Kernel/Scripts/DbImportCommandTest.php
index c90d22663..8a292e502 100644
--- a/web/core/modules/system/tests/src/Kernel/Scripts/DbImportCommandTest.php
+++ b/web/core/modules/system/tests/src/Kernel/Scripts/DbImportCommandTest.php
@@ -51,10 +51,10 @@ class DbImportCommandTest extends KernelTestBase {
* @requires extension pdo_sqlite
*/
public function testDbImportCommand() {
- $connection_info = array(
+ $connection_info = [
'driver' => 'sqlite',
'database' => ':memory:',
- );
+ ];
Database::addConnectionInfo($this->databasePrefix, 'default', $connection_info);
$command = new DbImportCommand();
diff --git a/web/core/modules/system/tests/src/Kernel/System/CronQueueTest.php b/web/core/modules/system/tests/src/Kernel/System/CronQueueTest.php
index c51ee5a87..649a2c752 100644
--- a/web/core/modules/system/tests/src/Kernel/System/CronQueueTest.php
+++ b/web/core/modules/system/tests/src/Kernel/System/CronQueueTest.php
@@ -55,7 +55,7 @@ class CronQueueTest extends KernelTestBase {
$queue = $this->container->get('queue')->get('cron_queue_test_exception');
// Enqueue an item for processing.
- $queue->createItem(array($this->randomMachineName() => $this->randomMachineName()));
+ $queue->createItem([$this->randomMachineName() => $this->randomMachineName()]);
// Run cron; the worker for this queue should throw an exception and handle
// it.
diff --git a/web/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php b/web/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php
index 8e6f79e01..ebdac3ce0 100644
--- a/web/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php
+++ b/web/core/modules/system/tests/src/Kernel/System/InfoAlterTest.php
@@ -11,7 +11,7 @@ use Drupal\KernelTests\KernelTestBase;
*/
class InfoAlterTest extends KernelTestBase {
- public static $modules = array('system');
+ public static $modules = ['system'];
/**
* Tests that theme .info.yml data is rebuild after enabling a module.
@@ -20,13 +20,13 @@ class InfoAlterTest extends KernelTestBase {
* hook_system_info_alter() is enabled. Also tests if core *_list() functions
* return freshly altered info.
*/
- function testSystemInfoAlter() {
+ public function testSystemInfoAlter() {
\Drupal::state()->set('module_required_test.hook_system_info_alter', TRUE);
$info = system_rebuild_module_data();
$this->assertFalse(isset($info['node']->info['required']), 'Before the module_required_test is installed the node module is not required.');
// Enable the test module.
- \Drupal::service('module_installer')->install(array('module_required_test'), FALSE);
+ \Drupal::service('module_installer')->install(['module_required_test'], FALSE);
$this->assertTrue(\Drupal::moduleHandler()->moduleExists('module_required_test'), 'Test required module is enabled.');
$info = system_rebuild_module_data();
diff --git a/web/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php b/web/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
index 040cf1a35..b334e6412 100644
--- a/web/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
+++ b/web/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
@@ -29,25 +29,25 @@ class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
*/
public function testSystemTokenRecognition() {
// Generate prefixes and suffixes for the token context.
- $tests = array(
- array('prefix' => 'this is the ', 'suffix' => ' site'),
- array('prefix' => 'this is the', 'suffix' => 'site'),
- array('prefix' => '[', 'suffix' => ']'),
- array('prefix' => '', 'suffix' => ']]]'),
- array('prefix' => '[[[', 'suffix' => ''),
- array('prefix' => ':[:', 'suffix' => '--]'),
- array('prefix' => '-[-', 'suffix' => ':]:'),
- array('prefix' => '[:', 'suffix' => ']'),
- array('prefix' => '[site:', 'suffix' => ':name]'),
- array('prefix' => '[site:', 'suffix' => ']'),
- );
+ $tests = [
+ ['prefix' => 'this is the ', 'suffix' => ' site'],
+ ['prefix' => 'this is the', 'suffix' => 'site'],
+ ['prefix' => '[', 'suffix' => ']'],
+ ['prefix' => '', 'suffix' => ']]]'],
+ ['prefix' => '[[[', 'suffix' => ''],
+ ['prefix' => ':[:', 'suffix' => '--]'],
+ ['prefix' => '-[-', 'suffix' => ':]:'],
+ ['prefix' => '[:', 'suffix' => ']'],
+ ['prefix' => '[site:', 'suffix' => ':name]'],
+ ['prefix' => '[site:', 'suffix' => ']'],
+ ];
// Check if the token is recognized in each of the contexts.
foreach ($tests as $test) {
$input = $test['prefix'] . '[site:name]' . $test['suffix'];
$expected = $test['prefix'] . 'Drupal' . $test['suffix'];
- $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId()));
- $this->assertTrue($output == $expected, format_string('Token recognized in string %string', array('%string' => $input)));
+ $output = $this->tokenService->replace($input, [], ['langcode' => $this->interfaceLanguage->getId()]);
+ $this->assertTrue($output == $expected, format_string('Token recognized in string %string', ['%string' => $input]));
}
// Test token replacement when the string contains no tokens.
@@ -67,12 +67,12 @@ class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
// Replace with the clear parameter, only the valid token should remain.
$target = Html::escape($this->config('system.site')->get('name'));
- $result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->getId(), 'clear' => TRUE));
+ $result = $this->tokenService->replace($source, [], ['langcode' => $this->interfaceLanguage->getId(), 'clear' => TRUE]);
$this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.');
$target .= '[user:name]';
$target .= '[bogus:token]';
- $result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->getId()));
+ $result = $this->tokenService->replace($source, [], ['langcode' => $this->interfaceLanguage->getId()]);
$this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.');
}
@@ -80,10 +80,10 @@ class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
* Tests the generation of all system site information tokens.
*/
public function testSystemSiteTokenReplacement() {
- $url_options = array(
+ $url_options = [
'absolute' => TRUE,
'language' => $this->interfaceLanguage,
- );
+ ];
$slogan = '';
$safe_slogan = Xss::filterAdmin($slogan);
@@ -98,12 +98,12 @@ class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
// Generate and test tokens.
- $tests = array();
+ $tests = [];
$tests['[site:name]'] = Html::escape($config->get('name'));
$tests['[site:slogan]'] = $safe_slogan;
$tests['[site:mail]'] = $config->get('mail');
$tests['[site:url]'] = \Drupal::url('', [], $url_options);
- $tests['[site:url-brief]'] = preg_replace(array('!^https?://!', '!/$!'), '', \Drupal::url('', [], $url_options));
+ $tests['[site:url-brief]'] = preg_replace(['!^https?://!', '!/$!'], '', \Drupal::url('', [], $url_options));
$tests['[site:login-url]'] = \Drupal::url('user.page', [], $url_options);
$base_bubbleable_metadata = new BubbleableMetadata();
@@ -122,7 +122,7 @@ class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
foreach ($tests as $input => $expected) {
$bubbleable_metadata = new BubbleableMetadata();
- $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId()), $bubbleable_metadata);
+ $output = $this->tokenService->replace($input, [], ['langcode' => $this->interfaceLanguage->getId()], $bubbleable_metadata);
$this->assertEqual($output, $expected, new FormattableMarkup('System site information token %token replaced.', ['%token' => $input]));
$this->assertEqual($bubbleable_metadata, $metadata_tests[$input]);
}
@@ -136,21 +136,21 @@ class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
$date = REQUEST_TIME - 3600;
// Generate and test tokens.
- $tests = array();
+ $tests = [];
$date_formatter = \Drupal::service('date.formatter');
$tests['[date:short]'] = $date_formatter->format($date, 'short', '', NULL, $this->interfaceLanguage->getId());
$tests['[date:medium]'] = $date_formatter->format($date, 'medium', '', NULL, $this->interfaceLanguage->getId());
$tests['[date:long]'] = $date_formatter->format($date, 'long', '', NULL, $this->interfaceLanguage->getId());
$tests['[date:custom:m/j/Y]'] = $date_formatter->format($date, 'custom', 'm/j/Y', NULL, $this->interfaceLanguage->getId());
- $tests['[date:since]'] = $date_formatter->formatTimeDiffSince($date, array('langcode' => $this->interfaceLanguage->getId()));
+ $tests['[date:since]'] = $date_formatter->formatTimeDiffSince($date, ['langcode' => $this->interfaceLanguage->getId()]);
$tests['[date:raw]'] = Xss::filter($date);
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
- $output = $this->tokenService->replace($input, array('date' => $date), array('langcode' => $this->interfaceLanguage->getId()));
- $this->assertEqual($output, $expected, format_string('Date token %token replaced.', array('%token' => $input)));
+ $output = $this->tokenService->replace($input, ['date' => $date], ['langcode' => $this->interfaceLanguage->getId()]);
+ $this->assertEqual($output, $expected, format_string('Date token %token replaced.', ['%token' => $input]));
}
}
diff --git a/web/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTestBase.php b/web/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTestBase.php
index 0e2a3fc61..2c8339060 100644
--- a/web/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTestBase.php
+++ b/web/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTestBase.php
@@ -28,12 +28,12 @@ abstract class TokenReplaceKernelTestBase extends EntityKernelTestBase {
*
* @var array
*/
- public static $modules = array('system');
+ public static $modules = ['system'];
protected function setUp() {
parent::setUp();
// Install default system configuration.
- $this->installConfig(array('system'));
+ $this->installConfig(['system']);
\Drupal::service('router.builder')->rebuild();
$this->interfaceLanguage = \Drupal::languageManager()->getCurrentLanguage();
diff --git a/web/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php b/web/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
index eb095a780..d1eb8fb90 100644
--- a/web/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
+++ b/web/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
@@ -94,7 +94,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$this->requestMatcher = $this->getMock('\Symfony\Component\Routing\Matcher\RequestMatcherInterface');
- $config_factory = $this->getConfigFactoryStub(array('system.site' => array('front' => 'test_frontpage')));
+ $config_factory = $this->getConfigFactoryStub(['system.site' => ['front' => 'test_frontpage']]);
$this->pathProcessor = $this->getMock('\Drupal\Core\PathProcessor\InboundPathProcessorInterface');
$this->context = $this->getMock('\Drupal\Core\Routing\RequestContext');
@@ -182,11 +182,11 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
->method('matchRequest')
->will($this->returnCallback(function(Request $request) use ($route_1) {
if ($request->getPathInfo() == '/example') {
- return array(
+ return [
RouteObjectInterface::ROUTE_NAME => 'example',
RouteObjectInterface::ROUTE_OBJECT => $route_1,
- '_raw_variables' => new ParameterBag(array()),
- );
+ '_raw_variables' => new ParameterBag([]),
+ ];
}
}));
@@ -218,18 +218,18 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
->method('matchRequest')
->will($this->returnCallback(function(Request $request) use ($route_1, $route_2) {
if ($request->getPathInfo() == '/example/bar') {
- return array(
+ return [
RouteObjectInterface::ROUTE_NAME => 'example_bar',
RouteObjectInterface::ROUTE_OBJECT => $route_1,
- '_raw_variables' => new ParameterBag(array()),
- );
+ '_raw_variables' => new ParameterBag([]),
+ ];
}
elseif ($request->getPathInfo() == '/example') {
- return array(
+ return [
RouteObjectInterface::ROUTE_NAME => 'example',
RouteObjectInterface::ROUTE_OBJECT => $route_2,
- '_raw_variables' => new ParameterBag(array()),
- );
+ '_raw_variables' => new ParameterBag([]),
+ ];
}
}));
@@ -286,11 +286,11 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
* @see \Drupal\Tests\system\Unit\Breadcrumbs\PathBasedBreadcrumbBuilderTest::testBuildWithException()
*/
public function providerTestBuildWithException() {
- return array(
- array('Drupal\Core\ParamConverter\ParamNotConvertedException', ''),
- array('Symfony\Component\Routing\Exception\MethodNotAllowedException', array()),
- array('Symfony\Component\Routing\Exception\ResourceNotFoundException', ''),
- );
+ return [
+ ['Drupal\Core\ParamConverter\ParamNotConvertedException', ''],
+ ['Symfony\Component\Routing\Exception\MethodNotAllowedException', []],
+ ['Symfony\Component\Routing\Exception\ResourceNotFoundException', ''],
+ ];
}
/**
@@ -310,7 +310,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$this->requestMatcher->expects($this->any())
->method('matchRequest')
- ->will($this->returnValue(array()));
+ ->will($this->returnValue([]));
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
@@ -348,11 +348,11 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
->method('matchRequest')
->will($this->returnCallback(function(Request $request) use ($route_1) {
if ($request->getPathInfo() == '/user/1') {
- return array(
+ return [
RouteObjectInterface::ROUTE_NAME => 'user_page',
RouteObjectInterface::ROUTE_OBJECT => $route_1,
- '_raw_variables' => new ParameterBag(array()),
- );
+ '_raw_variables' => new ParameterBag([]),
+ ];
}
}));
diff --git a/web/core/modules/system/tests/src/Unit/Installer/InstallTranslationFilePatternTest.php b/web/core/modules/system/tests/src/Unit/Installer/InstallTranslationFilePatternTest.php
index fd2b88495..0dd7510e8 100644
--- a/web/core/modules/system/tests/src/Unit/Installer/InstallTranslationFilePatternTest.php
+++ b/web/core/modules/system/tests/src/Unit/Installer/InstallTranslationFilePatternTest.php
@@ -45,11 +45,11 @@ class InstallTranslationFilePatternTest extends UnitTestCase {
* @return array
*/
public function providerValidTranslationFiles() {
- return array(
- array('hu', 'drupal-8.0.0-alpha1.hu.po'),
- array('ta', 'drupal-8.10.10-beta12.ta.po'),
- array('hi', 'drupal-8.0.0.hi.po'),
- );
+ return [
+ ['hu', 'drupal-8.0.0-alpha1.hu.po'],
+ ['ta', 'drupal-8.10.10-beta12.ta.po'],
+ ['hi', 'drupal-8.0.0.hi.po'],
+ ];
}
/**
@@ -64,13 +64,13 @@ class InstallTranslationFilePatternTest extends UnitTestCase {
* @return array
*/
public function providerInvalidTranslationFiles() {
- return array(
- array('hu', 'drupal-alpha1-*-hu.po'),
- array('ta', 'drupal-beta12.ta'),
- array('hi', 'drupal-hi.po'),
- array('de', 'drupal-dummy-de.po'),
- array('hu', 'drupal-10.0.1.alpha1-hu.po'),
- );
+ return [
+ ['hu', 'drupal-alpha1-*-hu.po'],
+ ['ta', 'drupal-beta12.ta'],
+ ['hi', 'drupal-hi.po'],
+ ['de', 'drupal-dummy-de.po'],
+ ['hu', 'drupal-10.0.1.alpha1-hu.po'],
+ ];
}
}
diff --git a/web/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php b/web/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php
index 9f0afc62f..c632a3e55 100644
--- a/web/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php
+++ b/web/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php
@@ -25,20 +25,20 @@ class SystemLocalTasksTest extends LocalTaskIntegrationTestBase {
protected function setUp() {
parent::setUp();
- $this->directoryList = array(
+ $this->directoryList = [
'system' => 'core/modules/system',
- );
+ ];
$this->themeHandler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface');
$theme = new Extension($this->root, 'theme', '/core/themes/bartik', 'bartik.info.yml');
$theme->status = 1;
- $theme->info = array('name' => 'bartik');
+ $theme->info = ['name' => 'bartik'];
$this->themeHandler->expects($this->any())
->method('listInfo')
- ->will($this->returnValue(array(
+ ->will($this->returnValue([
'bartik' => $theme,
- )));
+ ]));
$this->themeHandler->expects($this->any())
->method('hasUi')
->with('bartik')
@@ -59,13 +59,13 @@ class SystemLocalTasksTest extends LocalTaskIntegrationTestBase {
* Provides a list of routes to test.
*/
public function getSystemAdminRoutes() {
- return array(
- array('system.admin_content', array(array('system.admin_content'))),
- array('system.theme_settings_theme', array(
- array('system.themes_page', 'system.theme_settings'),
- array('system.theme_settings_global', 'system.theme_settings_theme:bartik'),
- )),
- );
+ return [
+ ['system.admin_content', [['system.admin_content']]],
+ ['system.theme_settings_theme', [
+ ['system.themes_page', 'system.theme_settings'],
+ ['system.theme_settings_global', 'system.theme_settings_theme:bartik'],
+ ]],
+ ];
}
}
diff --git a/web/core/modules/system/tests/src/Unit/Transliteration/MachineNameControllerTest.php b/web/core/modules/system/tests/src/Unit/Transliteration/MachineNameControllerTest.php
index 90696fda4..689c1782a 100644
--- a/web/core/modules/system/tests/src/Unit/Transliteration/MachineNameControllerTest.php
+++ b/web/core/modules/system/tests/src/Unit/Transliteration/MachineNameControllerTest.php
@@ -53,21 +53,21 @@ class MachineNameControllerTest extends UnitTestCase {
* - The expected content of the JSONresponse.
*/
public function providerTestMachineNameController() {
- $valid_data = array(
- array(array('text' => 'Bob', 'langcode' => 'en'), '"Bob"'),
- array(array('text' => 'Bob', 'langcode' => 'en', 'lowercase' => TRUE), '"bob"'),
- array(array('text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Bob'), '"Alice"'),
- array(array('text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Tom'), '"Bob"'),
- array(array('text' => 'Äwesome', 'langcode' => 'en', 'lowercase' => TRUE), '"awesome"'),
- array(array('text' => 'Äwesome', 'langcode' => 'de', 'lowercase' => TRUE), '"aewesome"'),
+ $valid_data = [
+ [['text' => 'Bob', 'langcode' => 'en'], '"Bob"'],
+ [['text' => 'Bob', 'langcode' => 'en', 'lowercase' => TRUE], '"bob"'],
+ [['text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Bob'], '"Alice"'],
+ [['text' => 'Bob', 'langcode' => 'en', 'replace' => 'Alice', 'replace_pattern' => 'Tom'], '"Bob"'],
+ [['text' => 'Äwesome', 'langcode' => 'en', 'lowercase' => TRUE], '"awesome"'],
+ [['text' => 'Äwesome', 'langcode' => 'de', 'lowercase' => TRUE], '"aewesome"'],
// Tests special characters replacement in the input text.
- array(array('text' => 'B?!"@\/-ob@e', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => '_', 'replace_pattern' => '[^a-z0-9_.]+'), '"b_ob_e"'),
+ [['text' => 'B?!"@\/-ob@e', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => '_', 'replace_pattern' => '[^a-z0-9_.]+'], '"b_ob_e"'],
// Tests @ character in the replace_pattern regex.
- array(array('text' => 'Bob@e\0', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => '_', 'replace_pattern' => '[^a-z0-9_.@]+'), '"bob@e_0"'),
+ [['text' => 'Bob@e\0', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => '_', 'replace_pattern' => '[^a-z0-9_.@]+'], '"bob@e_0"'],
// Tests null byte in the replace_pattern regex.
- array(array('text' => 'Bob', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => 'fail()', 'replace_pattern' => ".*@e\0"), '"bob"'),
- array(array('text' => 'Bob@e', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => 'fail()', 'replace_pattern' => ".*@e\0"), '"fail()"'),
- );
+ [['text' => 'Bob', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => 'fail()', 'replace_pattern' => ".*@e\0"], '"bob"'],
+ [['text' => 'Bob@e', 'langcode' => 'en', 'lowercase' => TRUE, 'replace' => 'fail()', 'replace_pattern' => ".*@e\0"], '"fail()"'],
+ ];
$valid_data = array_map(function ($data) {
if (isset($data[0]['replace_pattern'])) {
diff --git a/web/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine b/web/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine
index 04666dc15..21cf116da 100644
--- a/web/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine
+++ b/web/core/modules/system/tests/themes/engines/nyan_cat/nyan_cat.engine
@@ -21,7 +21,7 @@ function nyan_cat_init(Extension $theme) {
* Implements hook_theme().
*/
function nyan_cat_theme($existing, $type, $theme, $path) {
- $templates = drupal_find_theme_functions($existing, array($theme));
+ $templates = drupal_find_theme_functions($existing, [$theme]);
$templates += drupal_find_theme_templates($existing, '.nyan-cat.html', $path);
return $templates;
}
diff --git a/web/core/modules/system/tests/themes/test_subtheme/test_subtheme.theme b/web/core/modules/system/tests/themes/test_subtheme/test_subtheme.theme
index cd312dbcb..78333a9ab 100644
--- a/web/core/modules/system/tests/themes/test_subtheme/test_subtheme.theme
+++ b/web/core/modules/system/tests/themes/test_subtheme/test_subtheme.theme
@@ -23,7 +23,7 @@ function test_subtheme_views_post_render(ViewExecutable $view, &$output, CachePl
// We append the function name to the title for test to check for.
$view->setTitle($view->getTitle() . ":" . __FUNCTION__);
if ($view->id() == 'test_page_display') {
- $output['#rows'][0]['#title'] = t('%total_rows items found.', array('%total_rows' => $view->total_rows));
+ $output['#rows'][0]['#title'] = t('%total_rows items found.', ['%total_rows' => $view->total_rows]);
}
}
diff --git a/web/core/modules/taxonomy/src/Controller/TaxonomyController.php b/web/core/modules/taxonomy/src/Controller/TaxonomyController.php
index 843cdd7a4..27b1ec0c8 100644
--- a/web/core/modules/taxonomy/src/Controller/TaxonomyController.php
+++ b/web/core/modules/taxonomy/src/Controller/TaxonomyController.php
@@ -22,7 +22,7 @@ class TaxonomyController extends ControllerBase {
* The taxonomy term add form.
*/
public function addForm(VocabularyInterface $taxonomy_vocabulary) {
- $term = $this->entityManager()->getStorage('taxonomy_term')->create(array('vid' => $taxonomy_vocabulary->id()));
+ $term = $this->entityManager()->getStorage('taxonomy_term')->create(['vid' => $taxonomy_vocabulary->id()]);
return $this->entityFormBuilder()->getForm($term);
}
diff --git a/web/core/modules/taxonomy/src/Entity/Term.php b/web/core/modules/taxonomy/src/Entity/Term.php
index 2e41e2d0f..43e62c612 100644
--- a/web/core/modules/taxonomy/src/Entity/Term.php
+++ b/web/core/modules/taxonomy/src/Entity/Term.php
@@ -61,14 +61,14 @@ class Term extends ContentEntityBase implements TermInterface {
parent::postDelete($storage, $entities);
// See if any of the term's children are about to be become orphans.
- $orphans = array();
+ $orphans = [];
foreach (array_keys($entities) as $tid) {
if ($children = $storage->loadChildren($tid)) {
foreach ($children as $child) {
// If the term has multiple parents, we don't delete it.
$parents = $storage->loadParents($child->id());
if (empty($parents)) {
- $orphans[] = $child->id();
+ $orphans[] = $child;
}
}
}
@@ -79,7 +79,7 @@ class Term extends ContentEntityBase implements TermInterface {
$storage->deleteTermHierarchy(array_keys($entities));
if (!empty($orphans)) {
- entity_delete_multiple('taxonomy_term', $orphans);
+ $storage->delete($orphans);
}
}
@@ -92,7 +92,7 @@ class Term extends ContentEntityBase implements TermInterface {
// Only change the parents if a value is set, keep the existing values if
// not.
if (isset($this->parent->target_id)) {
- $storage->deleteTermHierarchy(array($this->id()));
+ $storage->deleteTermHierarchy([$this->id()]);
$storage->updateTermHierarchy($this);
}
}
@@ -116,35 +116,33 @@ class Term extends ContentEntityBase implements TermInterface {
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
- ->setDescription(t('The term name.'))
->setTranslatable(TRUE)
->setRequired(TRUE)
->setSetting('max_length', 255)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'string',
'weight' => -5,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -5,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
$fields['description'] = BaseFieldDefinition::create('text_long')
->setLabel(t('Description'))
- ->setDescription(t('A description of the term.'))
->setTranslatable(TRUE)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'text_default',
'weight' => 0,
- ))
+ ])
->setDisplayConfigurable('view', TRUE)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'text_textfield',
'weight' => 0,
- ))
+ ])
->setDisplayConfigurable('form', TRUE);
$fields['weight'] = BaseFieldDefinition::create('integer')
@@ -234,4 +232,17 @@ class Term extends ContentEntityBase implements TermInterface {
return $this->get('vid')->target_id;
}
+ /**
+ * {@inheritdoc}
+ */
+ protected function getFieldsToSkipFromTranslationChangesCheck() {
+ // @todo the current implementation of the parent field makes it impossible
+ // for ::hasTranslationChanges() to correctly check the field for changes,
+ // so it is currently skipped from the comparision and has to be fixed by
+ // https://www.drupal.org/node/2843060.
+ $fields = parent::getFieldsToSkipFromTranslationChangesCheck();
+ $fields[] = 'parent';
+ return $fields;
+ }
+
}
diff --git a/web/core/modules/taxonomy/src/Entity/Vocabulary.php b/web/core/modules/taxonomy/src/Entity/Vocabulary.php
index a2d7eef8a..b0d1ac13d 100644
--- a/web/core/modules/taxonomy/src/Entity/Vocabulary.php
+++ b/web/core/modules/taxonomy/src/Entity/Vocabulary.php
@@ -140,13 +140,13 @@ class Vocabulary extends ConfigEntityBundleBase implements VocabularyInterface {
return;
}
- $vocabularies = array();
+ $vocabularies = [];
foreach ($entities as $vocabulary) {
$vocabularies[$vocabulary->id()] = $vocabulary->id();
}
// Load all Taxonomy module fields and delete those which use only this
// vocabulary.
- $field_storages = entity_load_multiple_by_properties('field_storage_config', array('module' => 'taxonomy'));
+ $field_storages = entity_load_multiple_by_properties('field_storage_config', ['module' => 'taxonomy']);
foreach ($field_storages as $field_storage) {
$modified_storage = FALSE;
// Term reference fields may reference terms from more than one
diff --git a/web/core/modules/taxonomy/src/Form/OverviewTerms.php b/web/core/modules/taxonomy/src/Form/OverviewTerms.php
index 4c8cee3fb..0ccb24b49 100644
--- a/web/core/modules/taxonomy/src/Form/OverviewTerms.php
+++ b/web/core/modules/taxonomy/src/Form/OverviewTerms.php
@@ -21,6 +21,13 @@ class OverviewTerms extends FormBase {
*/
protected $moduleHandler;
+ /**
+ * The entity manager.
+ *
+ * @var \Drupal\Core\Entity\EntityManagerInterface
+ */
+ protected $entityManager;
+
/**
* The term storage handler.
*
@@ -38,6 +45,7 @@ class OverviewTerms extends FormBase {
*/
public function __construct(ModuleHandlerInterface $module_handler, EntityManagerInterface $entity_manager) {
$this->moduleHandler = $module_handler;
+ $this->entityManager = $entity_manager;
$this->storageController = $entity_manager->getStorage('taxonomy_term');
}
@@ -101,10 +109,10 @@ class OverviewTerms extends FormBase {
$forward_step = 0;
// An array of the terms to be displayed on this page.
- $current_page = array();
+ $current_page = [];
$delta = 0;
- $term_deltas = array();
+ $term_deltas = [];
$tree = $this->storageController->loadTree($taxonomy_vocabulary->id(), 0, NULL, TRUE);
$tree_index = 0;
do {
@@ -199,93 +207,94 @@ class OverviewTerms extends FormBase {
$destination = $this->getDestinationArray();
$row_position = 0;
// Build the actual form.
- $form['terms'] = array(
+ $form['terms'] = [
'#type' => 'table',
- '#header' => array($this->t('Name'), $this->t('Weight'), $this->t('Operations')),
- '#empty' => $this->t('No terms available. Add term.', array(':link' => $this->url('entity.taxonomy_term.add_form', array('taxonomy_vocabulary' => $taxonomy_vocabulary->id())))),
- '#attributes' => array(
+ '#header' => [$this->t('Name'), $this->t('Weight'), $this->t('Operations')],
+ '#empty' => $this->t('No terms available. Add term.', [':link' => $this->url('entity.taxonomy_term.add_form', ['taxonomy_vocabulary' => $taxonomy_vocabulary->id()])]),
+ '#attributes' => [
'id' => 'taxonomy',
- ),
- );
+ ],
+ ];
foreach ($current_page as $key => $term) {
/** @var $term \Drupal\Core\Entity\EntityInterface */
+ $term = $this->entityManager->getTranslationFromContext($term);
$form['terms'][$key]['#term'] = $term;
- $indentation = array();
+ $indentation = [];
if (isset($term->depth) && $term->depth > 0) {
- $indentation = array(
+ $indentation = [
'#theme' => 'indentation',
'#size' => $term->depth,
- );
+ ];
}
- $form['terms'][$key]['term'] = array(
+ $form['terms'][$key]['term'] = [
'#prefix' => !empty($indentation) ? drupal_render($indentation) : '',
'#type' => 'link',
'#title' => $term->getName(),
'#url' => $term->urlInfo(),
- );
+ ];
if ($taxonomy_vocabulary->getHierarchy() != VocabularyInterface::HIERARCHY_MULTIPLE && count($tree) > 1) {
$parent_fields = TRUE;
- $form['terms'][$key]['term']['tid'] = array(
+ $form['terms'][$key]['term']['tid'] = [
'#type' => 'hidden',
'#value' => $term->id(),
- '#attributes' => array(
- 'class' => array('term-id'),
- ),
- );
- $form['terms'][$key]['term']['parent'] = array(
+ '#attributes' => [
+ 'class' => ['term-id'],
+ ],
+ ];
+ $form['terms'][$key]['term']['parent'] = [
'#type' => 'hidden',
// Yes, default_value on a hidden. It needs to be changeable by the
// javascript.
'#default_value' => $term->parents[0],
- '#attributes' => array(
- 'class' => array('term-parent'),
- ),
- );
- $form['terms'][$key]['term']['depth'] = array(
+ '#attributes' => [
+ 'class' => ['term-parent'],
+ ],
+ ];
+ $form['terms'][$key]['term']['depth'] = [
'#type' => 'hidden',
// Same as above, the depth is modified by javascript, so it's a
// default_value.
'#default_value' => $term->depth,
- '#attributes' => array(
- 'class' => array('term-depth'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['term-depth'],
+ ],
+ ];
}
- $form['terms'][$key]['weight'] = array(
+ $form['terms'][$key]['weight'] = [
'#type' => 'weight',
'#delta' => $delta,
'#title' => $this->t('Weight for added term'),
'#title_display' => 'invisible',
'#default_value' => $term->getWeight(),
- '#attributes' => array(
- 'class' => array('term-weight'),
- ),
- );
- $operations = array(
- 'edit' => array(
+ '#attributes' => [
+ 'class' => ['term-weight'],
+ ],
+ ];
+ $operations = [
+ 'edit' => [
'title' => $this->t('Edit'),
'query' => $destination,
'url' => $term->urlInfo('edit-form'),
- ),
- 'delete' => array(
+ ],
+ 'delete' => [
'title' => $this->t('Delete'),
'query' => $destination,
'url' => $term->urlInfo('delete-form'),
- ),
- );
+ ],
+ ];
if ($this->moduleHandler->moduleExists('content_translation') && content_translation_translate_access($term)->isAllowed()) {
- $operations['translate'] = array(
+ $operations['translate'] = [
'title' => $this->t('Translate'),
'query' => $destination,
'url' => $term->urlInfo('drupal:content-translation-overview'),
- );
+ ];
}
- $form['terms'][$key]['operations'] = array(
+ $form['terms'][$key]['operations'] = [
'#type' => 'operations',
'#links' => $operations,
- );
+ ];
- $form['terms'][$key]['#attributes']['class'] = array();
+ $form['terms'][$key]['#attributes']['class'] = [];
if ($parent_fields) {
$form['terms'][$key]['#attributes']['class'][] = 'draggable';
}
@@ -314,44 +323,44 @@ class OverviewTerms extends FormBase {
}
if ($parent_fields) {
- $form['terms']['#tabledrag'][] = array(
+ $form['terms']['#tabledrag'][] = [
'action' => 'match',
'relationship' => 'parent',
'group' => 'term-parent',
'subgroup' => 'term-parent',
'source' => 'term-id',
'hidden' => FALSE,
- );
- $form['terms']['#tabledrag'][] = array(
+ ];
+ $form['terms']['#tabledrag'][] = [
'action' => 'depth',
'relationship' => 'group',
'group' => 'term-depth',
'hidden' => FALSE,
- );
+ ];
$form['terms']['#attached']['library'][] = 'taxonomy/drupal.taxonomy';
$form['terms']['#attached']['drupalSettings']['taxonomy'] = [
'backStep' => $back_step,
'forwardStep' => $forward_step,
];
}
- $form['terms']['#tabledrag'][] = array(
+ $form['terms']['#tabledrag'][] = [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'term-weight',
- );
+ ];
if ($taxonomy_vocabulary->getHierarchy() != VocabularyInterface::HIERARCHY_MULTIPLE && count($tree) > 1) {
- $form['actions'] = array('#type' => 'actions', '#tree' => FALSE);
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions', '#tree' => FALSE];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
'#button_type' => 'primary',
- );
- $form['actions']['reset_alphabetical'] = array(
+ ];
+ $form['actions']['reset_alphabetical'] = [
'#type' => 'submit',
- '#submit' => array('::submitReset'),
+ '#submit' => ['::submitReset'],
'#value' => $this->t('Reset to alphabetical'),
- );
+ ];
}
$form['pager_pager'] = ['#type' => 'pager'];
@@ -378,13 +387,13 @@ class OverviewTerms extends FormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// Sort term order based on weight.
- uasort($form_state->getValue('terms'), array('Drupal\Component\Utility\SortArray', 'sortByWeightElement'));
+ uasort($form_state->getValue('terms'), ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']);
$vocabulary = $form_state->get(['taxonomy', 'vocabulary']);
// Update the current hierarchy type as we go.
$hierarchy = VocabularyInterface::HIERARCHY_DISABLED;
- $changed_terms = array();
+ $changed_terms = [];
$tree = $this->storageController->loadTree($vocabulary->id(), 0, NULL, TRUE);
if (empty($tree)) {
@@ -405,7 +414,7 @@ class OverviewTerms extends FormBase {
}
// Renumber the current page weights and assign any new parents.
- $level_weights = array();
+ $level_weights = [];
foreach ($form_state->getValue('terms') as $tid => $values) {
if (isset($form['terms'][$tid]['#term'])) {
$term = $form['terms'][$tid]['#term'];
diff --git a/web/core/modules/taxonomy/src/Form/TermDeleteForm.php b/web/core/modules/taxonomy/src/Form/TermDeleteForm.php
index 22ab19b06..0e97ff64a 100644
--- a/web/core/modules/taxonomy/src/Form/TermDeleteForm.php
+++ b/web/core/modules/taxonomy/src/Form/TermDeleteForm.php
@@ -38,7 +38,7 @@ class TermDeleteForm extends ContentEntityDeleteForm {
* {@inheritdoc}
*/
protected function getDeletionMessage() {
- return $this->t('Deleted term %name.', array('%name' => $this->entity->label()));
+ return $this->t('Deleted term %name.', ['%name' => $this->entity->label()]);
}
/**
@@ -54,7 +54,7 @@ class TermDeleteForm extends ContentEntityDeleteForm {
$vocabulary = $storage->load($this->entity->bundle());
// @todo Move to storage http://drupal.org/node/1988712
- taxonomy_check_vocabulary_hierarchy($vocabulary, array('tid' => $term->id()));
+ taxonomy_check_vocabulary_hierarchy($vocabulary, ['tid' => $term->id()]);
}
}
diff --git a/web/core/modules/taxonomy/src/Form/VocabularyDeleteForm.php b/web/core/modules/taxonomy/src/Form/VocabularyDeleteForm.php
index bada5d6ea..7c91b7868 100644
--- a/web/core/modules/taxonomy/src/Form/VocabularyDeleteForm.php
+++ b/web/core/modules/taxonomy/src/Form/VocabularyDeleteForm.php
@@ -20,7 +20,7 @@ class VocabularyDeleteForm extends EntityDeleteForm {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to delete the vocabulary %title?', array('%title' => $this->entity->label()));
+ return $this->t('Are you sure you want to delete the vocabulary %title?', ['%title' => $this->entity->label()]);
}
/**
@@ -34,7 +34,7 @@ class VocabularyDeleteForm extends EntityDeleteForm {
* {@inheritdoc}
*/
protected function getDeletionMessage() {
- return $this->t('Deleted vocabulary %name.', array('%name' => $this->entity->label()));
+ return $this->t('Deleted vocabulary %name.', ['%name' => $this->entity->label()]);
}
}
diff --git a/web/core/modules/taxonomy/src/Form/VocabularyResetForm.php b/web/core/modules/taxonomy/src/Form/VocabularyResetForm.php
index fb33e358e..e036ff917 100644
--- a/web/core/modules/taxonomy/src/Form/VocabularyResetForm.php
+++ b/web/core/modules/taxonomy/src/Form/VocabularyResetForm.php
@@ -49,7 +49,7 @@ class VocabularyResetForm extends EntityConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to reset the vocabulary %title to alphabetical order?', array('%title' => $this->entity->label()));
+ return $this->t('Are you sure you want to reset the vocabulary %title to alphabetical order?', ['%title' => $this->entity->label()]);
}
/**
@@ -80,8 +80,8 @@ class VocabularyResetForm extends EntityConfirmFormBase {
parent::submitForm($form, $form_state);
$this->termStorage->resetWeights($this->entity->id());
- drupal_set_message($this->t('Reset vocabulary %name to alphabetical order.', array('%name' => $this->entity->label())));
- $this->logger('taxonomy')->notice('Reset vocabulary %name to alphabetical order.', array('%name' => $this->entity->label()));
+ drupal_set_message($this->t('Reset vocabulary %name to alphabetical order.', ['%name' => $this->entity->label()]));
+ $this->logger('taxonomy')->notice('Reset vocabulary %name to alphabetical order.', ['%name' => $this->entity->label()]);
$form_state->setRedirectUrl($this->getCancelUrl());
}
diff --git a/web/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php b/web/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php
index 7dd4aa2d6..b8f4d14fb 100644
--- a/web/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php
+++ b/web/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php
@@ -53,7 +53,7 @@ class TermSelection extends DefaultSelection {
return parent::getReferenceableEntities($match, $match_operator, $limit);
}
- $options = array();
+ $options = [];
$bundles = $this->entityManager->getBundleInfo('taxonomy_term');
$handler_settings = $this->configuration['handler_settings'];
diff --git a/web/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php b/web/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php
index 11e832579..0d0d9170b 100644
--- a/web/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php
+++ b/web/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php
@@ -25,16 +25,16 @@ class EntityReferenceTaxonomyTermRssFormatter extends EntityReferenceFormatterBa
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$parent_entity = $items->getEntity();
- $elements = array();
+ $elements = [];
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
- $parent_entity->rss_elements[] = array(
+ $parent_entity->rss_elements[] = [
'key' => 'category',
'value' => $entity->label(),
- 'attributes' => array(
- 'domain' => $entity->id() ? \Drupal::url('entity.taxonomy_term.canonical', ['taxonomy_term' => $entity->id()], array('absolute' => TRUE)) : '',
- ),
- );
+ 'attributes' => [
+ 'domain' => $entity->id() ? \Drupal::url('entity.taxonomy_term.canonical', ['taxonomy_term' => $entity->id()], ['absolute' => TRUE]) : '',
+ ],
+ ];
}
return $elements;
diff --git a/web/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php b/web/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php
index 22280ec6c..b66a5cfa8 100644
--- a/web/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php
+++ b/web/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php
@@ -7,7 +7,6 @@ use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Core\Database\DatabaseExceptionWrapper;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\migrate\Exception\RequirementsException;
-use Drupal\migrate\Plugin\Migration;
use Drupal\migrate\Plugin\MigrationDeriverTrait;
use Drupal\migrate_drupal\Plugin\MigrateCckFieldPluginManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -84,8 +83,19 @@ class D7TaxonomyTermDeriver extends DeriverBase implements ContainerDeriverInter
// we'll create a migration just for the node properties.
}
+ $vocabulary_source_plugin = static::getSourcePlugin('d7_taxonomy_vocabulary');
try {
- foreach (static::getSourcePlugin('d7_taxonomy_vocabulary') as $row) {
+ $vocabulary_source_plugin->checkRequirements();
+ }
+ catch (RequirementsException $e) {
+ // If the d7_taxonomy_vocabulary requirements failed, that means we do not
+ // have a Drupal source database configured - there is nothing to
+ // generate.
+ return $this->derivatives;
+ }
+
+ try {
+ foreach ($vocabulary_source_plugin as $row) {
$bundle = $row->getSourceProperty('machine_name');
$values = $base_plugin_definition;
diff --git a/web/core/modules/taxonomy/src/Plugin/migrate/cckfield/TaxonomyTermReference.php b/web/core/modules/taxonomy/src/Plugin/migrate/cckfield/TaxonomyTermReference.php
index c3035c431..2d4e719d3 100644
--- a/web/core/modules/taxonomy/src/Plugin/migrate/cckfield/TaxonomyTermReference.php
+++ b/web/core/modules/taxonomy/src/Plugin/migrate/cckfield/TaxonomyTermReference.php
@@ -20,20 +20,20 @@ class TaxonomyTermReference extends CckFieldPluginBase {
* {@inheritdoc}
*/
public function getFieldFormatterMap() {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
public function processCckFieldValues(MigrationInterface $migration, $field_name, $data) {
- $process = array(
+ $process = [
'plugin' => 'iterator',
'source' => $field_name,
- 'process' => array(
+ 'process' => [
'target_id' => 'tid',
- ),
- );
+ ],
+ ];
$migration->setProcessOfProperty($field_name, $process);
}
diff --git a/web/core/modules/taxonomy/src/Plugin/migrate/source/Term.php b/web/core/modules/taxonomy/src/Plugin/migrate/source/Term.php
index ce468a29d..545d205ba 100644
--- a/web/core/modules/taxonomy/src/Plugin/migrate/source/Term.php
+++ b/web/core/modules/taxonomy/src/Plugin/migrate/source/Term.php
@@ -64,14 +64,14 @@ class Term extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- $fields = array(
+ $fields = [
'tid' => $this->t('The term ID.'),
'vid' => $this->t('Existing term VID'),
'name' => $this->t('The name of the term.'),
'description' => $this->t('The term description.'),
'weight' => $this->t('Weight'),
'parent' => $this->t("The Drupal term IDs of the term's parents."),
- );
+ ];
if ($this->getModuleSchemaVersion('taxonomy') >= 7000) {
$fields['format'] = $this->t('Format of the term description.');
}
@@ -84,7 +84,7 @@ class Term extends DrupalSqlBase {
public function prepareRow(Row $row) {
// Find parents for this row.
$parents = $this->select($this->termHierarchyTable, 'th')
- ->fields('th', array('parent', 'tid'))
+ ->fields('th', ['parent', 'tid'])
->condition('tid', $row->getSourceProperty('tid'))
->execute()
->fetchCol();
diff --git a/web/core/modules/taxonomy/src/Plugin/migrate/source/d6/TermNode.php b/web/core/modules/taxonomy/src/Plugin/migrate/source/d6/TermNode.php
index 2635aaa70..2b1c806f2 100644
--- a/web/core/modules/taxonomy/src/Plugin/migrate/source/d6/TermNode.php
+++ b/web/core/modules/taxonomy/src/Plugin/migrate/source/d6/TermNode.php
@@ -26,10 +26,10 @@ class TermNode extends DrupalSqlBase {
public function query() {
$query = $this->select('term_node', 'tn')
->distinct()
- ->fields('tn', array('nid', 'vid'))
- ->fields('n', array('type'));
+ ->fields('tn', ['nid', 'vid'])
+ ->fields('n', ['type']);
// Because this is an inner join it enforces the current revision.
- $query->innerJoin('term_data', 'td', 'td.tid = tn.tid AND td.vid = :vid', array(':vid' => $this->configuration['vid']));
+ $query->innerJoin('term_data', 'td', 'td.tid = tn.tid AND td.vid = :vid', [':vid' => $this->configuration['vid']]);
$query->innerJoin('node', 'n', static::JOIN);
return $query;
}
@@ -38,11 +38,11 @@ class TermNode extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'nid' => $this->t('The node revision ID.'),
'vid' => $this->t('The node revision ID.'),
'tid' => $this->t('The term ID.'),
- );
+ ];
}
/**
@@ -51,10 +51,10 @@ class TermNode extends DrupalSqlBase {
public function prepareRow(Row $row) {
// Select the terms belonging to the revision selected.
$query = $this->select('term_node', 'tn')
- ->fields('tn', array('tid'))
+ ->fields('tn', ['tid'])
->condition('n.nid', $row->getSourceProperty('nid'));
$query->join('node', 'n', static::JOIN);
- $query->innerJoin('term_data', 'td', 'td.tid = tn.tid AND td.vid = :vid', array(':vid' => $this->configuration['vid']));
+ $query->innerJoin('term_data', 'td', 'td.tid = tn.tid AND td.vid = :vid', [':vid' => $this->configuration['vid']]);
$row->setSourceProperty('tid', $query->execute()->fetchCol());
return parent::prepareRow($row);
}
diff --git a/web/core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php b/web/core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php
index 257303388..714fa9331 100644
--- a/web/core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php
+++ b/web/core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php
@@ -21,7 +21,7 @@ class Vocabulary extends DrupalSqlBase {
*/
public function query() {
$query = $this->select('vocabulary', 'v')
- ->fields('v', array(
+ ->fields('v', [
'vid',
'name',
'description',
@@ -33,7 +33,7 @@ class Vocabulary extends DrupalSqlBase {
'tags',
'module',
'weight',
- ));
+ ]);
return $query;
}
@@ -41,7 +41,7 @@ class Vocabulary extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'vid' => $this->t('The vocabulary ID.'),
'name' => $this->t('The name of the vocabulary.'),
'description' => $this->t('The description of the vocabulary.'),
@@ -54,7 +54,7 @@ class Vocabulary extends DrupalSqlBase {
'weight' => $this->t('The weight of the vocabulary in relation to other vocabularies.'),
'parents' => $this->t("The Drupal term IDs of the term's parents."),
'node_types' => $this->t('The names of the node types the vocabulary may be used with.'),
- );
+ ];
}
/**
@@ -63,7 +63,7 @@ class Vocabulary extends DrupalSqlBase {
public function prepareRow(Row $row) {
// Find node types for this row.
$node_types = $this->select('vocabulary_node_types', 'nt')
- ->fields('nt', array('type', 'vid'))
+ ->fields('nt', ['type', 'vid'])
->condition('vid', $row->getSourceProperty('vid'))
->execute()
->fetchCol();
diff --git a/web/core/modules/taxonomy/src/Plugin/migrate/source/d6/VocabularyPerType.php b/web/core/modules/taxonomy/src/Plugin/migrate/source/d6/VocabularyPerType.php
index ac7a2fe1c..40a0094af 100644
--- a/web/core/modules/taxonomy/src/Plugin/migrate/source/d6/VocabularyPerType.php
+++ b/web/core/modules/taxonomy/src/Plugin/migrate/source/d6/VocabularyPerType.php
@@ -18,7 +18,7 @@ class VocabularyPerType extends Vocabulary {
public function query() {
$query = parent::query();
$query->join('vocabulary_node_types', 'nt', 'v.vid = nt.vid');
- $query->fields('nt', array('type'));
+ $query->fields('nt', ['type']);
return $query;
}
diff --git a/web/core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php b/web/core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php
index e9eb4aa44..31103a8be 100644
--- a/web/core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php
+++ b/web/core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php
@@ -19,7 +19,7 @@ class Vocabulary extends DrupalSqlBase {
*/
public function query() {
$query = $this->select('taxonomy_vocabulary', 'v')
- ->fields('v', array(
+ ->fields('v', [
'vid',
'name',
'description',
@@ -27,7 +27,7 @@ class Vocabulary extends DrupalSqlBase {
'module',
'weight',
'machine_name',
- ));
+ ]);
return $query;
}
@@ -35,7 +35,7 @@ class Vocabulary extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'vid' => $this->t('The vocabulary ID.'),
'name' => $this->t('The name of the vocabulary.'),
'description' => $this->t('The description of the vocabulary.'),
@@ -43,7 +43,7 @@ class Vocabulary extends DrupalSqlBase {
'module' => $this->t('Module responsible for the vocabulary.'),
'weight' => $this->t('The weight of the vocabulary in relation to other vocabularies.'),
'machine_name' => $this->t('Unique machine name of the vocabulary.')
- );
+ ];
}
/**
diff --git a/web/core/modules/taxonomy/src/Plugin/views/argument/IndexTid.php b/web/core/modules/taxonomy/src/Plugin/views/argument/IndexTid.php
index 8ab40e3e6..8d1854533 100644
--- a/web/core/modules/taxonomy/src/Plugin/views/argument/IndexTid.php
+++ b/web/core/modules/taxonomy/src/Plugin/views/argument/IndexTid.php
@@ -15,7 +15,7 @@ use Drupal\views\Plugin\views\argument\ManyToOne;
class IndexTid extends ManyToOne {
public function titleQuery() {
- $titles = array();
+ $titles = [];
$terms = Term::loadMultiple($this->value);
foreach ($terms as $term) {
$titles[] = \Drupal::entityManager()->getTranslationFromContext($term)->label();
diff --git a/web/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php b/web/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php
index 68847168f..6933e7456 100644
--- a/web/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php
+++ b/web/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepth.php
@@ -44,27 +44,27 @@ class IndexTidDepth extends ArgumentPluginBase implements ContainerFactoryPlugin
protected function defineOptions() {
$options = parent::defineOptions();
- $options['depth'] = array('default' => 0);
- $options['break_phrase'] = array('default' => FALSE);
- $options['use_taxonomy_term_path'] = array('default' => FALSE);
+ $options['depth'] = ['default' => 0];
+ $options['break_phrase'] = ['default' => FALSE];
+ $options['use_taxonomy_term_path'] = ['default' => FALSE];
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['depth'] = array(
+ $form['depth'] = [
'#type' => 'weight',
'#title' => $this->t('Depth'),
'#default_value' => $this->options['depth'],
'#description' => $this->t('The depth will match nodes tagged with terms in the hierarchy. For example, if you have the term "fruit" and a child term "apple", with a depth of 1 (or higher) then filtering for the term "fruit" will get nodes that are tagged with "apple" as well as "fruit". If negative, the reverse is true; searching for "apple" will also pick up nodes tagged with "fruit" if depth is -1 (or lower).'),
- );
+ ];
- $form['break_phrase'] = array(
+ $form['break_phrase'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow multiple values'),
'#description' => $this->t('If selected, users can enter multiple values in the form of 1+2+3. Due to the number of JOINs it would require, AND will be treated as OR with this filter.'),
'#default_value' => !empty($this->options['break_phrase']),
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
@@ -74,7 +74,7 @@ class IndexTidDepth extends ArgumentPluginBase implements ContainerFactoryPlugin
*/
protected function defaultActions($which = NULL) {
if ($which) {
- if (in_array($which, array('ignore', 'not found', 'empty', 'default'))) {
+ if (in_array($which, ['ignore', 'not found', 'empty', 'default'])) {
return parent::defaultActions($which);
}
return;
@@ -92,7 +92,7 @@ class IndexTidDepth extends ArgumentPluginBase implements ContainerFactoryPlugin
if (!empty($this->options['break_phrase'])) {
$break = static::breakString($this->argument);
- if ($break->value === array(-1)) {
+ if ($break->value === [-1]) {
return FALSE;
}
@@ -130,7 +130,7 @@ class IndexTidDepth extends ArgumentPluginBase implements ContainerFactoryPlugin
$this->query->addWhere(0, "$this->tableAlias.$this->realField", $subquery, 'IN');
}
- function title() {
+ public function title() {
$term = $this->termStorage->load($this->argument);
if (!empty($term)) {
return $term->getName();
diff --git a/web/core/modules/taxonomy/src/Plugin/views/argument/Taxonomy.php b/web/core/modules/taxonomy/src/Plugin/views/argument/Taxonomy.php
index 38e64c732..25efbf35c 100644
--- a/web/core/modules/taxonomy/src/Plugin/views/argument/Taxonomy.php
+++ b/web/core/modules/taxonomy/src/Plugin/views/argument/Taxonomy.php
@@ -45,7 +45,7 @@ class Taxonomy extends NumericArgument implements ContainerFactoryPluginInterfac
/**
* Override the behavior of title(). Get the title of the node.
*/
- function title() {
+ public function title() {
// There might be no valid argument.
if ($this->argument) {
$term = $this->termStorage->load($this->argument);
diff --git a/web/core/modules/taxonomy/src/Plugin/views/argument/VocabularyVid.php b/web/core/modules/taxonomy/src/Plugin/views/argument/VocabularyVid.php
index 9432c7c73..d2fe82072 100644
--- a/web/core/modules/taxonomy/src/Plugin/views/argument/VocabularyVid.php
+++ b/web/core/modules/taxonomy/src/Plugin/views/argument/VocabularyVid.php
@@ -54,7 +54,7 @@ class VocabularyVid extends NumericArgument {
/**
* Override the behavior of title(). Get the name of the vocabulary.
*/
- function title() {
+ public function title() {
$vocabulary = $this->vocabularyStorage->load($this->argument);
if ($vocabulary) {
return $vocabulary->label();
diff --git a/web/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php b/web/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php
index 513ed7e78..95e5b1ef8 100644
--- a/web/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php
+++ b/web/core/modules/taxonomy/src/Plugin/views/argument_default/Tid.php
@@ -96,11 +96,11 @@ class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
protected function defineOptions() {
$options = parent::defineOptions();
- $options['term_page'] = array('default' => TRUE);
- $options['node'] = array('default' => FALSE);
- $options['anyall'] = array('default' => ',');
- $options['limit'] = array('default' => FALSE);
- $options['vids'] = array('default' => array());
+ $options['term_page'] = ['default' => TRUE];
+ $options['node'] = ['default' => FALSE];
+ $options['anyall'] = ['default' => ','];
+ $options['limit'] = ['default' => FALSE];
+ $options['vids'] = ['default' => []];
return $options;
}
@@ -109,67 +109,67 @@ class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['term_page'] = array(
+ $form['term_page'] = [
'#type' => 'checkbox',
'#title' => $this->t('Load default filter from term page'),
'#default_value' => $this->options['term_page'],
- );
- $form['node'] = array(
+ ];
+ $form['node'] = [
'#type' => 'checkbox',
'#title' => $this->t('Load default filter from node page, that\'s good for related taxonomy blocks'),
'#default_value' => $this->options['node'],
- );
+ ];
- $form['limit'] = array(
+ $form['limit'] = [
'#type' => 'checkbox',
'#title' => $this->t('Limit terms by vocabulary'),
'#default_value' => $this->options['limit'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[argument_default][taxonomy_tid][node]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[argument_default][taxonomy_tid][node]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
- $options = array();
+ $options = [];
$vocabularies = $this->vocabularyStorage->loadMultiple();
foreach ($vocabularies as $voc) {
$options[$voc->id()] = $voc->label();
}
- $form['vids'] = array(
+ $form['vids'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Vocabularies'),
'#options' => $options,
'#default_value' => $this->options['vids'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[argument_default][taxonomy_tid][limit]"]' => array('checked' => TRUE),
- ':input[name="options[argument_default][taxonomy_tid][node]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[argument_default][taxonomy_tid][limit]"]' => ['checked' => TRUE],
+ ':input[name="options[argument_default][taxonomy_tid][node]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
- $form['anyall'] = array(
+ $form['anyall'] = [
'#type' => 'radios',
'#title' => $this->t('Multiple-value handling'),
'#default_value' => $this->options['anyall'],
- '#options' => array(
+ '#options' => [
',' => $this->t('Filter to items that share all terms'),
'+' => $this->t('Filter to items that share any term'),
- ),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[argument_default][taxonomy_tid][node]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ ],
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[argument_default][taxonomy_tid][node]"]' => ['checked' => TRUE],
+ ],
+ ],
+ ];
}
/**
* {@inheritdoc}
*/
- public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = array()) {
+ public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = []) {
// Filter unselected items so we don't unnecessarily store giant arrays.
$options['vids'] = array_filter($options['vids']);
}
@@ -188,7 +188,7 @@ class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
if (!empty($this->options['node'])) {
// Just check, if a node could be detected.
if (($node = $this->routeMatch->getParameter('node')) && $node instanceof NodeInterface) {
- $taxonomy = array();
+ $taxonomy = [];
foreach ($node->getFieldDefinitions() as $field) {
if ($field->getType() == 'entity_reference' && $field->getSetting('target_type') == 'taxonomy_term') {
$taxonomy_terms = $node->{$field->getName()}->referencedEntities();
@@ -199,7 +199,7 @@ class Tid extends ArgumentDefaultPluginBase implements CacheableDependencyInterf
}
}
if (!empty($this->options['limit'])) {
- $tids = array();
+ $tids = [];
// filter by vocabulary
foreach ($taxonomy as $tid => $vocab) {
if (!empty($this->options['vids'][$vocab])) {
diff --git a/web/core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php b/web/core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php
index eb30ff5fe..ac7bad0fa 100644
--- a/web/core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php
+++ b/web/core/modules/taxonomy/src/Plugin/views/argument_validator/TermName.php
@@ -39,7 +39,7 @@ class TermName extends Entity {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['transform'] = array('default' => FALSE);
+ $options['transform'] = ['default' => FALSE];
return $options;
}
@@ -50,11 +50,11 @@ class TermName extends Entity {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
- $form['transform'] = array(
+ $form['transform'] = [
'#type' => 'checkbox',
'#title' => $this->t('Transform dashes in URL to spaces in term name filter values'),
'#default_value' => $this->options['transform'],
- );
+ ];
}
/**
@@ -64,7 +64,7 @@ class TermName extends Entity {
if ($this->options['transform']) {
$argument = str_replace('-', ' ', $argument);
}
- $terms = $this->termStorage->loadByProperties(array('name' => $argument));
+ $terms = $this->termStorage->loadByProperties(['name' => $argument]);
if (!$terms) {
// Returned empty array no terms with the name.
diff --git a/web/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php b/web/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php
index 86a4fce21..e0b9a3221 100644
--- a/web/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php
+++ b/web/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php
@@ -62,19 +62,19 @@ class TaxonomyIndexTid extends PrerenderList {
// @todo: Wouldn't it be possible to use $this->base_table and no if here?
if ($view->storage->get('base_table') == 'node_field_revision') {
- $this->additional_fields['nid'] = array('table' => 'node_field_revision', 'field' => 'nid');
+ $this->additional_fields['nid'] = ['table' => 'node_field_revision', 'field' => 'nid'];
}
else {
- $this->additional_fields['nid'] = array('table' => 'node_field_data', 'field' => 'nid');
+ $this->additional_fields['nid'] = ['table' => 'node_field_data', 'field' => 'nid'];
}
}
protected function defineOptions() {
$options = parent::defineOptions();
- $options['link_to_taxonomy'] = array('default' => TRUE);
- $options['limit'] = array('default' => FALSE);
- $options['vids'] = array('default' => array());
+ $options['link_to_taxonomy'] = ['default' => TRUE];
+ $options['limit'] = ['default' => FALSE];
+ $options['vids'] = ['default' => []];
return $options;
}
@@ -83,36 +83,36 @@ class TaxonomyIndexTid extends PrerenderList {
* Provide "link to term" option.
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['link_to_taxonomy'] = array(
+ $form['link_to_taxonomy'] = [
'#title' => $this->t('Link this field to its term page'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['link_to_taxonomy']),
- );
+ ];
- $form['limit'] = array(
+ $form['limit'] = [
'#type' => 'checkbox',
'#title' => $this->t('Limit terms by vocabulary'),
'#default_value' => $this->options['limit'],
- );
+ ];
- $options = array();
+ $options = [];
$vocabularies = $this->vocabularyStorage->loadMultiple();
foreach ($vocabularies as $voc) {
$options[$voc->id()] = $voc->label();
}
- $form['vids'] = array(
+ $form['vids'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Vocabularies'),
'#options' => $options,
'#default_value' => $this->options['vids'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[limit]"]' => array('checked' => TRUE),
- ),
- ),
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[limit]"]' => ['checked' => TRUE],
+ ],
+ ],
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
@@ -127,7 +127,7 @@ class TaxonomyIndexTid extends PrerenderList {
public function preRender(&$values) {
$vocabularies = $this->vocabularyStorage->loadMultiple();
$this->field_alias = $this->aliases['nid'];
- $nids = array();
+ $nids = [];
foreach ($values as $result) {
if (!empty($result->{$this->aliases['nid']})) {
$nids[] = $result->{$this->aliases['nid']};
@@ -137,7 +137,7 @@ class TaxonomyIndexTid extends PrerenderList {
if ($nids) {
$vocabs = array_filter($this->options['vids']);
if (empty($this->options['limit'])) {
- $vocabs = array();
+ $vocabs = [];
}
$result = \Drupal::entityManager()->getStorage('taxonomy_term')->getNodeTerms($nids, $vocabs);
@@ -157,7 +157,7 @@ class TaxonomyIndexTid extends PrerenderList {
}
}
- function render_item($count, $item) {
+ public function render_item($count, $item) {
return $item['name'];
}
@@ -169,7 +169,7 @@ class TaxonomyIndexTid extends PrerenderList {
}
protected function addSelfTokens(&$tokens, $item) {
- foreach (array('tid', 'name', 'vocabulary_vid', 'vocabulary') as $token) {
+ foreach (['tid', 'name', 'vocabulary_vid', 'vocabulary'] as $token) {
$tokens['{{ ' . $this->options['id'] . '__' . $token . ' }}'] = isset($item[$token]) ? $item[$token] : '';
}
}
diff --git a/web/core/modules/taxonomy/src/Plugin/views/field/TermName.php b/web/core/modules/taxonomy/src/Plugin/views/field/TermName.php
index 20bc3c6f3..0a777e9c1 100644
--- a/web/core/modules/taxonomy/src/Plugin/views/field/TermName.php
+++ b/web/core/modules/taxonomy/src/Plugin/views/field/TermName.php
@@ -3,7 +3,7 @@
namespace Drupal\taxonomy\Plugin\views\field;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\views\Plugin\views\field\Field;
+use Drupal\views\Plugin\views\field\EntityField;
use Drupal\views\ResultRow;
/**
@@ -13,7 +13,7 @@ use Drupal\views\ResultRow;
*
* @ViewsField("term_name")
*/
-class TermName extends Field {
+class TermName extends EntityField {
/**
* {@inheritdoc}
@@ -37,7 +37,7 @@ class TermName extends Field {
*/
protected function defineOptions() {
$options = parent::defineOptions();
- $options['convert_spaces'] = array('default' => FALSE);
+ $options['convert_spaces'] = ['default' => FALSE];
return $options;
}
@@ -45,11 +45,11 @@ class TermName extends Field {
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
- $form['convert_spaces'] = array(
+ $form['convert_spaces'] = [
'#title' => $this->t('Convert spaces in term names to hyphens'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['convert_spaces']),
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
diff --git a/web/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php b/web/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
index d769bb04d..a68c3c8c6 100644
--- a/web/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
+++ b/web/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php
@@ -94,18 +94,18 @@ class TaxonomyIndexTid extends ManyToOne {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['type'] = array('default' => 'textfield');
- $options['limit'] = array('default' => TRUE);
- $options['vid'] = array('default' => '');
- $options['hierarchy'] = array('default' => FALSE);
- $options['error_message'] = array('default' => TRUE);
+ $options['type'] = ['default' => 'textfield'];
+ $options['limit'] = ['default' => TRUE];
+ $options['vid'] = ['default' => ''];
+ $options['hierarchy'] = ['default' => FALSE];
+ $options['error_message'] = ['default' => TRUE];
return $options;
}
public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
$vocabularies = $this->vocabularyStorage->loadMultiple();
- $options = array();
+ $options = [];
foreach ($vocabularies as $voc) {
$options[$voc->id()] = $voc->label();
}
@@ -118,56 +118,56 @@ class TaxonomyIndexTid extends ManyToOne {
}
if (empty($this->definition['vocabulary'])) {
- $form['vid'] = array(
+ $form['vid'] = [
'#type' => 'radios',
'#title' => $this->t('Vocabulary'),
'#options' => $options,
'#description' => $this->t('Select which vocabulary to show terms for in the regular options.'),
'#default_value' => $this->options['vid'],
- );
+ ];
}
}
- $form['type'] = array(
+ $form['type'] = [
'#type' => 'radios',
'#title' => $this->t('Selection type'),
- '#options' => array('select' => $this->t('Dropdown'), 'textfield' => $this->t('Autocomplete')),
+ '#options' => ['select' => $this->t('Dropdown'), 'textfield' => $this->t('Autocomplete')],
'#default_value' => $this->options['type'],
- );
+ ];
- $form['hierarchy'] = array(
+ $form['hierarchy'] = [
'#type' => 'checkbox',
'#title' => $this->t('Show hierarchy in dropdown'),
'#default_value' => !empty($this->options['hierarchy']),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[type]"]' => array('value' => 'select'),
- ),
- ),
- );
+ '#states' => [
+ 'visible' => [
+ ':input[name="options[type]"]' => ['value' => 'select'],
+ ],
+ ],
+ ];
}
protected function valueForm(&$form, FormStateInterface $form_state) {
$vocabulary = $this->vocabularyStorage->load($this->options['vid']);
if (empty($vocabulary) && $this->options['limit']) {
- $form['markup'] = array(
+ $form['markup'] = [
'#markup' => '' . $this->t('An invalid vocabulary is selected. Please change it in the options.') . '
',
- );
+ ];
return;
}
if ($this->options['type'] == 'textfield') {
- $terms = $this->value ? Term::loadMultiple(($this->value)) : array();
- $form['value'] = array(
- '#title' => $this->options['limit'] ? $this->t('Select terms from vocabulary @voc', array('@voc' => $vocabulary->label())) : $this->t('Select terms'),
+ $terms = $this->value ? Term::loadMultiple(($this->value)) : [];
+ $form['value'] = [
+ '#title' => $this->options['limit'] ? $this->t('Select terms from vocabulary @voc', ['@voc' => $vocabulary->label()]) : $this->t('Select terms'),
'#type' => 'textfield',
'#default_value' => EntityAutocomplete::getEntityLabels($terms),
- );
+ ];
if ($this->options['limit']) {
$form['value']['#type'] = 'entity_autocomplete';
$form['value']['#target_type'] = 'taxonomy_term';
- $form['value']['#selection_settings']['target_bundles'] = array($vocabulary->id());
+ $form['value']['#selection_settings']['target_bundles'] = [$vocabulary->id()];
$form['value']['#tags'] = TRUE;
$form['value']['#process_default_value'] = FALSE;
}
@@ -175,18 +175,18 @@ class TaxonomyIndexTid extends ManyToOne {
else {
if (!empty($this->options['hierarchy']) && $this->options['limit']) {
$tree = $this->termStorage->loadTree($vocabulary->id(), 0, NULL, TRUE);
- $options = array();
+ $options = [];
if ($tree) {
foreach ($tree as $term) {
$choice = new \stdClass();
- $choice->option = array($term->id() => str_repeat('-', $term->depth) . \Drupal::entityManager()->getTranslationFromContext($term)->label());
+ $choice->option = [$term->id() => str_repeat('-', $term->depth) . \Drupal::entityManager()->getTranslationFromContext($term)->label()];
$options[] = $choice;
}
}
}
else {
- $options = array();
+ $options = [];
$query = \Drupal::entityQuery('taxonomy_term')
// @todo Sorting on vocabulary properties -
// https://www.drupal.org/node/1821274.
@@ -211,7 +211,7 @@ class TaxonomyIndexTid extends ManyToOne {
$options = $this->reduceValueOptions($options);
if (!empty($this->options['expose']['multiple']) && empty($this->options['expose']['required'])) {
- $default_value = array();
+ $default_value = [];
}
}
@@ -225,7 +225,7 @@ class TaxonomyIndexTid extends ManyToOne {
}
// Due to #1464174 there is a chance that array('') was saved in the admin ui.
// Let's choose a safe default value.
- elseif ($default_value == array('')) {
+ elseif ($default_value == ['']) {
$default_value = 'All';
}
else {
@@ -234,14 +234,14 @@ class TaxonomyIndexTid extends ManyToOne {
}
}
}
- $form['value'] = array(
+ $form['value'] = [
'#type' => 'select',
- '#title' => $this->options['limit'] ? $this->t('Select terms from vocabulary @voc', array('@voc' => $vocabulary->label())) : $this->t('Select terms'),
+ '#title' => $this->options['limit'] ? $this->t('Select terms from vocabulary @voc', ['@voc' => $vocabulary->label()]) : $this->t('Select terms'),
'#multiple' => TRUE,
'#options' => $options,
'#size' => min(9, count($options)),
'#default_value' => $default_value,
- );
+ ];
$user_input = $form_state->getUserInput();
if ($exposed && isset($identifier) && !isset($user_input[$identifier])) {
@@ -265,13 +265,13 @@ class TaxonomyIndexTid extends ManyToOne {
return;
}
- $tids = array();
- if ($values = $form_state->getValue(array('options', 'value'))) {
+ $tids = [];
+ if ($values = $form_state->getValue(['options', 'value'])) {
foreach ($values as $value) {
$tids[] = $value['target_id'];
}
}
- $form_state->setValue(array('options', 'value'), $tids);
+ $form_state->setValue(['options', 'value'], $tids);
}
public function acceptExposedInput($input) {
@@ -348,16 +348,16 @@ class TaxonomyIndexTid extends ManyToOne {
if ($this->options['type'] != 'select') {
unset($form['expose']['reduce']);
}
- $form['error_message'] = array(
+ $form['error_message'] = [
'#type' => 'checkbox',
'#title' => $this->t('Display error message'),
'#default_value' => !empty($this->options['error_message']),
- );
+ ];
}
public function adminSummary() {
// set up $this->valueOptions for the parent summary
- $this->valueOptions = array();
+ $this->valueOptions = [];
if ($this->value) {
$this->value = array_filter($this->value);
diff --git a/web/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php b/web/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php
index a2b8108ff..732f5b150 100644
--- a/web/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php
+++ b/web/core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTidDepth.php
@@ -17,15 +17,15 @@ use Drupal\Core\Form\FormStateInterface;
class TaxonomyIndexTidDepth extends TaxonomyIndexTid {
public function operatorOptions($which = 'title') {
- return array(
+ return [
'or' => $this->t('Is one of'),
- );
+ ];
}
protected function defineOptions() {
$options = parent::defineOptions();
- $options['depth'] = array('default' => 0);
+ $options['depth'] = ['default' => 0];
return $options;
}
@@ -33,12 +33,12 @@ class TaxonomyIndexTidDepth extends TaxonomyIndexTid {
public function buildExtraOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildExtraOptionsForm($form, $form_state);
- $form['depth'] = array(
+ $form['depth'] = [
'#type' => 'weight',
'#title' => $this->t('Depth'),
'#default_value' => $this->options['depth'],
'#description' => $this->t('The depth will match nodes tagged with terms in the hierarchy. For example, if you have the term "fruit" and a child term "apple", with a depth of 1 (or higher) then filtering for the term "fruit" will get nodes that are tagged with "apple" as well as "fruit". If negative, the reverse is true; searching for "apple" will also pick up nodes tagged with "fruit" if depth is -1 (or lower).'),
- );
+ ];
}
public function query() {
diff --git a/web/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php b/web/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php
index b1c72e4bd..13fd056ab 100644
--- a/web/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php
+++ b/web/core/modules/taxonomy/src/Plugin/views/relationship/NodeTermData.php
@@ -74,24 +74,24 @@ class NodeTermData extends RelationshipPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
- $options['vids'] = array('default' => array());
+ $options['vids'] = ['default' => []];
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$vocabularies = $this->vocabularyStorage->loadMultiple();
- $options = array();
+ $options = [];
foreach ($vocabularies as $voc) {
$options[$voc->id()] = $voc->label();
}
- $form['vids'] = array(
+ $form['vids'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Vocabularies'),
'#options' => $options,
'#default_value' => $this->options['vids'],
'#description' => $this->t('Choose which vocabularies you wish to relate. Remember that every term found will create a new record, so this relationship is best used on just one vocabulary that has only one term per node.'),
- );
+ ];
parent::buildOptionsForm($form, $form_state);
}
@@ -134,7 +134,7 @@ class NodeTermData extends RelationshipPluginBase {
$query->condition('td.vid', array_filter($this->options['vids']), 'IN');
$query->addTag('taxonomy_term_access');
$query->fields('td');
- $query->fields('tn', array('nid'));
+ $query->fields('tn', ['nid']);
$def['table formula'] = $query;
}
diff --git a/web/core/modules/taxonomy/src/TermBreadcrumbBuilder.php b/web/core/modules/taxonomy/src/TermBreadcrumbBuilder.php
index 838011d7b..73588d1f0 100644
--- a/web/core/modules/taxonomy/src/TermBreadcrumbBuilder.php
+++ b/web/core/modules/taxonomy/src/TermBreadcrumbBuilder.php
@@ -68,7 +68,7 @@ class TermBreadcrumbBuilder implements BreadcrumbBuilderInterface {
foreach (array_reverse($parents) as $term) {
$term = $this->entityManager->getTranslationFromContext($term);
$breadcrumb->addCacheableDependency($term);
- $breadcrumb->addLink(Link::createFromRoute($term->getName(), 'entity.taxonomy_term.canonical', array('taxonomy_term' => $term->id())));
+ $breadcrumb->addLink(Link::createFromRoute($term->getName(), 'entity.taxonomy_term.canonical', ['taxonomy_term' => $term->id()]));
}
// This breadcrumb builder is based on a route parameter, and hence it
diff --git a/web/core/modules/taxonomy/src/TermForm.php b/web/core/modules/taxonomy/src/TermForm.php
index 1f5635132..6e307ca35 100644
--- a/web/core/modules/taxonomy/src/TermForm.php
+++ b/web/core/modules/taxonomy/src/TermForm.php
@@ -23,12 +23,12 @@ class TermForm extends ContentEntityForm {
$form_state->set(['taxonomy', 'parent'], $parent);
$form_state->set(['taxonomy', 'vocabulary'], $vocabulary);
- $form['relations'] = array(
+ $form['relations'] = [
'#type' => 'details',
'#title' => $this->t('Relations'),
'#open' => $vocabulary->getHierarchy() == VocabularyInterface::HIERARCHY_MULTIPLE,
'#weight' => 10,
- );
+ ];
// \Drupal\taxonomy\TermStorageInterface::loadTree() and
// \Drupal\taxonomy\TermStorageInterface::loadParents() may contain large
@@ -46,9 +46,9 @@ class TermForm extends ContentEntityForm {
$exclude[] = $term->id();
$tree = $taxonomy_storage->loadTree($vocabulary->id());
- $options = array('<' . $this->t('root') . '>');
+ $options = ['<' . $this->t('root') . '>'];
if (empty($parent)) {
- $parent = array(0);
+ $parent = [0];
}
foreach ($tree as $item) {
@@ -57,33 +57,33 @@ class TermForm extends ContentEntityForm {
}
}
- $form['relations']['parent'] = array(
+ $form['relations']['parent'] = [
'#type' => 'select',
'#title' => $this->t('Parent terms'),
'#options' => $options,
'#default_value' => $parent,
'#multiple' => TRUE,
- );
+ ];
}
- $form['relations']['weight'] = array(
+ $form['relations']['weight'] = [
'#type' => 'textfield',
'#title' => $this->t('Weight'),
'#size' => 6,
'#default_value' => $term->getWeight(),
'#description' => $this->t('Terms are displayed in ascending order by weight.'),
'#required' => TRUE,
- );
+ ];
- $form['vid'] = array(
+ $form['vid'] = [
'#type' => 'value',
'#value' => $vocabulary->id(),
- );
+ ];
- $form['tid'] = array(
+ $form['tid'] = [
'#type' => 'value',
'#value' => $term->id(),
- );
+ ];
return parent::form($form, $form_state, $term);
}
@@ -127,21 +127,21 @@ class TermForm extends ContentEntityForm {
$view_link = $term->link($term->getName());
switch ($result) {
case SAVED_NEW:
- drupal_set_message($this->t('Created new term %term.', array('%term' => $view_link)));
- $this->logger('taxonomy')->notice('Created new term %term.', array('%term' => $term->getName(), 'link' => $edit_link));
+ drupal_set_message($this->t('Created new term %term.', ['%term' => $view_link]));
+ $this->logger('taxonomy')->notice('Created new term %term.', ['%term' => $term->getName(), 'link' => $edit_link]);
break;
case SAVED_UPDATED:
- drupal_set_message($this->t('Updated term %term.', array('%term' => $view_link)));
- $this->logger('taxonomy')->notice('Updated term %term.', array('%term' => $term->getName(), 'link' => $edit_link));
+ drupal_set_message($this->t('Updated term %term.', ['%term' => $view_link]));
+ $this->logger('taxonomy')->notice('Updated term %term.', ['%term' => $term->getName(), 'link' => $edit_link]);
break;
}
$current_parent_count = count($form_state->getValue('parent'));
$previous_parent_count = count($form_state->get(['taxonomy', 'parent']));
// Root doesn't count if it's the only parent.
- if ($current_parent_count == 1 && $form_state->hasValue(array('parent', 0))) {
+ if ($current_parent_count == 1 && $form_state->hasValue(['parent', 0])) {
$current_parent_count = 0;
- $form_state->setValue('parent', array());
+ $form_state->setValue('parent', []);
}
// If the number of parents has been reduced to one or none, do a check on the
diff --git a/web/core/modules/taxonomy/src/TermStorage.php b/web/core/modules/taxonomy/src/TermStorage.php
index bc44c226f..0a00c13de 100644
--- a/web/core/modules/taxonomy/src/TermStorage.php
+++ b/web/core/modules/taxonomy/src/TermStorage.php
@@ -15,49 +15,49 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
*
* @var array
*/
- protected $parents = array();
+ protected $parents = [];
/**
* Array of all loaded term ancestry keyed by ancestor term ID.
*
* @var array
*/
- protected $parentsAll = array();
+ protected $parentsAll = [];
/**
* Array of child terms keyed by parent term ID.
*
* @var array
*/
- protected $children = array();
+ protected $children = [];
/**
* Array of term parents keyed by vocabulary ID and child term ID.
*
* @var array
*/
- protected $treeParents = array();
+ protected $treeParents = [];
/**
* Array of term ancestors keyed by vocabulary ID and parent term ID.
*
* @var array
*/
- protected $treeChildren = array();
+ protected $treeChildren = [];
/**
* Array of terms in a tree keyed by vocabulary ID and term ID.
*
* @var array
*/
- protected $treeTerms = array();
+ protected $treeTerms = [];
/**
* Array of loaded trees keyed by a cache id matching tree arguments.
*
* @var array
*/
- protected $trees = array();
+ protected $trees = [];
/**
* {@inheritdoc}
@@ -66,10 +66,10 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
* An array of values to set, keyed by property name. A value for the
* vocabulary ID ('vid') is required.
*/
- public function create(array $values = array()) {
+ public function create(array $values = []) {
// Save new terms with no parents by default.
if (empty($values['parent'])) {
- $values['parent'] = array(0);
+ $values['parent'] = [0];
}
$entity = parent::create($values);
return $entity;
@@ -80,13 +80,13 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
*/
public function resetCache(array $ids = NULL) {
drupal_static_reset('taxonomy_term_count_nodes');
- $this->parents = array();
- $this->parentsAll = array();
- $this->children = array();
- $this->treeChildren = array();
- $this->treeParents = array();
- $this->treeTerms = array();
- $this->trees = array();
+ $this->parents = [];
+ $this->parentsAll = [];
+ $this->children = [];
+ $this->treeChildren = [];
+ $this->treeParents = [];
+ $this->treeTerms = [];
+ $this->trees = [];
parent::resetCache($ids);
}
@@ -104,13 +104,13 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
*/
public function updateTermHierarchy(EntityInterface $term) {
$query = $this->database->insert('taxonomy_term_hierarchy')
- ->fields(array('tid', 'parent'));
+ ->fields(['tid', 'parent']);
foreach ($term->parent as $parent) {
- $query->values(array(
+ $query->values([
'tid' => $term->id(),
'parent' => (int) $parent->target_id,
- ));
+ ]);
}
$query->execute();
}
@@ -120,7 +120,7 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
*/
public function loadParents($tid) {
if (!isset($this->parents[$tid])) {
- $parents = array();
+ $parents = [];
$query = $this->database->select('taxonomy_term_field_data', 't');
$query->join('taxonomy_term_hierarchy', 'h', 'h.parent = t.tid');
$query->addField('t', 'tid');
@@ -142,7 +142,7 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
*/
public function loadAllParents($tid) {
if (!isset($this->parentsAll[$tid])) {
- $parents = array();
+ $parents = [];
if ($term = $this->load($tid)) {
$parents[$term->id()] = $term;
$terms_to_search[] = $term->id();
@@ -169,7 +169,7 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
*/
public function loadChildren($tid, $vid = NULL) {
if (!isset($this->children[$tid])) {
- $children = array();
+ $children = [];
$query = $this->database->select('taxonomy_term_field_data', 't');
$query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
$query->addField('t', 'tid');
@@ -198,15 +198,15 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
// We cache trees, so it's not CPU-intensive to call on a term and its
// children, too.
if (!isset($this->treeChildren[$vid])) {
- $this->treeChildren[$vid] = array();
- $this->treeParents[$vid] = array();
- $this->treeTerms[$vid] = array();
+ $this->treeChildren[$vid] = [];
+ $this->treeParents[$vid] = [];
+ $this->treeTerms[$vid] = [];
$query = $this->database->select('taxonomy_term_field_data', 't');
$query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
$result = $query
->addTag('taxonomy_term_access')
->fields('t')
- ->fields('h', array('parent'))
+ ->fields('h', ['parent'])
->condition('t.vid', $vid)
->condition('t.default_langcode', 1)
->orderBy('t.weight')
@@ -221,17 +221,17 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
// Load full entities, if necessary. The entity controller statically
// caches the results.
- $term_entities = array();
+ $term_entities = [];
if ($load_entities) {
$term_entities = $this->loadMultiple(array_keys($this->treeTerms[$vid]));
}
$max_depth = (!isset($max_depth)) ? count($this->treeChildren[$vid]) : $max_depth;
- $tree = array();
+ $tree = [];
// Keeps track of the parents we have to process, the last entry is used
// for the next processing step.
- $process_parents = array();
+ $process_parents = [];
$process_parents[] = $parent;
// Loops over the parent terms and adds its children to the tree array.
@@ -304,7 +304,7 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
*/
public function resetWeights($vid) {
$this->database->update('taxonomy_term_field_data')
- ->fields(array('weight' => 0))
+ ->fields(['weight' => 0])
->condition('vid', $vid)
->execute();
}
@@ -312,10 +312,10 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
/**
* {@inheritdoc}
*/
- public function getNodeTerms(array $nids, array $vocabs = array(), $langcode = NULL) {
+ public function getNodeTerms(array $nids, array $vocabs = [], $langcode = NULL) {
$query = db_select('taxonomy_term_field_data', 'td');
$query->innerJoin('taxonomy_index', 'tn', 'td.tid = tn.tid');
- $query->fields('td', array('tid'));
+ $query->fields('td', ['tid']);
$query->addField('tn', 'nid', 'node_nid');
$query->orderby('td.weight');
$query->orderby('td.name');
@@ -328,15 +328,15 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
$query->condition('td.langcode', $langcode);
}
- $results = array();
- $all_tids = array();
+ $results = [];
+ $all_tids = [];
foreach ($query->execute() as $term_record) {
$results[$term_record->node_nid][] = $term_record->tid;
$all_tids[] = $term_record->tid;
}
$all_terms = $this->loadMultiple($all_tids);
- $terms = array();
+ $terms = [];
foreach ($results as $nid => $tids) {
foreach ($tids as $tid) {
$terms[$nid][$tid] = $all_terms[$tid];
@@ -361,13 +361,13 @@ class TermStorage extends SqlContentEntityStorage implements TermStorageInterfac
public function __wakeup() {
parent::__wakeup();
// Initialize static caches.
- $this->parents = array();
- $this->parentsAll = array();
- $this->children = array();
- $this->treeChildren = array();
- $this->treeParents = array();
- $this->treeTerms = array();
- $this->trees = array();
+ $this->parents = [];
+ $this->parentsAll = [];
+ $this->children = [];
+ $this->treeChildren = [];
+ $this->treeParents = [];
+ $this->treeTerms = [];
+ $this->trees = [];
}
}
diff --git a/web/core/modules/taxonomy/src/TermStorageInterface.php b/web/core/modules/taxonomy/src/TermStorageInterface.php
index 99167114d..05d8d7f4c 100644
--- a/web/core/modules/taxonomy/src/TermStorageInterface.php
+++ b/web/core/modules/taxonomy/src/TermStorageInterface.php
@@ -116,6 +116,6 @@ interface TermStorageInterface extends ContentEntityStorageInterface {
* @return array
* An array of nids and the term entities they were tagged with.
*/
- public function getNodeTerms(array $nids, array $vocabs = array(), $langcode = NULL);
+ public function getNodeTerms(array $nids, array $vocabs = [], $langcode = NULL);
}
diff --git a/web/core/modules/taxonomy/src/TermStorageSchema.php b/web/core/modules/taxonomy/src/TermStorageSchema.php
index 5534821ef..5bcb088db 100644
--- a/web/core/modules/taxonomy/src/TermStorageSchema.php
+++ b/web/core/modules/taxonomy/src/TermStorageSchema.php
@@ -17,93 +17,93 @@ class TermStorageSchema extends SqlContentEntityStorageSchema {
protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) {
$schema = parent::getEntitySchema($entity_type, $reset = FALSE);
- $schema['taxonomy_term_field_data']['indexes'] += array(
- 'taxonomy_term__tree' => array('vid', 'weight', 'name'),
- 'taxonomy_term__vid_name' => array('vid', 'name'),
- );
+ $schema['taxonomy_term_field_data']['indexes'] += [
+ 'taxonomy_term__tree' => ['vid', 'weight', 'name'],
+ 'taxonomy_term__vid_name' => ['vid', 'name'],
+ ];
- $schema['taxonomy_term_hierarchy'] = array(
+ $schema['taxonomy_term_hierarchy'] = [
'description' => 'Stores the hierarchical relationship between terms.',
- 'fields' => array(
- 'tid' => array(
+ 'fields' => [
+ 'tid' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Primary Key: The {taxonomy_term_data}.tid of the term.',
- ),
- 'parent' => array(
+ ],
+ 'parent' => [
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => "Primary Key: The {taxonomy_term_data}.tid of the term's parent. 0 indicates no parent.",
- ),
- ),
- 'indexes' => array(
- 'parent' => array('parent'),
- ),
- 'foreign keys' => array(
- 'taxonomy_term_data' => array(
+ ],
+ ],
+ 'indexes' => [
+ 'parent' => ['parent'],
+ ],
+ 'foreign keys' => [
+ 'taxonomy_term_data' => [
'table' => 'taxonomy_term_data',
- 'columns' => array('tid' => 'tid'),
- ),
- ),
- 'primary key' => array('tid', 'parent'),
- );
+ 'columns' => ['tid' => 'tid'],
+ ],
+ ],
+ 'primary key' => ['tid', 'parent'],
+ ];
- $schema['taxonomy_index'] = array(
+ $schema['taxonomy_index'] = [
'description' => 'Maintains denormalized information about node/term relationships.',
- 'fields' => array(
- 'nid' => array(
+ 'fields' => [
+ 'nid' => [
'description' => 'The {node}.nid this record tracks.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'tid' => array(
+ ],
+ 'tid' => [
'description' => 'The term ID.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
- ),
- 'status' => array(
+ ],
+ 'status' => [
'description' => 'Boolean indicating whether the node is published (visible to non-administrators).',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
- ),
- 'sticky' => array(
+ ],
+ 'sticky' => [
'description' => 'Boolean indicating whether the node is sticky.',
'type' => 'int',
'not null' => FALSE,
'default' => 0,
'size' => 'tiny',
- ),
- 'created' => array(
+ ],
+ 'created' => [
'description' => 'The Unix timestamp when the node was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
- ),
- ),
- 'primary key' => array('nid', 'tid'),
- 'indexes' => array(
- 'term_node' => array('tid', 'status', 'sticky', 'created'),
- ),
- 'foreign keys' => array(
- 'tracked_node' => array(
+ ],
+ ],
+ 'primary key' => ['nid', 'tid'],
+ 'indexes' => [
+ 'term_node' => ['tid', 'status', 'sticky', 'created'],
+ ],
+ 'foreign keys' => [
+ 'tracked_node' => [
'table' => 'node',
- 'columns' => array('nid' => 'nid'),
- ),
- 'term' => array(
+ 'columns' => ['nid' => 'nid'],
+ ],
+ 'term' => [
'table' => 'taxonomy_term_data',
- 'columns' => array('tid' => 'tid'),
- ),
- ),
- );
+ 'columns' => ['tid' => 'tid'],
+ ],
+ ],
+ ];
return $schema;
}
diff --git a/web/core/modules/taxonomy/src/TermTranslationHandler.php b/web/core/modules/taxonomy/src/TermTranslationHandler.php
index 72539b53d..688c63e38 100644
--- a/web/core/modules/taxonomy/src/TermTranslationHandler.php
+++ b/web/core/modules/taxonomy/src/TermTranslationHandler.php
@@ -16,7 +16,7 @@ class TermTranslationHandler extends ContentTranslationHandler {
*/
public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) {
parent::entityFormAlter($form, $form_state, $entity);
- $form['actions']['submit']['#submit'][] = array($this, 'entityFormSave');
+ $form['actions']['submit']['#submit'][] = [$this, 'entityFormSave'];
}
/**
@@ -26,7 +26,7 @@ class TermTranslationHandler extends ContentTranslationHandler {
*
* @see \Drupal\Core\Entity\EntityForm::build()
*/
- function entityFormSave(array $form, FormStateInterface $form_state) {
+ public function entityFormSave(array $form, FormStateInterface $form_state) {
if ($this->getSourceLangcode($form_state)) {
$entity = $form_state->getFormObject()->getEntity();
// We need a redirect here, otherwise we would get an access denied page,
diff --git a/web/core/modules/taxonomy/src/TermViewBuilder.php b/web/core/modules/taxonomy/src/TermViewBuilder.php
index ca74535ac..6748a4b03 100644
--- a/web/core/modules/taxonomy/src/TermViewBuilder.php
+++ b/web/core/modules/taxonomy/src/TermViewBuilder.php
@@ -16,10 +16,10 @@ class TermViewBuilder extends EntityViewBuilder {
*/
protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
parent::alterBuild($build, $entity, $display, $view_mode);
- $build['#contextual_links']['taxonomy_term'] = array(
- 'route_parameters' => array('taxonomy_term' => $entity->id()),
- 'metadata' => array('changed' => $entity->getChangedTime()),
- );
+ $build['#contextual_links']['taxonomy_term'] = [
+ 'route_parameters' => ['taxonomy_term' => $entity->id()],
+ 'metadata' => ['changed' => $entity->getChangedTime()],
+ ];
}
}
diff --git a/web/core/modules/taxonomy/src/TermViewsData.php b/web/core/modules/taxonomy/src/TermViewsData.php
index 89b2b55ef..5e98bfe9b 100644
--- a/web/core/modules/taxonomy/src/TermViewsData.php
+++ b/web/core/modules/taxonomy/src/TermViewsData.php
@@ -19,13 +19,13 @@ class TermViewsData extends EntityViewsData {
$data['taxonomy_term_field_data']['table']['base']['access query tag'] = 'taxonomy_term_access';
$data['taxonomy_term_field_data']['table']['wizard_id'] = 'taxonomy_term';
- $data['taxonomy_term_field_data']['table']['join'] = array(
+ $data['taxonomy_term_field_data']['table']['join'] = [
// This is provided for the many_to_one argument.
- 'taxonomy_index' => array(
+ 'taxonomy_index' => [
'field' => 'tid',
'left_field' => 'tid',
- ),
- );
+ ],
+ ];
$data['taxonomy_term_field_data']['tid']['help'] = $this->t('The tid of a taxonomy term.');
@@ -39,18 +39,18 @@ class TermViewsData extends EntityViewsData {
$data['taxonomy_term_field_data']['tid']['filter']['hierarchy table'] = 'taxonomy_term_hierarchy';
$data['taxonomy_term_field_data']['tid']['filter']['numeric'] = TRUE;
- $data['taxonomy_term_field_data']['tid_raw'] = array(
+ $data['taxonomy_term_field_data']['tid_raw'] = [
'title' => $this->t('Term ID'),
'help' => $this->t('The tid of a taxonomy term.'),
'real field' => 'tid',
- 'filter' => array(
+ 'filter' => [
'id' => 'numeric',
'allow empty' => TRUE,
- ),
- );
+ ],
+ ];
- $data['taxonomy_term_field_data']['tid_representative'] = array(
- 'relationship' => array(
+ $data['taxonomy_term_field_data']['tid_representative'] = [
+ 'relationship' => [
'title' => $this->t('Representative node'),
'label' => $this->t('Representative node'),
'help' => $this->t('Obtains a single representative node for each term, according to a chosen sort criterion.'),
@@ -62,12 +62,12 @@ class TermViewsData extends EntityViewsData {
'base' => 'node_field_data',
'field' => 'nid',
'relationship' => 'node_field_data:term_node_tid'
- ),
- );
+ ],
+ ];
$data['taxonomy_term_field_data']['vid']['help'] = $this->t('Filter the results of "Taxonomy: Term" to a particular vocabulary.');
unset($data['taxonomy_term_field_data']['vid']['field']);
- unset($data['taxonomy_term_field_data']['vid']['argument']);
+ $data['taxonomy_term_field_data']['vid']['argument']['id'] = 'vocabulary_vid';
unset($data['taxonomy_term_field_data']['vid']['sort']);
$data['taxonomy_term_field_data']['name']['field']['id'] = 'term_name';
@@ -79,114 +79,114 @@ class TermViewsData extends EntityViewsData {
$data['taxonomy_term_field_data']['changed']['title'] = $this->t('Updated date');
$data['taxonomy_term_field_data']['changed']['help'] = $this->t('The date the term was last updated.');
- $data['taxonomy_term_field_data']['changed_fulldate'] = array(
+ $data['taxonomy_term_field_data']['changed_fulldate'] = [
'title' => $this->t('Updated date'),
'help' => $this->t('Date in the form of CCYYMMDD.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_fulldate',
- ),
- );
+ ],
+ ];
- $data['taxonomy_term_field_data']['changed_year_month'] = array(
+ $data['taxonomy_term_field_data']['changed_year_month'] = [
'title' => $this->t('Updated year + month'),
'help' => $this->t('Date in the form of YYYYMM.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_year_month',
- ),
- );
+ ],
+ ];
- $data['taxonomy_term_field_data']['changed_year'] = array(
+ $data['taxonomy_term_field_data']['changed_year'] = [
'title' => $this->t('Updated year'),
'help' => $this->t('Date in the form of YYYY.'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_year',
- ),
- );
+ ],
+ ];
- $data['taxonomy_term_field_data']['changed_month'] = array(
+ $data['taxonomy_term_field_data']['changed_month'] = [
'title' => $this->t('Updated month'),
'help' => $this->t('Date in the form of MM (01 - 12).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_month',
- ),
- );
+ ],
+ ];
- $data['taxonomy_term_field_data']['changed_day'] = array(
+ $data['taxonomy_term_field_data']['changed_day'] = [
'title' => $this->t('Updated day'),
'help' => $this->t('Date in the form of DD (01 - 31).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_day',
- ),
- );
+ ],
+ ];
- $data['taxonomy_term_field_data']['changed_week'] = array(
+ $data['taxonomy_term_field_data']['changed_week'] = [
'title' => $this->t('Updated week'),
'help' => $this->t('Date in the form of WW (01 - 53).'),
- 'argument' => array(
+ 'argument' => [
'field' => 'changed',
'id' => 'date_week',
- ),
- );
+ ],
+ ];
$data['taxonomy_index']['table']['group'] = $this->t('Taxonomy term');
- $data['taxonomy_index']['table']['join'] = array(
- 'taxonomy_term_field_data' => array(
+ $data['taxonomy_index']['table']['join'] = [
+ 'taxonomy_term_field_data' => [
// links directly to taxonomy_term_field_data via tid
'left_field' => 'tid',
'field' => 'tid',
- ),
- 'node_field_data' => array(
+ ],
+ 'node_field_data' => [
// links directly to node via nid
'left_field' => 'nid',
'field' => 'nid',
- ),
- 'taxonomy_term_hierarchy' => array(
+ ],
+ 'taxonomy_term_hierarchy' => [
'left_field' => 'tid',
'field' => 'tid',
- ),
- );
+ ],
+ ];
- $data['taxonomy_index']['nid'] = array(
+ $data['taxonomy_index']['nid'] = [
'title' => $this->t('Content with term'),
'help' => $this->t('Relate all content tagged with a term.'),
- 'relationship' => array(
+ 'relationship' => [
'id' => 'standard',
'base' => 'node',
'base field' => 'nid',
'label' => $this->t('node'),
'skip base' => 'node',
- ),
- );
+ ],
+ ];
// @todo This stuff needs to move to a node field since really it's all
// about nodes.
- $data['taxonomy_index']['tid'] = array(
+ $data['taxonomy_index']['tid'] = [
'group' => $this->t('Content'),
'title' => $this->t('Has taxonomy term ID'),
'help' => $this->t('Display content if it has the selected taxonomy terms.'),
- 'argument' => array(
+ 'argument' => [
'id' => 'taxonomy_index_tid',
'name table' => 'taxonomy_term_field_data',
'name field' => 'name',
'empty field name' => $this->t('Uncategorized'),
'numeric' => TRUE,
'skip base' => 'taxonomy_term_field_data',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'title' => $this->t('Has taxonomy term'),
'id' => 'taxonomy_index_tid',
'hierarchy table' => 'taxonomy_term_hierarchy',
'numeric' => TRUE,
'skip base' => 'taxonomy_term_field_data',
'allow empty' => TRUE,
- ),
- );
+ ],
+ ];
$data['taxonomy_index']['status'] = [
'title' => $this->t('Publish status'),
@@ -226,37 +226,37 @@ class TermViewsData extends EntityViewsData {
$data['taxonomy_term_hierarchy']['table']['group'] = $this->t('Taxonomy term');
$data['taxonomy_term_hierarchy']['table']['provider'] = 'taxonomy';
- $data['taxonomy_term_hierarchy']['table']['join'] = array(
- 'taxonomy_term_hierarchy' => array(
+ $data['taxonomy_term_hierarchy']['table']['join'] = [
+ 'taxonomy_term_hierarchy' => [
// Link to self through left.parent = right.tid (going down in depth).
'left_field' => 'tid',
'field' => 'parent',
- ),
- 'taxonomy_term_field_data' => array(
+ ],
+ 'taxonomy_term_field_data' => [
// Link directly to taxonomy_term_field_data via tid.
'left_field' => 'tid',
'field' => 'tid',
- ),
- );
+ ],
+ ];
- $data['taxonomy_term_hierarchy']['parent'] = array(
+ $data['taxonomy_term_hierarchy']['parent'] = [
'title' => $this->t('Parent term'),
'help' => $this->t('The parent term of the term. This can produce duplicate entries if you are using a vocabulary that allows multiple parents.'),
- 'relationship' => array(
+ 'relationship' => [
'base' => 'taxonomy_term_field_data',
'field' => 'parent',
'label' => $this->t('Parent'),
'id' => 'standard',
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'help' => $this->t('Filter the results of "Taxonomy: Term" by the parent pid.'),
'id' => 'numeric',
- ),
- 'argument' => array(
+ ],
+ 'argument' => [
'help' => $this->t('The parent term of the term.'),
'id' => 'taxonomy',
- ),
- );
+ ],
+ ];
return $data;
}
diff --git a/web/core/modules/taxonomy/src/Tests/RssTest.php b/web/core/modules/taxonomy/src/Tests/RssTest.php
index effd4dd97..81a397d69 100644
--- a/web/core/modules/taxonomy/src/Tests/RssTest.php
+++ b/web/core/modules/taxonomy/src/Tests/RssTest.php
@@ -18,7 +18,7 @@ class RssTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $modules = array('node', 'field_ui', 'views');
+ public static $modules = ['node', 'field_ui', 'views'];
/**
* Vocabulary for testing.
@@ -41,23 +41,23 @@ class RssTest extends TaxonomyTestBase {
$this->vocabulary = $this->createVocabulary();
$this->fieldName = 'taxonomy_' . $this->vocabulary->id();
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->vocabulary->id() => $this->vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'article', $this->fieldName, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_get_form_display('node', 'article', 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'options_select',
- ))
+ ])
->save();
entity_get_display('node', 'article', 'default')
- ->setComponent($this->fieldName, array(
+ ->setComponent($this->fieldName, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
}
@@ -66,26 +66,27 @@ class RssTest extends TaxonomyTestBase {
*
* Create a node and assert that taxonomy terms appear in rss.xml.
*/
- function testTaxonomyRss() {
+ public function testTaxonomyRss() {
// Create two taxonomy terms.
$term1 = $this->createTerm($this->vocabulary);
// RSS display must be added manually.
$this->drupalGet("admin/structure/types/manage/article/display");
- $edit = array(
+ $edit = [
"display_modes_custom[rss]" => '1',
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
// Change the format to 'RSS category'.
$this->drupalGet("admin/structure/types/manage/article/display/rss");
- $edit = array(
+ $edit = [
"fields[taxonomy_" . $this->vocabulary->id() . "][type]" => 'entity_reference_rss_category',
- );
+ "fields[taxonomy_" . $this->vocabulary->id() . "][region]" => 'content',
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
// Post an article.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit[$this->fieldName . '[]'] = $term1->id();
$this->drupalPostForm('node/add/article', $edit, t('Save'));
@@ -94,7 +95,7 @@ class RssTest extends TaxonomyTestBase {
$this->drupalGet('rss.xml');
$test_element = sprintf(
'%s',
- 'domain="' . $term1->url('canonical', array('absolute' => TRUE)) . '"',
+ 'domain="' . $term1->url('canonical', ['absolute' => TRUE]) . '"',
$term1->getName()
);
$this->assertRaw($test_element, 'Term is displayed when viewing the rss feed.');
diff --git a/web/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php b/web/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php
index 306e160b2..7d2ee2b63 100644
--- a/web/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php
+++ b/web/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php
@@ -26,48 +26,48 @@ class TaxonomyImageTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $modules = array('image');
+ public static $modules = ['image'];
protected function setUp() {
parent::setUp();
// Remove access content permission from registered users.
- user_role_revoke_permissions(RoleInterface::AUTHENTICATED_ID, array('access content'));
+ user_role_revoke_permissions(RoleInterface::AUTHENTICATED_ID, ['access content']);
$this->vocabulary = $this->createVocabulary();
// Add a field to the vocabulary.
$entity_type = 'taxonomy_term';
$name = 'field_test';
- FieldStorageConfig::create(array(
+ FieldStorageConfig::create([
'field_name' => $name,
'entity_type' => $entity_type,
'type' => 'image',
- 'settings' => array(
+ 'settings' => [
'uri_scheme' => 'private',
- ),
- ))->save();
+ ],
+ ])->save();
FieldConfig::create([
'field_name' => $name,
'entity_type' => $entity_type,
'bundle' => $this->vocabulary->id(),
- 'settings' => array(),
+ 'settings' => [],
])->save();
entity_get_display($entity_type, $this->vocabulary->id(), 'default')
- ->setComponent($name, array(
+ ->setComponent($name, [
'type' => 'image',
- 'settings' => array(),
- ))
+ 'settings' => [],
+ ])
->save();
entity_get_form_display($entity_type, $this->vocabulary->id(), 'default')
- ->setComponent($name, array(
+ ->setComponent($name, [
'type' => 'image_image',
- 'settings' => array(),
- ))
+ 'settings' => [],
+ ])
->save();
}
public function testTaxonomyImageAccess() {
- $user = $this->drupalCreateUser(array('administer site configuration', 'administer taxonomy', 'access user profiles'));
+ $user = $this->drupalCreateUser(['administer site configuration', 'administer taxonomy', 'access user profiles']);
$this->drupalLogin($user);
// Create a term and upload the image.
@@ -77,12 +77,12 @@ class TaxonomyImageTest extends TaxonomyTestBase {
$edit['files[field_test_0]'] = drupal_realpath($image->uri);
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add', $edit, t('Save'));
$this->drupalPostForm(NULL, ['field_test[0][alt]' => $this->randomMachineName()], t('Save'));
- $terms = entity_load_multiple_by_properties('taxonomy_term', array('name' => $edit['name[0][value]']));
+ $terms = entity_load_multiple_by_properties('taxonomy_term', ['name' => $edit['name[0][value]']]);
$term = reset($terms);
- $this->assertText(t('Created new term @name.', array('@name' => $term->getName())));
+ $this->assertText(t('Created new term @name.', ['@name' => $term->getName()]));
// Create a user that should have access to the file and one that doesn't.
- $access_user = $this->drupalCreateUser(array('access content'));
+ $access_user = $this->drupalCreateUser(['access content']);
$no_access_user = $this->drupalCreateUser();
$image = File::load($term->field_test->target_id);
$this->drupalLogin($access_user);
diff --git a/web/core/modules/taxonomy/src/Tests/TaxonomyQueryAlterTest.php b/web/core/modules/taxonomy/src/Tests/TaxonomyQueryAlterTest.php
index 543910b0b..e5e787bb5 100644
--- a/web/core/modules/taxonomy/src/Tests/TaxonomyQueryAlterTest.php
+++ b/web/core/modules/taxonomy/src/Tests/TaxonomyQueryAlterTest.php
@@ -26,7 +26,7 @@ class TaxonomyQueryAlterTest extends WebTestBase {
public function testTaxonomyQueryAlter() {
// Create a new vocabulary and add a few terms to it.
$vocabulary = $this->createVocabulary();
- $terms = array();
+ $terms = [];
for ($i = 0; $i < 5; $i++) {
$terms[$i] = $this->createTerm($vocabulary);
}
diff --git a/web/core/modules/taxonomy/src/Tests/TaxonomyTermIndentationTest.php b/web/core/modules/taxonomy/src/Tests/TaxonomyTermIndentationTest.php
index 6043d7751..fbf8515ea 100644
--- a/web/core/modules/taxonomy/src/Tests/TaxonomyTermIndentationTest.php
+++ b/web/core/modules/taxonomy/src/Tests/TaxonomyTermIndentationTest.php
@@ -14,7 +14,7 @@ class TaxonomyTermIndentationTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy');
+ public static $modules = ['taxonomy'];
/**
* Vocabulary for testing.
@@ -32,7 +32,7 @@ class TaxonomyTermIndentationTest extends TaxonomyTestBase {
/**
* Tests term indentation.
*/
- function testTermIndentation() {
+ public function testTermIndentation() {
// Create three taxonomy terms.
$term1 = $this->createTerm($this->vocabulary);
$term2 = $this->createTerm($this->vocabulary);
@@ -42,12 +42,12 @@ class TaxonomyTermIndentationTest extends TaxonomyTestBase {
$taxonomy_storage = $this->container->get('entity.manager')->getStorage('taxonomy_term');
// Indent the second term under the first one.
- $edit = array(
+ $edit = [
'terms[tid:' . $term2->id() . ':0][term][tid]' => 2,
'terms[tid:' . $term2->id() . ':0][term][parent]' => 1,
'terms[tid:' . $term2->id() . ':0][term][depth]' => 1,
'terms[tid:' . $term2->id() . ':0][weight]' => 1,
- );
+ ];
// Submit the edited form and check for HTML indentation element presence.
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->get('vid') . '/overview', $edit, t('Save'));
@@ -58,12 +58,12 @@ class TaxonomyTermIndentationTest extends TaxonomyTestBase {
$this->assertEqual(key($parents), 1, 'Term 1 is the term 2\'s parent');
// Move the second term back out to the root level.
- $edit = array(
+ $edit = [
'terms[tid:' . $term2->id() . ':0][term][tid]' => 2,
'terms[tid:' . $term2->id() . ':0][term][parent]' => 0,
'terms[tid:' . $term2->id() . ':0][term][depth]' => 0,
'terms[tid:' . $term2->id() . ':0][weight]' => 1,
- );
+ ];
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->get('vid' ) . '/overview', $edit, t('Save'));
// All terms back at the root level, no indentation should be present.
diff --git a/web/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php b/web/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php
index aa9123798..838a9b02c 100644
--- a/web/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php
+++ b/web/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php
@@ -7,6 +7,9 @@ use Drupal\simpletest\WebTestBase;
/**
* Provides common helper methods for Taxonomy module tests.
+ *
+ * @deprecated Scheduled for removal in Drupal 9.0.0.
+ * Use \Drupal\Tests\taxonomy\Functional\TaxonomyTestBase instead.
*/
abstract class TaxonomyTestBase extends WebTestBase {
@@ -18,7 +21,7 @@ abstract class TaxonomyTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy', 'block');
+ public static $modules = ['taxonomy', 'block'];
/**
* {@inheritdoc}
@@ -29,7 +32,7 @@ abstract class TaxonomyTestBase extends WebTestBase {
// Create Basic page and Article node types.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
}
diff --git a/web/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php b/web/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php
index f04be0013..744ab1b28 100644
--- a/web/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php
+++ b/web/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php
@@ -15,7 +15,7 @@ trait TaxonomyTestTrait {
/**
* Returns a new vocabulary with random properties.
*/
- function createVocabulary() {
+ public function createVocabulary() {
// Create a vocabulary.
$vocabulary = Vocabulary::create([
'name' => $this->randomMachineName(),
@@ -40,7 +40,7 @@ trait TaxonomyTestTrait {
* @return \Drupal\taxonomy\Entity\Term
* The new taxonomy term object.
*/
- function createTerm(Vocabulary $vocabulary, $values = array()) {
+ public function createTerm(Vocabulary $vocabulary, $values = []) {
$filter_formats = filter_formats();
$format = array_pop($filter_formats);
$term = Term::create($values + [
diff --git a/web/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php b/web/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php
index 5ae627035..3607fc6b0 100644
--- a/web/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php
+++ b/web/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php
@@ -79,26 +79,26 @@ trait TaxonomyTranslationTestTrait {
* to FALSE.
*/
protected function setUpTermReferenceField() {
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->vocabulary->id() => $this->vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'article', $this->termFieldName, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$field_storage = FieldStorageConfig::loadByName('node', $this->termFieldName);
$field_storage->setTranslatable(FALSE);
$field_storage->save();
entity_get_form_display('node', 'article', 'default')
- ->setComponent($this->termFieldName, array(
+ ->setComponent($this->termFieldName, [
'type' => 'entity_reference_autocomplete_tags',
- ))
+ ])
->save();
entity_get_display('node', 'article', 'default')
- ->setComponent($this->termFieldName, array(
+ ->setComponent($this->termFieldName, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
}
diff --git a/web/core/modules/taxonomy/src/Tests/TermTest.php b/web/core/modules/taxonomy/src/Tests/TermTest.php
index 311ed6b7c..42f92b1b4 100644
--- a/web/core/modules/taxonomy/src/Tests/TermTest.php
+++ b/web/core/modules/taxonomy/src/Tests/TermTest.php
@@ -52,31 +52,31 @@ class TermTest extends TaxonomyTestBase {
$field_name = 'taxonomy_' . $this->vocabulary->id();
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->vocabulary->id() => $this->vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'article', $field_name, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$this->field = FieldConfig::loadByName('node', 'article', $field_name);
entity_get_form_display('node', 'article', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'options_select',
- ))
+ ])
->save();
entity_get_display('node', 'article', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
}
/**
* Test terms in a single and multiple hierarchy.
*/
- function testTaxonomyTermHierarchy() {
+ public function testTaxonomyTermHierarchy() {
// Create two taxonomy terms.
$term1 = $this->createTerm($this->vocabulary);
$term2 = $this->createTerm($this->vocabulary);
@@ -89,8 +89,8 @@ class TermTest extends TaxonomyTestBase {
$this->assertEqual(0, $vocabulary->getHierarchy(), 'Vocabulary is flat.');
// Edit $term2, setting $term1 as parent.
- $edit = array();
- $edit['parent[]'] = array($term1->id());
+ $edit = [];
+ $edit['parent[]'] = [$term1->id()];
$this->drupalPostForm('taxonomy/term/' . $term2->id() . '/edit', $edit, t('Save'));
// Check the hierarchy.
@@ -107,7 +107,7 @@ class TermTest extends TaxonomyTestBase {
// Create a third term and save this as a parent of term2.
$term3 = $this->createTerm($this->vocabulary);
- $term2->parent = array($term1->id(), $term3->id());
+ $term2->parent = [$term1->id(), $term3->id()];
$term2->save();
$parents = $taxonomy_storage->loadParents($term2->id());
$this->assertTrue(isset($parents[$term1->id()]) && isset($parents[$term3->id()]), 'Both parents found successfully.');
@@ -116,7 +116,7 @@ class TermTest extends TaxonomyTestBase {
/**
* Tests that many terms with parents show on each page
*/
- function testTaxonomyTermChildTerms() {
+ public function testTaxonomyTermChildTerms() {
// Set limit to 10 terms per page. Set variable to 9 so 10 terms appear.
$this->config('taxonomy.settings')->set('terms_per_page_admin', '9')->save();
$term1 = $this->createTerm($this->vocabulary);
@@ -127,7 +127,7 @@ class TermTest extends TaxonomyTestBase {
// Create 40 terms. Terms 1-12 get parent of $term1. All others are
// individual terms.
for ($x = 1; $x <= 40; $x++) {
- $edit = array();
+ $edit = [];
// Set terms in order so we know which terms will be on which pages.
$edit['weight'] = $x;
@@ -149,14 +149,14 @@ class TermTest extends TaxonomyTestBase {
}
// Get Page 2.
- $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', array('query' => array('page' => 1)));
+ $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', ['query' => ['page' => 1]]);
$this->assertText($term1->getName(), 'Parent Term is displayed on Page 2');
for ($x = 1; $x <= 18; $x++) {
$this->assertText($terms_array[$x]->getName(), $terms_array[$x]->getName() . ' found on Page 2');
}
// Get Page 3.
- $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', array('query' => array('page' => 2)));
+ $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', ['query' => ['page' => 2]]);
$this->assertNoText($term1->getName(), 'Parent Term is not displayed on Page 3');
for ($x = 1; $x <= 17; $x++) {
$this->assertNoText($terms_array[$x]->getName(), $terms_array[$x]->getName() . ' not found on Page 3');
@@ -171,13 +171,13 @@ class TermTest extends TaxonomyTestBase {
*
* Save & edit a node and assert that taxonomy terms are saved/loaded properly.
*/
- function testTaxonomyNode() {
+ public function testTaxonomyNode() {
// Create two taxonomy terms.
$term1 = $this->createTerm($this->vocabulary);
$term2 = $this->createTerm($this->vocabulary);
// Post an article.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit['body[0][value]'] = $this->randomMachineName();
$edit[$this->field->getName() . '[]'] = $term1->id();
@@ -190,7 +190,7 @@ class TermTest extends TaxonomyTestBase {
$this->clickLink(t('Edit'));
$this->assertText($term1->getName(), 'Term is displayed when editing the node.');
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$this->assertText($term1->getName(), 'Term is displayed after saving the node with no changes.');
// Edit the node with a different term.
@@ -210,28 +210,28 @@ class TermTest extends TaxonomyTestBase {
/**
* Test term creation with a free-tagging vocabulary from the node form.
*/
- function testNodeTermCreationAndDeletion() {
+ public function testNodeTermCreationAndDeletion() {
// Enable tags in the vocabulary.
$field = $this->field;
entity_get_form_display($field->getTargetEntityTypeId(), $field->getTargetBundle(), 'default')
- ->setComponent($field->getName(), array(
+ ->setComponent($field->getName(), [
'type' => 'entity_reference_autocomplete_tags',
- 'settings' => array(
+ 'settings' => [
'placeholder' => 'Start typing here.',
- ),
- ))
+ ],
+ ])
->save();
// Prefix the terms with a letter to ensure there is no clash in the first
// three letters.
// @see https://www.drupal.org/node/2397691
- $terms = array(
+ $terms = [
'term1' => 'a' . $this->randomMachineName(),
'term2' => 'b' . $this->randomMachineName(),
'term3' => 'c' . $this->randomMachineName() . ', ' . $this->randomMachineName(),
'term4' => 'd' . $this->randomMachineName(),
- );
+ ];
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit['body[0][value]'] = $this->randomMachineName();
// Insert the terms in a comma separated list. Vocabulary 1 is a
@@ -255,10 +255,10 @@ class TermTest extends TaxonomyTestBase {
// Save, creating the terms.
$this->drupalPostForm('node/add/article', $edit, t('Save'));
- $this->assertText(t('@type @title has been created.', array('@type' => t('Article'), '@title' => $edit['title[0][value]'])), 'The node was created successfully.');
+ $this->assertText(t('@type @title has been created.', ['@type' => t('Article'), '@title' => $edit['title[0][value]']]), 'The node was created successfully.');
// Verify that the creation message contains a link to a node.
- $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'node/'));
+ $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'node/']);
$this->assert(isset($view_link), 'The message area contains a link to a node');
foreach ($terms as $term) {
@@ -266,7 +266,7 @@ class TermTest extends TaxonomyTestBase {
}
// Get the created terms.
- $term_objects = array();
+ $term_objects = [];
foreach ($terms as $key => $term) {
$term_objects[$key] = taxonomy_term_load_multiple_by_name($term);
$term_objects[$key] = reset($term_objects[$key]);
@@ -288,30 +288,30 @@ class TermTest extends TaxonomyTestBase {
// Delete term 2 from the term delete page.
$this->drupalGet('taxonomy/term/' . $term_objects['term2']->id() . '/delete');
- $this->drupalPostForm(NULL, array(), t('Delete'));
- $term_names = array($term_objects['term3']->getName(), $term_objects['term4']->getName());
+ $this->drupalPostForm(NULL, [], t('Delete'));
+ $term_names = [$term_objects['term3']->getName(), $term_objects['term4']->getName()];
$this->drupalGet('node/' . $node->id());
foreach ($term_names as $term_name) {
- $this->assertText($term_name, format_string('The term %name appears on the node page after two terms, %deleted1 and %deleted2, were deleted.', array('%name' => $term_name, '%deleted1' => $term_objects['term1']->getName(), '%deleted2' => $term_objects['term2']->getName())));
+ $this->assertText($term_name, format_string('The term %name appears on the node page after two terms, %deleted1 and %deleted2, were deleted.', ['%name' => $term_name, '%deleted1' => $term_objects['term1']->getName(), '%deleted2' => $term_objects['term2']->getName()]));
}
- $this->assertNoText($term_objects['term1']->getName(), format_string('The deleted term %name does not appear on the node page.', array('%name' => $term_objects['term1']->getName())));
- $this->assertNoText($term_objects['term2']->getName(), format_string('The deleted term %name does not appear on the node page.', array('%name' => $term_objects['term2']->getName())));
+ $this->assertNoText($term_objects['term1']->getName(), format_string('The deleted term %name does not appear on the node page.', ['%name' => $term_objects['term1']->getName()]));
+ $this->assertNoText($term_objects['term2']->getName(), format_string('The deleted term %name does not appear on the node page.', ['%name' => $term_objects['term2']->getName()]));
}
/**
* Save, edit and delete a term using the user interface.
*/
- function testTermInterface() {
- \Drupal::service('module_installer')->install(array('views'));
- $edit = array(
+ public function testTermInterface() {
+ \Drupal::service('module_installer')->install(['views']);
+ $edit = [
'name[0][value]' => $this->randomMachineName(12),
'description[0][value]' => $this->randomMachineName(100),
- );
+ ];
// Explicitly set the parents field to 'root', to ensure that
// TermForm::save() handles the invalid term ID correctly.
- $edit['parent[]'] = array(0);
+ $edit['parent[]'] = [0];
// Create the term to edit.
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add', $edit, t('Save'));
@@ -328,10 +328,10 @@ class TermTest extends TaxonomyTestBase {
$this->assertRaw($edit['name[0][value]'], 'The randomly generated term name is present.');
$this->assertText($edit['description[0][value]'], 'The randomly generated term description is present.');
- $edit = array(
+ $edit = [
'name[0][value]' => $this->randomMachineName(14),
'description[0][value]' => $this->randomMachineName(102),
- );
+ ];
// Edit the term.
$this->drupalPostForm('taxonomy/term/' . $term->id() . '/edit', $edit, t('Save'));
@@ -380,7 +380,7 @@ class TermTest extends TaxonomyTestBase {
/**
* Save, edit and delete a term using the user interface.
*/
- function testTermReorder() {
+ public function testTermReorder() {
$this->createTerm($this->vocabulary);
$this->createTerm($this->vocabulary);
$this->createTerm($this->vocabulary);
@@ -398,7 +398,7 @@ class TermTest extends TaxonomyTestBase {
// "tid:1:0[depth]", and "tid:1:0[weight]". Change the order to term2,
// term3, term1 by setting weight property, make term3 a child of term2 by
// setting the parent and depth properties, and update all hidden fields.
- $edit = array(
+ $edit = [
'terms[tid:' . $term2->id() . ':0][term][tid]' => $term2->id(),
'terms[tid:' . $term2->id() . ':0][term][parent]' => 0,
'terms[tid:' . $term2->id() . ':0][term][depth]' => 0,
@@ -411,18 +411,18 @@ class TermTest extends TaxonomyTestBase {
'terms[tid:' . $term1->id() . ':0][term][parent]' => 0,
'terms[tid:' . $term1->id() . ':0][term][depth]' => 0,
'terms[tid:' . $term1->id() . ':0][weight]' => 2,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Save'));
$taxonomy_storage->resetCache();
$terms = $taxonomy_storage->loadTree($this->vocabulary->id());
$this->assertEqual($terms[0]->tid, $term2->id(), 'Term 2 was moved above term 1.');
- $this->assertEqual($terms[1]->parents, array($term2->id()), 'Term 3 was made a child of term 2.');
+ $this->assertEqual($terms[1]->parents, [$term2->id()], 'Term 3 was made a child of term 2.');
$this->assertEqual($terms[2]->tid, $term1->id(), 'Term 1 was moved below term 2.');
- $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', array(), t('Reset to alphabetical'));
+ $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', [], t('Reset to alphabetical'));
// Submit confirmation form.
- $this->drupalPostForm(NULL, array(), t('Reset to alphabetical'));
+ $this->drupalPostForm(NULL, [], t('Reset to alphabetical'));
// Ensure form redirected back to overview.
$this->assertUrl('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
@@ -431,22 +431,22 @@ class TermTest extends TaxonomyTestBase {
$this->assertEqual($terms[0]->id(), $term1->id(), 'Term 1 was moved to back above term 2.');
$this->assertEqual($terms[1]->id(), $term2->id(), 'Term 2 was moved to back below term 1.');
$this->assertEqual($terms[2]->id(), $term3->id(), 'Term 3 is still below term 2.');
- $this->assertEqual($terms[2]->parents, array($term2->id()), 'Term 3 is still a child of term 2.');
+ $this->assertEqual($terms[2]->parents, [$term2->id()], 'Term 3 is still a child of term 2.');
}
/**
* Test saving a term with multiple parents through the UI.
*/
- function testTermMultipleParentsInterface() {
+ public function testTermMultipleParentsInterface() {
// Add a new term to the vocabulary so that we can have multiple parents.
$parent = $this->createTerm($this->vocabulary);
// Add a new term with multiple parents.
- $edit = array(
+ $edit = [
'name[0][value]' => $this->randomMachineName(12),
'description[0][value]' => $this->randomMachineName(100),
- 'parent[]' => array(0, $parent->id()),
- );
+ 'parent[]' => [0, $parent->id()],
+ ];
// Save the new term.
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add', $edit, t('Save'));
@@ -466,7 +466,7 @@ class TermTest extends TaxonomyTestBase {
/**
* Test taxonomy_term_load_multiple_by_name().
*/
- function testTaxonomyGetTermByName() {
+ public function testTaxonomyGetTermByName() {
$term = $this->createTerm($this->vocabulary);
// Load the term with the exact name.
@@ -526,18 +526,18 @@ class TermTest extends TaxonomyTestBase {
/**
* Tests that editing and saving a node with no changes works correctly.
*/
- function testReSavingTags() {
+ public function testReSavingTags() {
// Enable tags in the vocabulary.
$field = $this->field;
entity_get_form_display($field->getTargetEntityTypeId(), $field->getTargetBundle(), 'default')
- ->setComponent($field->getName(), array(
+ ->setComponent($field->getName(), [
'type' => 'entity_reference_autocomplete_tags',
- ))
+ ])
->save();
// Create a term and a node using it.
$term = $this->createTerm($this->vocabulary);
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$edit[$this->field->getName() . '[target_id]'] = $term->getName();
@@ -547,7 +547,7 @@ class TermTest extends TaxonomyTestBase {
// changes.
$this->clickLink(t('Edit'));
$this->assertRaw($term->getName(), 'Term is displayed when editing the node.');
- $this->drupalPostForm(NULL, array(), t('Save'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$this->assertRaw($term->getName(), 'Term is displayed after saving the node with no changes.');
}
diff --git a/web/core/modules/taxonomy/src/Tests/TermTranslationTest.php b/web/core/modules/taxonomy/src/Tests/TermTranslationTest.php
index 91b13b158..ccb16f611 100644
--- a/web/core/modules/taxonomy/src/Tests/TermTranslationTest.php
+++ b/web/core/modules/taxonomy/src/Tests/TermTranslationTest.php
@@ -20,23 +20,23 @@ class TermTranslationTest extends TaxonomyTestBase {
*
* @var array
*/
- protected $termTranslationMap = array(
+ protected $termTranslationMap = [
'one' => 'translatedOne',
'two' => 'translatedTwo',
'three' => 'translatedThree',
- );
+ ];
/**
* Created terms.
*
* @var \Drupal\taxonomy\Entity\Term[]
*/
- protected $terms = array();
+ protected $terms = [];
/**
* {@inheritdoc}
*/
- public static $modules = array('taxonomy', 'language', 'content_translation');
+ public static $modules = ['taxonomy', 'language', 'content_translation'];
/**
* {@inheritdoc}
@@ -55,7 +55,7 @@ class TermTranslationTest extends TaxonomyTestBase {
*/
public function testTranslatedBreadcrumbs() {
// Ensure non-translated breadcrumb is correct.
- $breadcrumb = array(Url::fromRoute('')->toString() => 'Home');
+ $breadcrumb = [Url::fromRoute('')->toString() => 'Home'];
foreach ($this->terms as $term) {
$breadcrumb[$term->url()] = $term->label();
}
@@ -69,7 +69,7 @@ class TermTranslationTest extends TaxonomyTestBase {
$languages = \Drupal::languageManager()->getLanguages();
// Construct the expected translated breadcrumb.
- $breadcrumb = array(Url::fromRoute('', [], ['language' => $languages[$this->translateToLangcode]])->toString() => 'Home');
+ $breadcrumb = [Url::fromRoute('', [], ['language' => $languages[$this->translateToLangcode]])->toString() => 'Home'];
foreach ($this->terms as $term) {
$translated = $term->getTranslation($this->translateToLangcode);
$url = $translated->url('canonical', ['language' => $languages[$this->translateToLangcode]]);
@@ -87,14 +87,14 @@ class TermTranslationTest extends TaxonomyTestBase {
/**
* Test translation of terms are showed in the node.
*/
- protected function testTermsTranslation() {
+ public function testTermsTranslation() {
// Set the display of the term reference field on the article content type
// to "Check boxes/radio buttons".
entity_get_form_display('node', 'article', 'default')
- ->setComponent($this->termFieldName, array(
+ ->setComponent($this->termFieldName, [
'type' => 'options_buttons',
- ))
+ ])
->save();
$this->drupalLogin($this->drupalCreateUser(['create article content']));
@@ -118,15 +118,15 @@ class TermTranslationTest extends TaxonomyTestBase {
$parent_vid = 0;
foreach ($this->termTranslationMap as $name => $translation) {
- $term = $this->createTerm($this->vocabulary, array(
+ $term = $this->createTerm($this->vocabulary, [
'name' => $name,
'langcode' => $this->baseLangcode,
'parent' => $parent_vid,
- ));
+ ]);
- $term->addTranslation($this->translateToLangcode, array(
+ $term->addTranslation($this->translateToLangcode, [
'name' => $translation,
- ));
+ ]);
$term->save();
// Each term is nested under the last.
diff --git a/web/core/modules/taxonomy/src/Tests/TermTranslationUITest.php b/web/core/modules/taxonomy/src/Tests/TermTranslationUITest.php
index fa9652def..43edc156b 100644
--- a/web/core/modules/taxonomy/src/Tests/TermTranslationUITest.php
+++ b/web/core/modules/taxonomy/src/Tests/TermTranslationUITest.php
@@ -25,7 +25,7 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
*
* @var array
*/
- public static $modules = array('language', 'content_translation', 'taxonomy');
+ public static $modules = ['language', 'content_translation', 'taxonomy'];
protected function setUp() {
$this->entityTypeId = 'taxonomy_term';
@@ -54,14 +54,14 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
* {@inheritdoc}
*/
protected function getTranslatorPermissions() {
- return array_merge(parent::getTranslatorPermissions(), array('administer taxonomy'));
+ return array_merge(parent::getTranslatorPermissions(), ['administer taxonomy']);
}
/**
* {@inheritdoc}
*/
protected function getNewEntityValues($langcode) {
- return array('name' => $this->randomMachineName()) + parent::getNewEntityValues($langcode);
+ return ['name' => $this->randomMachineName()] + parent::getNewEntityValues($langcode);
}
/**
@@ -73,7 +73,7 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
// To be able to post values for the configurable base fields (name,
// description) have to be suffixed with [0][value].
foreach ($edit as $property => $value) {
- foreach (array('name', 'description') as $key) {
+ foreach (['name', 'description'] as $key) {
if ($property == $key) {
$edit[$key . '[0][value]'] = $value;
unset($edit[$property]);
@@ -91,7 +91,7 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
// Make sure that no row was inserted for taxonomy vocabularies which do
// not have translations enabled.
- $rows = db_query('SELECT tid, count(tid) AS count FROM {taxonomy_term_field_data} WHERE vid <> :vid GROUP BY tid', array(':vid' => $this->bundle))->fetchAll();
+ $rows = db_query('SELECT tid, count(tid) AS count FROM {taxonomy_term_field_data} WHERE vid <> :vid GROUP BY tid', [':vid' => $this->bundle])->fetchAll();
foreach ($rows as $row) {
$this->assertTrue($row->count < 2, 'Term does not have translations.');
}
@@ -100,12 +100,12 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
/**
* Tests translate link on vocabulary term list.
*/
- function testTranslateLinkVocabularyAdminPage() {
+ public function testTranslateLinkVocabularyAdminPage() {
$this->drupalLogin($this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), ['access administration pages', 'administer taxonomy'])));
- $values = array(
+ $values = [
'name' => $this->randomMachineName(),
- );
+ ];
$translatable_tid = $this->createEntity($values, $this->langcodes[0], $this->vocabulary->id());
// Create an untranslatable vocabulary.
@@ -118,9 +118,9 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
]);
$untranslatable_vocabulary->save();
- $values = array(
+ $values = [
'name' => $this->randomMachineName(),
- );
+ ];
$untranslatable_tid = $this->createEntity($values, $this->langcodes[0], $untranslatable_vocabulary->id());
// Verify translation links.
@@ -148,14 +148,14 @@ class TermTranslationUITest extends ContentTranslationUITestBase {
foreach ($this->langcodes as $langcode) {
// We only want to test the title for non-english translations.
if ($langcode != 'en') {
- $options = array('language' => $languages[$langcode]);
+ $options = ['language' => $languages[$langcode]];
$url = $entity->urlInfo('edit-form', $options);
$this->drupalGet($url);
- $title = t('@title [%language translation]', array(
+ $title = t('@title [%language translation]', [
'@title' => $entity->getTranslation($langcode)->label(),
'%language' => $languages[$langcode]->getName(),
- ));
+ ]);
$this->assertRaw($title);
}
}
diff --git a/web/core/modules/taxonomy/src/Tests/ThemeTest.php b/web/core/modules/taxonomy/src/Tests/ThemeTest.php
index 54ad6e462..8995c809a 100644
--- a/web/core/modules/taxonomy/src/Tests/ThemeTest.php
+++ b/web/core/modules/taxonomy/src/Tests/ThemeTest.php
@@ -14,7 +14,7 @@ class ThemeTest extends TaxonomyTestBase {
// Make sure we are using distinct default and administrative themes for
// the duration of these tests.
- \Drupal::service('theme_handler')->install(array('bartik', 'seven'));
+ \Drupal::service('theme_handler')->install(['bartik', 'seven']);
$this->config('system.theme')
->set('default', 'bartik')
->set('admin', 'seven')
@@ -22,14 +22,14 @@ class ThemeTest extends TaxonomyTestBase {
// Create and log in as a user who has permission to add and edit taxonomy
// terms and view the administrative theme.
- $admin_user = $this->drupalCreateUser(array('administer taxonomy', 'view the administration theme'));
+ $admin_user = $this->drupalCreateUser(['administer taxonomy', 'view the administration theme']);
$this->drupalLogin($admin_user);
}
/**
* Test the theme used when adding, viewing and editing taxonomy terms.
*/
- function testTaxonomyTermThemes() {
+ public function testTaxonomyTermThemes() {
// Adding a term to a vocabulary is considered an administrative action and
// should use the administrative theme.
$vocabulary = $this->createVocabulary();
diff --git a/web/core/modules/taxonomy/src/Tests/Views/RelationshipNodeTermDataTest.php b/web/core/modules/taxonomy/src/Tests/Views/RelationshipNodeTermDataTest.php
index c38c45c39..4f0cb4859 100644
--- a/web/core/modules/taxonomy/src/Tests/Views/RelationshipNodeTermDataTest.php
+++ b/web/core/modules/taxonomy/src/Tests/Views/RelationshipNodeTermDataTest.php
@@ -16,9 +16,9 @@ class RelationshipNodeTermDataTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $testViews = array('test_taxonomy_node_term_data');
+ public static $testViews = ['test_taxonomy_node_term_data'];
- function testViewsHandlerRelationshipNodeTermData() {
+ public function testViewsHandlerRelationshipNodeTermData() {
$view = Views::getView('test_taxonomy_node_term_data');
// Tests \Drupal\taxonomy\Plugin\views\relationship\NodeTermData::calculateDependencies().
$expected = [
@@ -30,16 +30,16 @@ class RelationshipNodeTermDataTest extends TaxonomyTestBase {
],
];
$this->assertIdentical($expected, $view->getDependencies());
- $this->executeView($view, array($this->term1->id(), $this->term2->id()));
- $expected_result = array(
- array(
+ $this->executeView($view, [$this->term1->id(), $this->term2->id()]);
+ $expected_result = [
+ [
'nid' => $this->nodes[1]->id(),
- ),
- array(
+ ],
+ [
'nid' => $this->nodes[0]->id(),
- ),
- );
- $column_map = array('nid' => 'nid');
+ ],
+ ];
+ $column_map = ['nid' => 'nid'];
$this->assertIdenticalResultset($view, $expected_result, $column_map);
// Change the view to test relation limited by vocabulary.
@@ -51,7 +51,7 @@ class RelationshipNodeTermDataTest extends TaxonomyTestBase {
// Tests \Drupal\taxonomy\Plugin\views\relationship\NodeTermData::calculateDependencies().
$expected['config'][] = 'taxonomy.vocabulary.views_testing_tags';
$this->assertIdentical($expected, $view->getDependencies());
- $this->executeView($view, array($this->term1->id(), $this->term2->id()));
+ $this->executeView($view, [$this->term1->id(), $this->term2->id()]);
$this->assertIdenticalResultset($view, $expected_result, $column_map);
}
diff --git a/web/core/modules/taxonomy/src/Tests/Views/RelationshipRepresentativeNodeTest.php b/web/core/modules/taxonomy/src/Tests/Views/RelationshipRepresentativeNodeTest.php
index d049f8228..aa85c9e5b 100644
--- a/web/core/modules/taxonomy/src/Tests/Views/RelationshipRepresentativeNodeTest.php
+++ b/web/core/modules/taxonomy/src/Tests/Views/RelationshipRepresentativeNodeTest.php
@@ -16,7 +16,7 @@ class RelationshipRepresentativeNodeTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $testViews = array('test_groupwise_term');
+ public static $testViews = ['test_groupwise_term'];
/**
* Tests the relationship.
@@ -24,17 +24,17 @@ class RelationshipRepresentativeNodeTest extends TaxonomyTestBase {
public function testRelationship() {
$view = Views::getView('test_groupwise_term');
$this->executeView($view);
- $map = array('node_field_data_taxonomy_term_field_data_nid' => 'nid', 'tid' => 'tid');
- $expected_result = array(
- array(
+ $map = ['node_field_data_taxonomy_term_field_data_nid' => 'nid', 'tid' => 'tid'];
+ $expected_result = [
+ [
'nid' => $this->nodes[1]->id(),
'tid' => $this->term2->id(),
- ),
- array(
+ ],
+ [
'nid' => $this->nodes[1]->id(),
'tid' => $this->term1->id(),
- ),
- );
+ ],
+ ];
$this->assertIdenticalResultset($view, $expected_result, $map);
}
diff --git a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyDefaultArgumentTest.php b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyDefaultArgumentTest.php
index c08266f12..8b263b4f6 100644
--- a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyDefaultArgumentTest.php
+++ b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyDefaultArgumentTest.php
@@ -19,7 +19,7 @@ class TaxonomyDefaultArgumentTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $testViews = array('taxonomy_default_argument_test');
+ public static $testViews = ['taxonomy_default_argument_test'];
/**
* Tests the relationship.
@@ -37,7 +37,7 @@ class TaxonomyDefaultArgumentTest extends TaxonomyTestBase {
$view->setResponse($response);
$view->initHandlers();
- $expected = implode(',', array($this->term1->id(), $this->term2->id()));
+ $expected = implode(',', [$this->term1->id(), $this->term2->id()]);
$this->assertEqual($expected, $view->argument['tid']->getDefaultArgument());
$view->destroy();
}
@@ -68,7 +68,7 @@ class TaxonomyDefaultArgumentTest extends TaxonomyTestBase {
$view->setResponse($response);
$view->initHandlers();
- $expected = implode(',', array($this->term1->id(), $this->term2->id()));
+ $expected = implode(',', [$this->term1->id(), $this->term2->id()]);
$this->assertEqual($expected, $view->argument['tid']->getDefaultArgument());
}
diff --git a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php
index 4737b989d..41780412c 100644
--- a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php
+++ b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldAllTermsTest.php
@@ -17,7 +17,7 @@ class TaxonomyFieldAllTermsTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $testViews = array('taxonomy_all_terms_test');
+ public static $testViews = ['taxonomy_all_terms_test'];
/**
* Tests the "all terms" field handler.
diff --git a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php
index fb0c0df2d..86f67ff3d 100644
--- a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php
+++ b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php
@@ -22,14 +22,14 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
/**
* {@inheritdoc}
*/
- public static $modules = array('language', 'taxonomy', 'taxonomy_test_views', 'text', 'views', 'node');
+ public static $modules = ['language', 'taxonomy', 'taxonomy_test_views', 'text', 'views', 'node'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_field_filters');
+ public static $testViews = ['test_field_filters'];
/**
* The vocabulary used for creating terms.
@@ -45,7 +45,7 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
*/
public $termNames = [];
- function setUp() {
+ public function setUp() {
parent::setUp();
// Add two new languages.
@@ -53,11 +53,11 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
ConfigurableLanguage::createFromLangcode('es')->save();
// Set up term names.
- $this->termNames = array(
+ $this->termNames = [
'en' => 'Food in Paris',
'es' => 'Comida en Paris',
'fr' => 'Nouriture en Paris',
- );
+ ];
// Create a vocabulary.
$this->vocabulary = Vocabulary::create([
@@ -67,11 +67,11 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
$this->vocabulary->save();
// Add a translatable field to the vocabulary.
- $field = FieldStorageConfig::create(array(
+ $field = FieldStorageConfig::create([
'field_name' => 'field_foo',
'entity_type' => 'taxonomy_term',
'type' => 'text',
- ));
+ ]);
$field->save();
FieldConfig::create([
'field_name' => 'field_foo',
@@ -81,9 +81,9 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
])->save();
// Create term with translations.
- $taxonomy = $this->createTermWithProperties(array('name' => $this->termNames['en'], 'langcode' => 'en', 'description' => $this->termNames['en'], 'field_foo' => $this->termNames['en']));
- foreach (array('es', 'fr') as $langcode) {
- $translation = $taxonomy->addTranslation($langcode, array('name' => $this->termNames[$langcode]));
+ $taxonomy = $this->createTermWithProperties(['name' => $this->termNames['en'], 'langcode' => 'en', 'description' => $this->termNames['en'], 'field_foo' => $this->termNames['en']]);
+ foreach (['es', 'fr'] as $langcode) {
+ $translation = $taxonomy->addTranslation($langcode, ['name' => $this->termNames[$langcode]]);
$translation->description->value = $this->termNames[$langcode];
$translation->field_foo->value = $this->termNames[$langcode];
}
@@ -91,7 +91,7 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
Views::viewsData()->clear();
- ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['taxonomy_test_views']);
$this->container->get('router.builder')->rebuild();
}
@@ -101,27 +101,27 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
public function testFilters() {
// Test the name filter page, which filters for name contains 'Comida'.
// Should show just the Spanish translation, once.
- $this->assertPageCounts('test-name-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida name filter');
+ $this->assertPageCounts('test-name-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida name filter');
// Test the description filter page, which filters for description contains
// 'Comida'. Should show just the Spanish translation, once.
- $this->assertPageCounts('test-desc-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida description filter');
+ $this->assertPageCounts('test-desc-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida description filter');
// Test the field filter page, which filters for field_foo contains
// 'Comida'. Should show just the Spanish translation, once.
- $this->assertPageCounts('test-field-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida field filter');
+ $this->assertPageCounts('test-field-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida field filter');
// Test the name Paris filter page, which filters for name contains
// 'Paris'. Should show each translation once.
- $this->assertPageCounts('test-name-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris name filter');
+ $this->assertPageCounts('test-name-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris name filter');
// Test the description Paris page, which filters for description contains
// 'Paris'. Should show each translation, once.
- $this->assertPageCounts('test-desc-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris description filter');
+ $this->assertPageCounts('test-desc-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris description filter');
// Test the field Paris filter page, which filters for field_foo contains
// 'Paris'. Should show each translation once.
- $this->assertPageCounts('test-field-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris field filter');
+ $this->assertPageCounts('test-field-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris field filter');
}
@@ -163,12 +163,12 @@ class TaxonomyFieldFilterTest extends ViewTestBase {
$filter_formats = filter_formats();
$format = array_pop($filter_formats);
- $properties += array(
+ $properties += [
'name' => $this->randomMachineName(),
'description' => $this->randomMachineName(),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'field_foo' => $this->randomMachineName(),
- );
+ ];
$term = Term::create([
'name' => $properties['name'],
diff --git a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldTidTest.php b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldTidTest.php
index 6480491fc..b068f083a 100644
--- a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldTidTest.php
+++ b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldTidTest.php
@@ -17,9 +17,9 @@ class TaxonomyFieldTidTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $testViews = array('test_taxonomy_tid_field');
+ public static $testViews = ['test_taxonomy_tid_field'];
- function testViewsHandlerTidField() {
+ public function testViewsHandlerTidField() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
diff --git a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidFilterTest.php b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidFilterTest.php
index 9935aa964..aa5054feb 100644
--- a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidFilterTest.php
+++ b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidFilterTest.php
@@ -58,7 +58,7 @@ class TaxonomyIndexTidFilterTest extends TaxonomyTestBase {
$term->save();
$this->terms[$term->id()] = $term;
- ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['taxonomy_test_views']);
}
/**
diff --git a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php
index 7dff50a48..efa51916d 100644
--- a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php
+++ b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php
@@ -24,7 +24,7 @@ class TaxonomyIndexTidUiTest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_filter_taxonomy_index_tid', 'test_taxonomy_term_name');
+ public static $testViews = ['test_filter_taxonomy_index_tid', 'test_taxonomy_term_name'];
/**
* Modules to enable.
@@ -71,7 +71,7 @@ class TaxonomyIndexTidUiTest extends UITestBase {
$term->save();
}
}
- ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['taxonomy_test_views']);
Vocabulary::create([
'vid' => 'empty_vocabulary',
diff --git a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyParentUITest.php b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyParentUITest.php
index c79a406cf..a57a09a7a 100644
--- a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyParentUITest.php
+++ b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyParentUITest.php
@@ -18,14 +18,14 @@ class TaxonomyParentUITest extends UITestBase {
*
* @var array
*/
- public static $testViews = array('test_taxonomy_parent');
+ public static $testViews = ['test_taxonomy_parent'];
/**
* Modules to enable.
*
* @var array
*/
- public static $modules = array('taxonomy', 'taxonomy_test_views');
+ public static $modules = ['taxonomy', 'taxonomy_test_views'];
/**
* {@inheritdoc}
@@ -33,7 +33,7 @@ class TaxonomyParentUITest extends UITestBase {
protected function setUp() {
parent::setUp();
- ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['taxonomy_test_views']);
}
/**
diff --git a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyRelationshipTest.php b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyRelationshipTest.php
index bada7fae8..7024e64b4 100644
--- a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyRelationshipTest.php
+++ b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyRelationshipTest.php
@@ -18,14 +18,14 @@ class TaxonomyRelationshipTest extends TaxonomyTestBase {
*
* @var \Drupal\taxonomy\TermInterface[]
*/
- protected $terms = array();
+ protected $terms = [];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_taxonomy_term_relationship');
+ public static $testViews = ['test_taxonomy_term_relationship'];
/**
* {@inheritdoc}
diff --git a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyTermViewTest.php b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyTermViewTest.php
index ef6da478f..bfd65cf46 100644
--- a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyTermViewTest.php
+++ b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyTermViewTest.php
@@ -21,7 +21,7 @@ class TaxonomyTermViewTest extends TaxonomyTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy', 'views');
+ public static $modules = ['taxonomy', 'views'];
/**
* An user with permissions to administer taxonomy.
@@ -51,23 +51,23 @@ class TaxonomyTermViewTest extends TaxonomyTestBase {
$this->fieldName1 = Unicode::strtolower($this->randomMachineName());
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->vocabulary->id() => $this->vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'article', $this->fieldName1, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_get_form_display('node', 'article', 'default')
- ->setComponent($this->fieldName1, array(
+ ->setComponent($this->fieldName1, [
'type' => 'options_select',
- ))
+ ])
->save();
entity_get_display('node', 'article', 'default')
- ->setComponent($this->fieldName1, array(
+ ->setComponent($this->fieldName1, [
'type' => 'entity_reference_label',
- ))
+ ])
->save();
}
@@ -79,7 +79,7 @@ class TaxonomyTermViewTest extends TaxonomyTestBase {
$term = $this->createTerm();
// Post an article.
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $original_title = $this->randomMachineName();
$edit['body[0][value]'] = $this->randomMachineName();
$edit["{$this->fieldName1}[]"] = $term->id();
@@ -90,7 +90,7 @@ class TaxonomyTermViewTest extends TaxonomyTestBase {
$this->assertText($term->label());
$this->assertText($node->label());
- \Drupal::service('module_installer')->install(array('language', 'content_translation'));
+ \Drupal::service('module_installer')->install(['language', 'content_translation']);
$language = ConfigurableLanguage::createFromLangcode('ur');
$language->save();
// Enable translation for the article content type and ensure the change is
diff --git a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php
index dc5755993..6ff551418 100644
--- a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php
+++ b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php
@@ -22,14 +22,14 @@ abstract class TaxonomyTestBase extends ViewTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy', 'taxonomy_test_views');
+ public static $modules = ['taxonomy', 'taxonomy_test_views'];
/**
* Stores the nodes used for the different tests.
*
* @var \Drupal\node\NodeInterface[]
*/
- protected $nodes = array();
+ protected $nodes = [];
/**
* The vocabulary used for creating terms.
@@ -60,13 +60,13 @@ abstract class TaxonomyTestBase extends ViewTestBase {
$this->mockStandardInstall();
if ($import_test_views) {
- ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['taxonomy_test_views']);
}
$this->term1 = $this->createTerm();
$this->term2 = $this->createTerm();
- $node = array();
+ $node = [];
$node['type'] = 'article';
$node['field_views_testing_tags'][]['target_id'] = $this->term1->id();
$node['field_views_testing_tags'][]['target_id'] = $this->term2->id();
@@ -80,9 +80,9 @@ abstract class TaxonomyTestBase extends ViewTestBase {
* @see https://www.drupal.org/node/1708692
*/
protected function mockStandardInstall() {
- $this->drupalCreateContentType(array(
+ $this->drupalCreateContentType([
'type' => 'article',
- ));
+ ]);
// Create the vocabulary for the tag field.
$this->vocabulary = Vocabulary::create([
'name' => 'Views testing tags',
@@ -91,32 +91,32 @@ abstract class TaxonomyTestBase extends ViewTestBase {
$this->vocabulary->save();
$field_name = 'field_' . $this->vocabulary->id();
- $handler_settings = array(
- 'target_bundles' => array(
+ $handler_settings = [
+ 'target_bundles' => [
$this->vocabulary->id() => $this->vocabulary->id(),
- ),
+ ],
'auto_create' => TRUE,
- );
+ ];
$this->createEntityReferenceField('node', 'article', $field_name, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
entity_get_form_display('node', 'article', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'entity_reference_autocomplete_tags',
'weight' => -4,
- ))
+ ])
->save();
entity_get_display('node', 'article', 'default')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'entity_reference_label',
'weight' => 10,
- ))
+ ])
->save();
entity_get_display('node', 'article', 'teaser')
- ->setComponent($field_name, array(
+ ->setComponent($field_name, [
'type' => 'entity_reference_label',
'weight' => 10,
- ))
+ ])
->save();
}
diff --git a/web/core/modules/taxonomy/src/Tests/Views/TaxonomyVocabularyArgumentTest.php b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyVocabularyArgumentTest.php
new file mode 100644
index 000000000..532335f19
--- /dev/null
+++ b/web/core/modules/taxonomy/src/Tests/Views/TaxonomyVocabularyArgumentTest.php
@@ -0,0 +1,76 @@
+vocabularies[] = $this->vocabulary;
+ // Create additional vocabulary.
+ $vocabulary = Vocabulary::create([
+ 'name' => 'Views testing category',
+ 'vid' => 'views_testing_category',
+ ]);
+ $vocabulary->save();
+ $this->vocabularies[] = $vocabulary;
+
+ // Create some terms.
+ $this->terms[0] = $this->createTerm([
+ 'name' => 'First',
+ 'vid' => $this->vocabularies[0]->id(),
+ ]);
+ $this->terms[1] = $this->createTerm([
+ 'name' => 'Second',
+ 'vid' => $this->vocabularies[1]->id(),
+ ]);
+ }
+
+ /**
+ * Tests the vocabulary argument handler.
+ *
+ * @see Drupal\taxonomy\Plugin\views\argument\VocabularyVid
+ */
+ public function testTermWithVocabularyArgument() {
+ $this->drupalGet('test_argument_taxonomy_vocabulary/' . $this->vocabularies[0]->id());
+ // First term should be present.
+ $this->assertText($this->terms[0]->label());
+ // Second term should not be present.
+ $this->assertNoText($this->terms[1]->label());
+ }
+
+}
diff --git a/web/core/modules/taxonomy/src/Tests/Views/TermNameFieldTest.php b/web/core/modules/taxonomy/src/Tests/Views/TermNameFieldTest.php
index 2effe722b..98d1ab4b4 100644
--- a/web/core/modules/taxonomy/src/Tests/Views/TermNameFieldTest.php
+++ b/web/core/modules/taxonomy/src/Tests/Views/TermNameFieldTest.php
@@ -16,7 +16,7 @@ class TermNameFieldTest extends TaxonomyTestBase {
/**
* {@inheritdoc}
*/
- public static $testViews = array('test_taxonomy_term_name');
+ public static $testViews = ['test_taxonomy_term_name'];
/**
* Tests term name field plugin functionality.
diff --git a/web/core/modules/taxonomy/src/Tests/VocabularyUiTest.php b/web/core/modules/taxonomy/src/Tests/VocabularyUiTest.php
index 3066ef07d..89c7a67f5 100644
--- a/web/core/modules/taxonomy/src/Tests/VocabularyUiTest.php
+++ b/web/core/modules/taxonomy/src/Tests/VocabularyUiTest.php
@@ -31,30 +31,33 @@ class VocabularyUiTest extends TaxonomyTestBase {
/**
* Create, edit and delete a vocabulary via the user interface.
*/
- function testVocabularyInterface() {
+ public function testVocabularyInterface() {
// Visit the main taxonomy administration page.
$this->drupalGet('admin/structure/taxonomy');
// Create a new vocabulary.
$this->clickLink(t('Add vocabulary'));
- $edit = array();
+ $edit = [];
$vid = Unicode::strtolower($this->randomMachineName());
$edit['name'] = $this->randomMachineName();
$edit['description'] = $this->randomMachineName();
$edit['vid'] = $vid;
$this->drupalPostForm(NULL, $edit, t('Save'));
- $this->assertRaw(t('Created new vocabulary %name.', array('%name' => $edit['name'])), 'Vocabulary created successfully.');
+ $this->assertRaw(t('Created new vocabulary %name.', ['%name' => $edit['name']]), 'Vocabulary created successfully.');
// Edit the vocabulary.
$this->drupalGet('admin/structure/taxonomy');
- $this->assertText($edit['name'], 'Vocabulary found in the vocabulary overview listing.');
+ $this->assertText($edit['name'], 'Vocabulary name found in the vocabulary overview listing.');
+ $this->assertText($edit['description'], 'Vocabulary description found in the vocabulary overview listing.');
$this->assertLinkByHref(Url::fromRoute('entity.taxonomy_term.add_form', ['taxonomy_vocabulary' => $edit['vid']])->toString());
$this->clickLink(t('Edit vocabulary'));
- $edit = array();
+ $edit = [];
$edit['name'] = $this->randomMachineName();
+ $edit['description'] = $this->randomMachineName();
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->drupalGet('admin/structure/taxonomy');
- $this->assertText($edit['name'], 'Vocabulary found in the vocabulary overview listing.');
+ $this->assertText($edit['name'], 'Vocabulary name found in the vocabulary overview listing.');
+ $this->assertText($edit['description'], 'Vocabulary description found in the vocabulary overview listing.');
// Try to submit a vocabulary with a duplicate machine name.
$edit['vid'] = $vid;
@@ -67,28 +70,28 @@ class VocabularyUiTest extends TaxonomyTestBase {
$this->assertText(t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
// Ensure that vocabulary titles are escaped properly.
- $edit = array();
+ $edit = [];
$edit['name'] = 'Don\'t Panic';
$edit['description'] = $this->randomMachineName();
$edit['vid'] = 'don_t_panic';
$this->drupalPostForm('admin/structure/taxonomy/add', $edit, t('Save'));
$site_name = $this->config('system.site')->get('name');
- $this->assertTitle(t('Don\'t Panic | @site-name', array('@site-name' => $site_name)), 'The page title contains the escaped character.');
- $this->assertNoTitle(t('Don't Panic | @site-name', array('@site-name' => $site_name)), 'The page title does not contain an encoded character.');
+ $this->assertTitle(t('Don\'t Panic | @site-name', ['@site-name' => $site_name]), 'The page title contains the escaped character.');
+ $this->assertNoTitle(t('Don't Panic | @site-name', ['@site-name' => $site_name]), 'The page title does not contain an encoded character.');
}
/**
* Changing weights on the vocabulary overview with two or more vocabularies.
*/
- function testTaxonomyAdminChangingWeights() {
+ public function testTaxonomyAdminChangingWeights() {
// Create some vocabularies.
for ($i = 0; $i < 10; $i++) {
$this->createVocabulary();
}
// Get all vocabularies and change their weights.
$vocabularies = Vocabulary::loadMultiple();
- $edit = array();
+ $edit = [];
foreach ($vocabularies as $key => $vocabulary) {
$weight = -$vocabulary->get('weight');
$vocabularies[$key]->set('weight', $weight);
@@ -110,7 +113,7 @@ class VocabularyUiTest extends TaxonomyTestBase {
/**
* Test the vocabulary overview with no vocabularies.
*/
- function testTaxonomyAdminNoVocabularies() {
+ public function testTaxonomyAdminNoVocabularies() {
// Delete all vocabularies.
$vocabularies = Vocabulary::loadMultiple();
foreach ($vocabularies as $key => $vocabulary) {
@@ -126,13 +129,13 @@ class VocabularyUiTest extends TaxonomyTestBase {
/**
* Deleting a vocabulary.
*/
- function testTaxonomyAdminDeletingVocabulary() {
+ public function testTaxonomyAdminDeletingVocabulary() {
// Create a vocabulary.
$vid = Unicode::strtolower($this->randomMachineName());
- $edit = array(
+ $edit = [
'name' => $this->randomMachineName(),
'vid' => $vid,
- );
+ ];
$this->drupalPostForm('admin/structure/taxonomy/add', $edit, t('Save'));
$this->assertText(t('Created new vocabulary'), 'New vocabulary was created.');
@@ -144,12 +147,12 @@ class VocabularyUiTest extends TaxonomyTestBase {
// Delete the vocabulary.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id());
$this->clickLink(t('Delete'));
- $this->assertRaw(t('Are you sure you want to delete the vocabulary %name?', array('%name' => $vocabulary->label())), '[confirm deletion] Asks for confirmation.');
+ $this->assertRaw(t('Are you sure you want to delete the vocabulary %name?', ['%name' => $vocabulary->label()]), '[confirm deletion] Asks for confirmation.');
$this->assertText(t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'), '[confirm deletion] Inform that all terms will be deleted.');
// Confirm deletion.
$this->drupalPostForm(NULL, NULL, t('Delete'));
- $this->assertRaw(t('Deleted vocabulary %name.', array('%name' => $vocabulary->label())), 'Vocabulary deleted.');
+ $this->assertRaw(t('Deleted vocabulary %name.', ['%name' => $vocabulary->label()]), 'Vocabulary deleted.');
$this->container->get('entity.manager')->getStorage('taxonomy_vocabulary')->resetCache();
$this->assertFalse(Vocabulary::load($vid), 'Vocabulary not found.');
}
diff --git a/web/core/modules/taxonomy/src/VocabularyForm.php b/web/core/modules/taxonomy/src/VocabularyForm.php
index 1868ddc38..63f0ccb8a 100644
--- a/web/core/modules/taxonomy/src/VocabularyForm.php
+++ b/web/core/modules/taxonomy/src/VocabularyForm.php
@@ -52,59 +52,59 @@ class VocabularyForm extends BundleEntityFormBase {
$form['#title'] = $this->t('Edit vocabulary');
}
- $form['name'] = array(
+ $form['name'] = [
'#type' => 'textfield',
'#title' => $this->t('Name'),
'#default_value' => $vocabulary->label(),
'#maxlength' => 255,
'#required' => TRUE,
- );
- $form['vid'] = array(
+ ];
+ $form['vid'] = [
'#type' => 'machine_name',
'#default_value' => $vocabulary->id(),
'#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
- '#machine_name' => array(
- 'exists' => array($this, 'exists'),
- 'source' => array('name'),
- ),
- );
- $form['description'] = array(
+ '#machine_name' => [
+ 'exists' => [$this, 'exists'],
+ 'source' => ['name'],
+ ],
+ ];
+ $form['description'] = [
'#type' => 'textfield',
'#title' => $this->t('Description'),
'#default_value' => $vocabulary->getDescription(),
- );
+ ];
// $form['langcode'] is not wrapped in an
// if ($this->moduleHandler->moduleExists('language')) check because the
// language_select form element works also without the language module being
// installed. https://www.drupal.org/node/1749954 documents the new element.
- $form['langcode'] = array(
+ $form['langcode'] = [
'#type' => 'language_select',
'#title' => $this->t('Vocabulary language'),
'#languages' => LanguageInterface::STATE_ALL,
'#default_value' => $vocabulary->language()->getId(),
- );
+ ];
if ($this->moduleHandler->moduleExists('language')) {
- $form['default_terms_language'] = array(
+ $form['default_terms_language'] = [
'#type' => 'details',
'#title' => $this->t('Terms language'),
'#open' => TRUE,
- );
- $form['default_terms_language']['default_language'] = array(
+ ];
+ $form['default_terms_language']['default_language'] = [
'#type' => 'language_configuration',
- '#entity_information' => array(
+ '#entity_information' => [
'entity_type' => 'taxonomy_term',
'bundle' => $vocabulary->id(),
- ),
+ ],
'#default_value' => ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $vocabulary->id()),
- );
+ ];
}
// Set the hierarchy to "multiple parents" by default. This simplifies the
// vocabulary form and standardizes the term form.
- $form['hierarchy'] = array(
+ $form['hierarchy'] = [
'#type' => 'value',
'#value' => '0',
- );
+ ];
$form = parent::form($form, $form_state);
return $this->protectBundleIdElement($form);
@@ -123,14 +123,14 @@ class VocabularyForm extends BundleEntityFormBase {
$edit_link = $this->entity->link($this->t('Edit'));
switch ($status) {
case SAVED_NEW:
- drupal_set_message($this->t('Created new vocabulary %name.', array('%name' => $vocabulary->label())));
- $this->logger('taxonomy')->notice('Created new vocabulary %name.', array('%name' => $vocabulary->label(), 'link' => $edit_link));
+ drupal_set_message($this->t('Created new vocabulary %name.', ['%name' => $vocabulary->label()]));
+ $this->logger('taxonomy')->notice('Created new vocabulary %name.', ['%name' => $vocabulary->label(), 'link' => $edit_link]);
$form_state->setRedirectUrl($vocabulary->urlInfo('overview-form'));
break;
case SAVED_UPDATED:
- drupal_set_message($this->t('Updated vocabulary %name.', array('%name' => $vocabulary->label())));
- $this->logger('taxonomy')->notice('Updated vocabulary %name.', array('%name' => $vocabulary->label(), 'link' => $edit_link));
+ drupal_set_message($this->t('Updated vocabulary %name.', ['%name' => $vocabulary->label()]));
+ $this->logger('taxonomy')->notice('Updated vocabulary %name.', ['%name' => $vocabulary->label(), 'link' => $edit_link]);
$form_state->setRedirectUrl($vocabulary->urlInfo('collection'));
break;
}
diff --git a/web/core/modules/taxonomy/src/VocabularyListBuilder.php b/web/core/modules/taxonomy/src/VocabularyListBuilder.php
index b5597bb2e..8503c288a 100644
--- a/web/core/modules/taxonomy/src/VocabularyListBuilder.php
+++ b/web/core/modules/taxonomy/src/VocabularyListBuilder.php
@@ -36,16 +36,16 @@ class VocabularyListBuilder extends DraggableListBuilder {
$operations['edit']['title'] = t('Edit vocabulary');
}
- $operations['list'] = array(
+ $operations['list'] = [
'title' => t('List terms'),
'weight' => 0,
'url' => $entity->urlInfo('overview-form'),
- );
- $operations['add'] = array(
+ ];
+ $operations['add'] = [
'title' => t('Add terms'),
'weight' => 10,
'url' => Url::fromRoute('entity.taxonomy_term.add_form', ['taxonomy_vocabulary' => $entity->id()]),
- );
+ ];
unset($operations['delete']);
return $operations;
@@ -56,6 +56,7 @@ class VocabularyListBuilder extends DraggableListBuilder {
*/
public function buildHeader() {
$header['label'] = t('Vocabulary name');
+ $header['description'] = t('Description');
return $header + parent::buildHeader();
}
@@ -64,6 +65,7 @@ class VocabularyListBuilder extends DraggableListBuilder {
*/
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity->label();
+ $row['description']['data'] = ['#markup' => $entity->getDescription()];
return $row + parent::buildRow($entity);
}
@@ -78,7 +80,7 @@ class VocabularyListBuilder extends DraggableListBuilder {
unset($this->weightKey);
}
$build = parent::render();
- $build['table']['#empty'] = t('No vocabularies available. Add vocabulary.', array(':link' => \Drupal::url('entity.taxonomy_vocabulary.add_form')));
+ $build['table']['#empty'] = t('No vocabularies available. Add vocabulary.', [':link' => \Drupal::url('entity.taxonomy_vocabulary.add_form')]);
return $build;
}
@@ -87,7 +89,7 @@ class VocabularyListBuilder extends DraggableListBuilder {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
- $form['vocabularies']['#attributes'] = array('id' => 'taxonomy');
+ $form['vocabularies']['#attributes'] = ['id' => 'taxonomy'];
$form['actions']['submit']['#value'] = t('Save');
return $form;
diff --git a/web/core/modules/taxonomy/src/VocabularyStorage.php b/web/core/modules/taxonomy/src/VocabularyStorage.php
index 4b08b2931..bdbf8938f 100644
--- a/web/core/modules/taxonomy/src/VocabularyStorage.php
+++ b/web/core/modules/taxonomy/src/VocabularyStorage.php
@@ -21,7 +21,7 @@ class VocabularyStorage extends ConfigEntityStorage implements VocabularyStorage
* {@inheritdoc}
*/
public function getToplevelTids($vids) {
- return db_query('SELECT t.tid FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} th ON th.tid = t.tid WHERE t.vid IN ( :vids[] ) AND th.parent = 0', array(':vids[]' => $vids))->fetchCol();
+ return db_query('SELECT t.tid FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} th ON th.tid = t.tid WHERE t.vid IN ( :vids[] ) AND th.parent = 0', [':vids[]' => $vids])->fetchCol();
}
}
diff --git a/web/core/modules/taxonomy/taxonomy.module b/web/core/modules/taxonomy/taxonomy.module
index 80884329b..4a93989ad 100644
--- a/web/core/modules/taxonomy/taxonomy.module
+++ b/web/core/modules/taxonomy/taxonomy.module
@@ -47,23 +47,23 @@ const TAXONOMY_HIERARCHY_MULTIPLE = 2;
function taxonomy_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.taxonomy':
- $field_ui_url = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#';
+ $field_ui_url = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#';
$output = '';
$output .= '' . t('About') . '
';
- $output .= '' . t('The Taxonomy module allows users who have permission to create and edit content to categorize (tag) content of that type. Users who have the Administer vocabularies and terms permission can add vocabularies that contain a set of related terms. The terms in a vocabulary can either be pre-set by an administrator or built gradually as content is added and edited. Terms may be organized hierarchically if desired.', array(':permissions' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-taxonomy')))) . '
';
- $output .= '' . t('For more information, see the online documentation for the Taxonomy module.', array(':taxonomy' => 'https://www.drupal.org/documentation/modules/taxonomy/')) . '
';
+ $output .= '' . t('The Taxonomy module allows users who have permission to create and edit content to categorize (tag) content of that type. Users who have the Administer vocabularies and terms permission can add vocabularies that contain a set of related terms. The terms in a vocabulary can either be pre-set by an administrator or built gradually as content is added and edited. Terms may be organized hierarchically if desired.', [':permissions' => \Drupal::url('user.admin_permissions', [], ['fragment' => 'module-taxonomy'])]) . '
';
+ $output .= '' . t('For more information, see the online documentation for the Taxonomy module.', [':taxonomy' => 'https://www.drupal.org/documentation/modules/taxonomy/']) . '
';
$output .= '' . t('Uses') . '
';
$output .= '';
$output .= '- ' . t('Managing vocabularies') . '
';
- $output .= '- ' . t('Users who have the Administer vocabularies and terms permission can add and edit vocabularies from the Taxonomy administration page. Vocabularies can be deleted from their Edit vocabulary page. Users with the Taxonomy term: Administer fields permission may add additional fields for terms in that vocabulary using the Field UI module.', array(':taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection'), ':field_ui' => $field_ui_url)) . '
';
+ $output .= '- ' . t('Users who have the Administer vocabularies and terms permission can add and edit vocabularies from the Taxonomy administration page. Vocabularies can be deleted from their Edit vocabulary page. Users with the Taxonomy term: Administer fields permission may add additional fields for terms in that vocabulary using the Field UI module.', [':taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection'), ':field_ui' => $field_ui_url]) . '
';
$output .= '- ' . t('Managing terms') . '
';
- $output .= '- ' . t('Users who have the Administer vocabularies and terms permission or the Edit terms permission for a particular vocabulary can add, edit, and organize the terms in a vocabulary from a vocabulary\'s term listing page, which can be accessed by going to the Taxonomy administration page and clicking List terms in the Operations column. Users must have the Administer vocabularies and terms permission or the Delete terms permission for a particular vocabulary to delete terms.', array(':taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection'))) . '
';
+ $output .= '- ' . t('Users who have the Administer vocabularies and terms permission or the Edit terms permission for a particular vocabulary can add, edit, and organize the terms in a vocabulary from a vocabulary\'s term listing page, which can be accessed by going to the Taxonomy administration page and clicking List terms in the Operations column. Users must have the Administer vocabularies and terms permission or the Delete terms permission for a particular vocabulary to delete terms.', [':taxonomy_admin' => \Drupal::url('entity.taxonomy_vocabulary.collection')]) . '
';
$output .= '- ' . t('Classifying entity content') . '
';
- $output .= '- ' . t('A user with the Administer fields permission for a certain entity type may add Taxonomy term reference fields to the entity type, which will allow entities to be classified using taxonomy terms. See the Entity Reference help for more information about reference fields. See the Field module help and the Field UI help pages for general information on fields and how to create and manage them.', array(':field_ui' => $field_ui_url, ':field' => \Drupal::url('help.page', array('name' => 'field')), ':entity_reference' => \Drupal::url('help.page', array('name' => 'entity_reference')))) . '
';
+ $output .= '- ' . t('A user with the Administer fields permission for a certain entity type may add Taxonomy term reference fields to the entity type, which will allow entities to be classified using taxonomy terms. See the Entity Reference help for more information about reference fields. See the Field module help and the Field UI help pages for general information on fields and how to create and manage them.', [':field_ui' => $field_ui_url, ':field' => \Drupal::url('help.page', ['name' => 'field']), ':entity_reference' => \Drupal::url('help.page', ['name' => 'entity_reference'])]) . '
';
$output .= '- ' . t('Adding new terms during content creation') . '
';
$output .= '- ' . t('Allowing users to add new terms gradually builds a vocabulary as content is added and edited. Users can add new terms if either of the two Autocomplete widgets is chosen for the Taxonomy term reference field in the Manage form display page for the field. You will also need to enable the Create referenced entities if they don\'t already exist option, and restrict the field to one vocabulary.') . '
';
$output .= '- ' . t('Configuring displays and form displays') . '
';
- $output .= '- ' . t('See the Entity Reference help page for the field widgets and formatters that can be configured for any reference field on the Manage display and Manage form display pages. Taxonomy additionally provides an RSS category formatter that displays nothing when the entity item is displayed as HTML, but displays an RSS category instead of a list when the entity item is displayed in an RSS feed.', array(':entity_reference' => \Drupal::url('help.page', array('name' => 'entity_reference')))) . '';
+ $output .= '
- ' . t('See the Entity Reference help page for the field widgets and formatters that can be configured for any reference field on the Manage display and Manage form display pages. Taxonomy additionally provides an RSS category formatter that displays nothing when the entity item is displayed as HTML, but displays an RSS category instead of a list when the entity item is displayed in an RSS feed.', [':entity_reference' => \Drupal::url('help.page', ['name' => 'entity_reference'])]) . '';
$output .= '