diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php index 7f04f0e..9bac79e 100644 --- a/core/lib/Drupal/Core/Cache/ApcuBackend.php +++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php @@ -166,7 +166,7 @@ protected function prepareItem($cache, $allow_invalid) { * {@inheritdoc} */ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) { - assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.'); + Cache::validateTags($tags); $tags = array_unique($tags); $cache = new \stdClass(); $cache->cid = $cid; diff --git a/core/lib/Drupal/Core/Cache/Cache.php b/core/lib/Drupal/Core/Cache/Cache.php index d75eaff..5ad9500 100644 --- a/core/lib/Drupal/Core/Cache/Cache.php +++ b/core/lib/Drupal/Core/Cache/Cache.php @@ -34,7 +34,7 @@ class Cache { */ public static function mergeContexts(array $a = [], array $b = []) { $cache_contexts = array_unique(array_merge($a, $b)); - assert('\Drupal::service(\'cache_contexts_manager\')->assertValidTokens($cache_contexts)'); + \Drupal::service('cache_contexts_manager')->validateTokens($cache_contexts); sort($cache_contexts); return $cache_contexts; } @@ -59,9 +59,8 @@ public static function mergeContexts(array $a = [], array $b = []) { * The merged array of cache tags. */ public static function mergeTags(array $a = [], array $b = []) { - assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($a) && \Drupal\Component\Assertion\Inspector::assertAllStrings($b)', 'Cache tags must be valid strings'); - $cache_tags = array_unique(array_merge($a, $b)); + static::validateTags($cache_tags); sort($cache_tags); return $cache_tags; } @@ -100,9 +99,6 @@ public static function mergeMaxAges($a = Cache::PERMANENT, $b = Cache::PERMANENT * @param string[] $tags * An array of cache tags. * - * @deprecated - * Use assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)'); - * * @throws \LogicException */ public static function validateTags(array $tags) { diff --git a/core/lib/Drupal/Core/Cache/CacheCollector.php b/core/lib/Drupal/Core/Cache/CacheCollector.php index eb1ca57..a6d8ab5 100644 --- a/core/lib/Drupal/Core/Cache/CacheCollector.php +++ b/core/lib/Drupal/Core/Cache/CacheCollector.php @@ -115,7 +115,7 @@ * (optional) The tags to specify for the cache item. */ public function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, array $tags = array()) { - assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.'); + Cache::validateTags($tags); $this->cid = $cid; $this->cache = $cache; $this->tags = $tags; diff --git a/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php b/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php index 69d97c0..64a8eb0 100644 --- a/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php +++ b/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php @@ -27,7 +27,8 @@ class CacheTagsInvalidator implements CacheTagsInvalidatorInterface { * {@inheritdoc} */ public function invalidateTags(array $tags) { - assert('Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.'); + // Validate the tags. + Cache::validateTags($tags); // Notify all added cache tags invalidators. foreach ($this->invalidators as $invalidator) { diff --git a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php index 81d6735..b01dc9e 100644 --- a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php +++ b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php @@ -103,9 +103,11 @@ public function getLabels($include_calculated_cache_contexts = FALSE) { * The ContextCacheKeys object containing the converted cache keys and * cacheability metadata. * + * @throws \LogicException + * Thrown if any of the context tokens or parameters are not valid. */ public function convertTokensToKeys(array $context_tokens) { - assert('$this->assertValidTokens($context_tokens)'); + $this->validateTokens($context_tokens); $cacheable_metadata = new CacheableMetadata(); $optimized_tokens = $this->optimizeTokens($context_tokens); // Iterate over cache contexts that have been optimized away and get their @@ -297,33 +299,4 @@ public function validateTokens(array $context_tokens = []) { } } - /** - * Asserts the context tokens are valid - * - * Similar to ::validateTokens, this method returns boolean TRUE when the - * context tokens are valid, and FALSE when they are not instead of returning - * NULL when they are valid and throwing a \LogicException when they are not. - * This function should be used with the assert() statement. - * - * @param mixed $context_tokens - * Variable to be examined - should be array of context_tokens. - * - * @return bool - * TRUE if context_tokens is an array of valid tokens. - */ - public function assertValidTokens($context_tokens) { - if (!is_array($context_tokens)) { - return FALSE; - } - - try { - $this->validateTokens($context_tokens); - } - catch (\LogicException $e) { - return FALSE; - } - - return TRUE; - } - } diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index 7faa806..06c5dc2 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -199,7 +199,7 @@ protected function doSetMultiple(array $items) { 'tags' => array(), ); - assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($item[\'tags\'])', 'Cache Tags must be strings.'); + Cache::validateTags($item['tags']); $item['tags'] = array_unique($item['tags']); // Sort the cache tags so that they are stored consistently in the DB. sort($item['tags']); diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php index 5c93e06..5c7f928 100644 --- a/core/lib/Drupal/Core/Cache/MemoryBackend.php +++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php @@ -107,7 +107,7 @@ protected function prepareItem($cache, $allow_invalid) { * Implements Drupal\Core\Cache\CacheBackendInterface::set(). */ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) { - assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache Tags must be strings.'); + Cache::validateTags($tags); $tags = array_unique($tags); // Sort the cache tags so that they are stored consistently in the database. sort($tags); diff --git a/core/lib/Drupal/Core/Cache/PhpBackend.php b/core/lib/Drupal/Core/Cache/PhpBackend.php index 80b8771..761e394 100644 --- a/core/lib/Drupal/Core/Cache/PhpBackend.php +++ b/core/lib/Drupal/Core/Cache/PhpBackend.php @@ -148,7 +148,7 @@ protected function prepareItem($cache, $allow_invalid) { * {@inheritdoc} */ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) { - assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache Tags must be strings.'); + Cache::validateTags($tags); $item = (object) array( 'cid' => $cid, 'data' => $data, diff --git a/core/lib/Drupal/Core/Config/ConfigManager.php b/core/lib/Drupal/Core/Config/ConfigManager.php index eb59497..e5b471d 100644 --- a/core/lib/Drupal/Core/Config/ConfigManager.php +++ b/core/lib/Drupal/Core/Config/ConfigManager.php @@ -320,7 +320,8 @@ public function getConfigEntitiesToChangeOnDependencyRemoval($type, array $names } if ($this->callOnDependencyRemoval($dependent, $original_dependencies, $type, $names)) { // Recalculate dependencies and update the dependency graph data. - $dependency_manager->updateData($dependent->getConfigDependencyName(), $dependent->calculateDependencies()); + $dependent->calculateDependencies(); + $dependency_manager->updateData($dependent->getConfigDependencyName(), $dependent->getDependencies()); // Based on the updated data rebuild the list of dependents. $dependents = $this->findConfigEntityDependentsAsEntities($type, $names, $dependency_manager); // Ensure that the dependency has actually been fixed. It is possible @@ -458,6 +459,9 @@ public function findMissingContentDependencies() { if (isset($config_data['dependencies']['content'])) { $content_dependencies = array_merge($content_dependencies, $config_data['dependencies']['content']); } + if (isset($config_data['dependencies']['enforced']['content'])) { + $content_dependencies = array_merge($content_dependencies, $config_data['dependencies']['enforced']['content']); + } } foreach (array_unique($content_dependencies) as $content_dependency) { // Format of the dependency is entity_type:bundle:uuid. diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php index a762de9..80180ce 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php @@ -58,11 +58,11 @@ * Configuration entity classes usually extend * \Drupal\Core\Config\Entity\ConfigEntityBase. The base class provides a * generic implementation of the calculateDependencies() method that can - * discover dependencies due to enforced dependencies, plugins, and third party - * settings. If the configuration entity has dependencies that cannot be - * discovered by the base class's implementation, then it needs to implement + * discover dependencies due to plugins, and third party settings. If the + * configuration entity has dependencies that cannot be discovered by the base + * class's implementation, then it needs to implement * \Drupal\Core\Config\Entity\ConfigEntityInterface::calculateDependencies() to - * calculate (and return) the dependencies. In this method, use + * calculate the dependencies. In this method, use * \Drupal\Core\Config\Entity\ConfigEntityBase::addDependency() to add * dependencies. Implementations should call the base class implementation to * inherit the generic functionality. @@ -87,7 +87,7 @@ * for configuration synchronization, which needs to be able to validate * configuration in the staging directory before the synchronization has * occurred. Also, if you have a configuration entity object and you want to - * get the current dependencies without recalculation, you can use + * get the current dependencies (without recalculation), you can use * \Drupal\Core\Config\Entity\ConfigEntityInterface::getDependencies(). * * When uninstalling a module or a theme, configuration entities that are @@ -115,6 +115,7 @@ * module dependency in the sub-module only. * * @see \Drupal\Core\Config\Entity\ConfigEntityInterface::calculateDependencies() + * @see \Drupal\Core\Config\Entity\ConfigEntityInterface::getDependencies() * @see \Drupal\Core\Config\Entity\ConfigEntityInterface::onDependencyRemoval() * @see \Drupal\Core\Config\Entity\ConfigEntityBase::addDependency() * @see \Drupal\Core\Config\ConfigInstallerInterface::installDefaultConfig() diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index d9e1df8..4dd5231 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Config\Entity; +use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\Cache; use Drupal\Core\Config\ConfigException; use Drupal\Core\Config\Schema\SchemaIncompleteException; @@ -353,16 +354,9 @@ public function preSave(EntityStorageInterface $storage) { * {@inheritdoc} */ public function calculateDependencies() { - // Dependencies should be recalculated on every save. This ensures stale - // dependencies are never saved. - if (isset($this->dependencies['enforced'])) { - $dependencies = $this->dependencies['enforced']; - $this->dependencies = $dependencies; - $this->dependencies['enforced'] = $dependencies; - } - else { - $this->dependencies = array(); - } + // All dependencies should be recalculated on every save apart from enforced + // dependencies. This ensures stale dependencies are never saved. + $this->dependencies = array_intersect_key($this->dependencies, ['enforced' => '']); if ($this instanceof EntityWithPluginCollectionInterface) { // Configuration entities need to depend on the providers of any plugins // that they store the configuration for. @@ -379,7 +373,7 @@ public function calculateDependencies() { $this->addDependency('module', $provider); } } - return $this->dependencies; + return $this; } /** @@ -438,7 +432,14 @@ protected function addDependency($type, $name) { * {@inheritdoc} */ public function getDependencies() { - return $this->dependencies; + $dependencies = $this->dependencies; + if (isset($dependencies['enforced'])) { + // Merge the enforced dependencies into the list of dependencies. + $enforced_dependencies = $dependencies['enforced']; + unset($dependencies['enforced']); + $dependencies = NestedArray::mergeDeep($dependencies, $enforced_dependencies); + } + return $dependencies; } /** diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php index 9ca55b6..87e6605 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php @@ -7,6 +7,8 @@ namespace Drupal\Core\Config\Entity; +use Drupal\Component\Utility\NestedArray; + /** * Provides a value object to discover configuration dependencies. * @@ -26,7 +28,7 @@ class ConfigEntityDependency { * * @var array */ - protected $dependencies; + protected $dependencies = []; /** * Constructs the configuration entity dependency from the entity values. @@ -36,13 +38,16 @@ class ConfigEntityDependency { * @param array $values * (optional) The configuration entity's values. */ - public function __construct($name, $values = array()) { + public function __construct($name, $values = []) { $this->name = $name; - if (isset($values['dependencies'])) { - $this->dependencies = $values['dependencies']; + if (isset($values['dependencies']) && isset($values['dependencies']['enforced'])) { + // Merge the enforced dependencies into the list of dependencies. + $enforced_dependencies = $values['dependencies']['enforced']; + unset($values['dependencies']['enforced']); + $this->dependencies = NestedArray::mergeDeep($values['dependencies'], $enforced_dependencies); } - else { - $this->dependencies = array(); + elseif (isset($values['dependencies'])) { + $this->dependencies = $values['dependencies']; } } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php index bd8c48c..766fa6f 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php @@ -144,8 +144,7 @@ public function set($property_name, $value); /** * Calculates dependencies and stores them in the dependency property. * - * @return array - * An array of dependencies grouped by type (module, theme, entity). + * @return $this * * @see \Drupal\Core\Config\Entity\ConfigDependencyManager */ diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php index 2cf18d8..b835327 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php @@ -278,7 +278,7 @@ public function calculateDependencies() { $mode_entity = $this->entityManager()->getStorage('entity_' . $this->displayContext . '_mode')->load($target_entity_type->id() . '.' . $this->mode); $this->addDependency('config', $mode_entity->getConfigDependencyName()); } - return $this->dependencies; + return $this; } /** diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php index bc7e7f7..998e1c7 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php @@ -93,7 +93,7 @@ public function calculateDependencies() { parent::calculateDependencies(); $target_entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType); $this->addDependency('module', $target_entity_type->getProvider()); - return $this->dependencies; + return $this; } /** diff --git a/core/lib/Drupal/Core/Field/FieldConfigBase.php b/core/lib/Drupal/Core/Field/FieldConfigBase.php index e9fbaca..e3728be 100644 --- a/core/lib/Drupal/Core/Field/FieldConfigBase.php +++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php @@ -245,7 +245,7 @@ public function calculateDependencies() { $bundle_config_dependency = $this->entityManager()->getDefinition($this->entity_type)->getBundleConfigDependency($this->bundle); $this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']); - return $this->dependencies; + return $this; } /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php index 31cf07d..c17e725 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php @@ -95,25 +95,6 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state /** * {@inheritdoc} */ - public function getConstraints() { - $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); - $constraints = parent::getConstraints(); - - $constraints[] = $constraint_manager->create('ComplexData', array( - 'value' => array( - 'Regex' => array( - 'pattern' => '/^[+-]?((\d+(\.\d*)?)|(\.\d+))$/i', - ) - ), - )); - - return $constraints; - } - - - /** - * {@inheritdoc} - */ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { $element = parent::fieldSettingsForm($form, $form_state); $settings = $this->getSettings(); diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php index 5b7b86b..7c8799a 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php @@ -154,7 +154,7 @@ public function __construct($subdir, \Traversable $namespaces, ModuleHandlerInte * definitions should be cleared along with other, related cache entries. */ public function setCacheBackend(CacheBackendInterface $cache_backend, $cache_key, array $cache_tags = array()) { - assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($cache_tags)', 'Cache Tags must be strings.'); + Cache::validateTags($cache_tags); $this->cacheBackend = $cache_backend; $this->cacheKey = $cache_key; $this->cacheTags = $cache_tags; diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RegexConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RegexConstraint.php deleted file mode 100644 index 7d476eb..0000000 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/RegexConstraint.php +++ /dev/null @@ -1,32 +0,0 @@ -addDependency('theme', $this->theme); - return $this->dependencies; + return $this; } /** diff --git a/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php b/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php index c0d6743..39a4e11 100644 --- a/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php +++ b/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php @@ -100,7 +100,7 @@ public function testCalculateDependencies() { ->method('getPluginCollections') ->will($this->returnValue(array($plugin_collection))); - $dependencies = $entity->calculateDependencies(); + $dependencies = $entity->calculateDependencies()->getDependencies(); $this->assertContains('test', $dependencies['module']); $this->assertContains('stark', $dependencies['theme']); } diff --git a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php index 3c5b0ba..5652533 100644 --- a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php +++ b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php @@ -57,8 +57,9 @@ public function setUpDisplayVariant($configuration = array(), $definition = arra ->getMock(); $container->set('cache_contexts_manager', $cache_context_manager); $cache_context_manager->expects($this->any()) - ->method('assertValidTokens') - ->willReturn(TRUE); + ->method('validateTokens') + ->with([]) + ->willReturn([]); \Drupal::setContainer($container); $this->blockRepository = $this->getMock('Drupal\block\BlockRepositoryInterface'); diff --git a/core/modules/book/config/install/core.entity_view_mode.node.print.yml b/core/modules/book/config/install/core.entity_view_mode.node.print.yml index 2706949..d695ac5 100644 --- a/core/modules/book/config/install/core.entity_view_mode.node.print.yml +++ b/core/modules/book/config/install/core.entity_view_mode.node.print.yml @@ -2,7 +2,6 @@ langcode: en status: false dependencies: module: - - book - node enforced: module: diff --git a/core/modules/book/config/install/node.type.book.yml b/core/modules/book/config/install/node.type.book.yml index 531677f..0d1d0c0 100644 --- a/core/modules/book/config/install/node.type.book.yml +++ b/core/modules/book/config/install/node.type.book.yml @@ -1,8 +1,6 @@ langcode: en status: true dependencies: - module: - - book enforced: module: - book diff --git a/core/modules/config/src/Tests/ConfigDependencyTest.php b/core/modules/config/src/Tests/ConfigDependencyTest.php index 35b176c..050797d 100644 --- a/core/modules/config/src/Tests/ConfigDependencyTest.php +++ b/core/modules/config/src/Tests/ConfigDependencyTest.php @@ -69,7 +69,8 @@ public function testDependencyManagement() { // Ensure that the provider of the config entity is not actually written to // the dependencies array. $raw_config = $this->config('config_test.dynamic.entity1'); - $this->assertTrue(array_search('node', $raw_config->get('dependencies.module')) !== FALSE, 'Node module is written to the dependencies array as this has to be explicit.'); + $root_module_dependencies = $raw_config->get('dependencies.module'); + $this->assertTrue(empty($root_module_dependencies), 'Node module is not written to the root dependencies array as it is enforced.'); // Create additional entities to test dependencies on config entities. $entity2 = $storage->create(array('id' => 'entity2', 'dependencies' => array('enforced' => array('config' => array($entity1->getConfigDependencyName()))))); @@ -301,10 +302,10 @@ public function testConfigEntityUninstall() { $this->assertFalse($storage->load('entity1'), 'Entity 1 deleted'); $entity2 = $storage->load('entity2'); $this->assertTrue($entity2, 'Entity 2 not deleted'); - $this->assertEqual($entity2->calculateDependencies()['config'], array(), 'Entity 2 dependencies updated to remove dependency on Entity1.'); + $this->assertEqual($entity2->calculateDependencies()->getDependencies()['config'], array(), 'Entity 2 dependencies updated to remove dependency on Entity1.'); $entity3 = $storage->load('entity3'); $this->assertTrue($entity3, 'Entity 3 not deleted'); - $this->assertEqual($entity3->calculateDependencies()['config'], [$entity2->getConfigDependencyName()], 'Entity 3 still depends on Entity 2.'); + $this->assertEqual($entity3->calculateDependencies()->getDependencies()['config'], [$entity2->getConfigDependencyName()], 'Entity 3 still depends on Entity 2.'); $this->assertFalse($storage->load('entity4'), 'Entity 4 deleted'); } @@ -402,10 +403,10 @@ public function testConfigEntityDelete() { $this->assertFalse($storage->load('entity1'), 'Entity 1 deleted'); $entity2 = $storage->load('entity2'); $this->assertTrue($entity2, 'Entity 2 not deleted'); - $this->assertEqual($entity2->calculateDependencies()['config'], array(), 'Entity 2 dependencies updated to remove dependency on Entity1.'); + $this->assertEqual($entity2->calculateDependencies()->getDependencies()['config'], array(), 'Entity 2 dependencies updated to remove dependency on Entity1.'); $entity3 = $storage->load('entity3'); $this->assertTrue($entity3, 'Entity 3 not deleted'); - $this->assertEqual($entity3->calculateDependencies()['config'], [$entity2->getConfigDependencyName()], 'Entity 3 still depends on Entity 2.'); + $this->assertEqual($entity3->calculateDependencies()->getDependencies()['config'], [$entity2->getConfigDependencyName()], 'Entity 3 still depends on Entity 2.'); } /** diff --git a/core/modules/config/src/Tests/ConfigDependencyWebTest.php b/core/modules/config/src/Tests/ConfigDependencyWebTest.php index 24d2a15..af63fed 100644 --- a/core/modules/config/src/Tests/ConfigDependencyWebTest.php +++ b/core/modules/config/src/Tests/ConfigDependencyWebTest.php @@ -125,10 +125,10 @@ function testConfigDependencyDeleteFormTrait() { $this->assertFalse($storage->load('entity1'), 'Test entity 1 deleted'); $entity2 = $storage->load('entity2'); $this->assertTrue($entity2, 'Entity 2 not deleted'); - $this->assertEqual($entity2->calculateDependencies()['config'], array(), 'Entity 2 dependencies updated to remove dependency on Entity1.'); + $this->assertEqual($entity2->calculateDependencies()->getDependencies()['config'], array(), 'Entity 2 dependencies updated to remove dependency on Entity1.'); $entity3 = $storage->load('entity3'); $this->assertTrue($entity3, 'Entity 3 not deleted'); - $this->assertEqual($entity3->calculateDependencies()['config'], [$entity2->getConfigDependencyName()], 'Entity 3 still depends on Entity 2.'); + $this->assertEqual($entity3->calculateDependencies()->getDependencies()['config'], [$entity2->getConfigDependencyName()], 'Entity 3 still depends on Entity 2.'); } diff --git a/core/modules/config/tests/config_other_module_config_test/config/optional/config_test.dynamic.other_module_test_unmet.yml b/core/modules/config/tests/config_other_module_config_test/config/optional/config_test.dynamic.other_module_test_unmet.yml index 572a79f..5d788fb 100644 --- a/core/modules/config/tests/config_other_module_config_test/config/optional/config_test.dynamic.other_module_test_unmet.yml +++ b/core/modules/config/tests/config_other_module_config_test/config/optional/config_test.dynamic.other_module_test_unmet.yml @@ -6,8 +6,6 @@ status: true langcode: en protected_property: Default dependencies: - module: - - config_install_dependency_test enforced: module: - config_install_dependency_test diff --git a/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php b/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php index 8cb5881..0818be2 100644 --- a/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php +++ b/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php @@ -40,7 +40,6 @@ protected function setUp() { $this->cacheContextsManager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager') ->disableOriginalConstructor() ->getMock(); - $this->cacheContextsManager->method('assertValidTokens')->willReturn(TRUE); $container = new ContainerBuilder(); $container->set('cache_contexts_manager', $this->cacheContextsManager); diff --git a/core/modules/editor/src/Entity/Editor.php b/core/modules/editor/src/Entity/Editor.php index 159c9b1..0100671 100644 --- a/core/modules/editor/src/Entity/Editor.php +++ b/core/modules/editor/src/Entity/Editor.php @@ -107,7 +107,7 @@ public function calculateDependencies() { // config entity and dependency on provider is managed automatically. $definition = $this->editorPluginManager()->createInstance($this->editor)->getPluginDefinition(); $this->addDependency('module', $definition['provider']); - return $this->dependencies; + return $this; } /** diff --git a/core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php b/core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php index c5a676b..6750544 100644 --- a/core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php +++ b/core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php @@ -130,7 +130,7 @@ public function testCalculateDependencies() { ->with('filter_format') ->will($this->returnValue($storage)); - $dependencies = $entity->calculateDependencies(); + $dependencies = $entity->calculateDependencies()->getDependencies(); $this->assertContains('test_module', $dependencies['module']); $this->assertContains('filter.format.test', $dependencies['config']); } diff --git a/core/modules/field/src/Entity/FieldConfig.php b/core/modules/field/src/Entity/FieldConfig.php index 1493e41..e2ab409 100644 --- a/core/modules/field/src/Entity/FieldConfig.php +++ b/core/modules/field/src/Entity/FieldConfig.php @@ -187,7 +187,7 @@ public function calculateDependencies() { parent::calculateDependencies(); // Mark the field_storage_config as a a dependency. $this->addDependency('config', $this->getFieldStorageDefinition()->getConfigDependencyName()); - return $this->dependencies; + return $this; } /** diff --git a/core/modules/field/src/Entity/FieldStorageConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php index bd546a2..594fb3b 100644 --- a/core/modules/field/src/Entity/FieldStorageConfig.php +++ b/core/modules/field/src/Entity/FieldStorageConfig.php @@ -346,7 +346,7 @@ public function calculateDependencies() { // Ensure the field is dependent on the provider of the entity type. $entity_type = \Drupal::entityManager()->getDefinition($this->entity_type); $this->addDependency('module', $entity_type->getProvider()); - return $this->dependencies; + return $this; } /** diff --git a/core/modules/field/src/Tests/Number/NumberFieldTest.php b/core/modules/field/src/Tests/Number/NumberFieldTest.php index f80dfab..e4f104e 100644 --- a/core/modules/field/src/Tests/Number/NumberFieldTest.php +++ b/core/modules/field/src/Tests/Number/NumberFieldTest.php @@ -220,14 +220,6 @@ function testNumberIntegerField() { $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertRaw(t('%name must be lower than or equal to %maximum.', array('%name' => $field_name, '%maximum' => $maximum)), 'Correctly failed to save integer value greater than maximum allowed value.'); - // Try to set a wrong integer value. - $this->drupalGet('entity_test/add'); - $edit = array( - "{$field_name}[0][value]" => '20-40', - ); - $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertRaw(t('%name must be a number.', array('%name' => $field_name)), 'Correctly failed to save wrong integer value.'); - // Test with valid entries. $valid_entries = array( '-1234', diff --git a/core/modules/field/src/Tests/Number/NumberItemTest.php b/core/modules/field/src/Tests/Number/NumberItemTest.php index e7eac30..4390449 100644 --- a/core/modules/field/src/Tests/Number/NumberItemTest.php +++ b/core/modules/field/src/Tests/Number/NumberItemTest.php @@ -53,9 +53,6 @@ public function testNumberItem() { $entity->field_integer = $integer; $float = 3.14; $entity->field_float = $float; - $entity->field_decimal = '20-40'; - $violations = $entity->validate(); - $this->assertIdentical(1, count($violations), 'Wrong decimal value causes validation error'); $decimal = '31.3'; $entity->field_decimal = $decimal; $entity->name->value = $this->randomMachineName(); diff --git a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php index 72cfd76..4cf0065 100644 --- a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php +++ b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php @@ -153,7 +153,7 @@ public function testCalculateDependencies() { 'bundle' => 'test_bundle', 'field_type' => 'test_field', ), $this->entityTypeId); - $dependencies = $field->calculateDependencies(); + $dependencies = $field->calculateDependencies()->getDependencies(); $this->assertContains('field.storage.test_entity_type.test_field', $dependencies['config']); $this->assertContains('test.test_entity_type.id', $dependencies['config']); $this->assertEquals(['test_module', 'test_module2', 'test_module3'], $dependencies['module']); diff --git a/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php b/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php index 424424a..ab5fa75 100644 --- a/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php +++ b/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php @@ -93,7 +93,7 @@ public function testCalculateDependencies() { 'module' => 'test_module', )); - $dependencies = $field_storage->calculateDependencies(); + $dependencies = $field_storage->calculateDependencies()->getDependencies(); $this->assertContains('test_module', $dependencies['module']); $this->assertContains('entity_provider_module', $dependencies['module']); } diff --git a/core/modules/field_ui/src/Tests/EntityDisplayTest.php b/core/modules/field_ui/src/Tests/EntityDisplayTest.php index 0cafbb4..7c7a48b 100644 --- a/core/modules/field_ui/src/Tests/EntityDisplayTest.php +++ b/core/modules/field_ui/src/Tests/EntityDisplayTest.php @@ -109,7 +109,7 @@ public function testEntityDisplayCRUD() { $new_display = $display->createCopy('other_view_mode'); $new_display->save(); $new_display = entity_load('entity_view_display', $new_display->id()); - $dependencies = $new_display->calculateDependencies(); + $dependencies = $new_display->calculateDependencies()->getDependencies(); $this->assertEqual(array('config' => array('core.entity_view_mode.entity_test.other_view_mode'), 'module' => array('entity_test')), $dependencies); $this->assertEqual($new_display->getTargetEntityTypeId(), $display->getTargetEntityTypeId()); $this->assertEqual($new_display->getTargetBundle(), $display->getTargetBundle()); @@ -239,7 +239,7 @@ public function testFieldComponent() { // Check that the display has dependencies on the field and the module that // provides the formatter. - $dependencies = $display->calculateDependencies(); + $dependencies = $display->calculateDependencies()->getDependencies(); $this->assertEqual(array('config' => array('field.field.entity_test.entity_test.test_field'), 'module' => array('entity_test', 'field_test')), $dependencies); } diff --git a/core/modules/field_ui/src/Tests/ManageDisplayTest.php b/core/modules/field_ui/src/Tests/ManageDisplayTest.php index 10bf706..d51f4f3 100644 --- a/core/modules/field_ui/src/Tests/ManageDisplayTest.php +++ b/core/modules/field_ui/src/Tests/ManageDisplayTest.php @@ -142,7 +142,7 @@ function testFormatterUI() { \Drupal::entityManager()->clearCachedFieldDefinitions(); $display = entity_load('entity_view_display', 'node.' . $this->type . '.default', TRUE); $this->assertEqual($display->getRenderer('field_test')->getThirdPartySetting('field_third_party_test', 'field_test_field_formatter_third_party_settings_form'), 'foo'); - $this->assertTrue(in_array('field_third_party_test', $display->calculateDependencies()['module']), 'The display has a dependency on field_third_party_test module.'); + $this->assertTrue(in_array('field_third_party_test', $display->calculateDependencies()->getDependencies()['module']), 'The display has a dependency on field_third_party_test module.'); // Confirm that the third party settings are not updated on the settings form. $this->drupalPostAjaxForm(NULL, array(), "field_test_settings_edit"); @@ -268,7 +268,7 @@ public function testWidgetUI() { \Drupal::entityManager()->clearCachedFieldDefinitions(); $display = entity_load('entity_form_display', 'node.' . $this->type . '.default', TRUE); $this->assertEqual($display->getRenderer('field_test')->getThirdPartySetting('field_third_party_test', 'field_test_widget_third_party_settings_form'), 'foo'); - $this->assertTrue(in_array('field_third_party_test', $display->calculateDependencies()['module']), 'Form display does not have a dependency on field_third_party_test module.'); + $this->assertTrue(in_array('field_third_party_test', $display->calculateDependencies()->getDependencies()['module']), 'Form display does not have a dependency on field_third_party_test module.'); // Confirm that the third party settings are not updated on the settings form. $this->drupalPostAjaxForm(NULL, array(), "field_test_settings_edit"); diff --git a/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php b/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php index beab748..8cdc903 100644 --- a/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php +++ b/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php @@ -84,7 +84,7 @@ public function testViewsHandlerRelationshipUserFileData() { 'user', ], ]; - $this->assertIdentical($expected, $view->calculateDependencies()); + $this->assertIdentical($expected, $view->getDependencies()); $this->executeView($view); $expected_result = array( array( diff --git a/core/modules/forum/config/install/node.type.forum.yml b/core/modules/forum/config/install/node.type.forum.yml index b03afe0..8ed965d 100644 --- a/core/modules/forum/config/install/node.type.forum.yml +++ b/core/modules/forum/config/install/node.type.forum.yml @@ -1,8 +1,6 @@ langcode: en status: true dependencies: - module: - - forum enforced: module: - forum diff --git a/core/modules/forum/config/install/taxonomy.vocabulary.forums.yml b/core/modules/forum/config/install/taxonomy.vocabulary.forums.yml index 311f6fc..b5c51eb 100644 --- a/core/modules/forum/config/install/taxonomy.vocabulary.forums.yml +++ b/core/modules/forum/config/install/taxonomy.vocabulary.forums.yml @@ -1,8 +1,6 @@ langcode: en status: true dependencies: - module: - - forum enforced: module: - forum diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php index 3cb442a..f690e03 100644 --- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php +++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php @@ -27,7 +27,8 @@ public function setUp() { $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager') ->disableOriginalConstructor() ->getMock(); - $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE); + $cache_contexts_manager->expects($this->any()) + ->method('validate_tokens'); $container = new Container(); $container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($container); diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php index b591394..0d201ed 100644 --- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php +++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php @@ -28,7 +28,8 @@ public function setUp() { $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager') ->disableOriginalConstructor() ->getMock(); - $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE); + $cache_contexts_manager->expects($this->any()) + ->method('validate_tokens'); $container = new Container(); $container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($container); diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php index ba1c974..76851fd 100644 --- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php +++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php @@ -27,7 +27,8 @@ public function setUp() { $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager') ->disableOriginalConstructor() ->getMock(); - $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE); + $cache_contexts_manager->expects($this->any()) + ->method('validate_tokens'); $container = new Container(); $container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($container); diff --git a/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php b/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php index a36f287..4ef0626 100644 --- a/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php +++ b/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php @@ -84,7 +84,7 @@ public function testViewsHandlerRelationshipUserImageData() { 'user', ], ]; - $this->assertIdentical($expected, $view->calculateDependencies()); + $this->assertIdentical($expected, $view->getDependencies()); $this->executeView($view); $expected_result = array( array( diff --git a/core/modules/language/src/Entity/ContentLanguageSettings.php b/core/modules/language/src/Entity/ContentLanguageSettings.php index 7504998..7501012 100644 --- a/core/modules/language/src/Entity/ContentLanguageSettings.php +++ b/core/modules/language/src/Entity/ContentLanguageSettings.php @@ -200,7 +200,7 @@ public function calculateDependencies() { $bundle_config_dependency = $entity_type->getBundleConfigDependency($this->target_bundle); $this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']); - return $this->dependencies; + return $this; } } diff --git a/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php b/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php index 04ab81b..af73b75 100644 --- a/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php +++ b/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php @@ -102,7 +102,7 @@ public function testCalculateDependencies() { 'target_entity_type_id' => 'test_entity_type', 'target_bundle' => 'test_bundle', ), 'language_content_settings'); - $dependencies = $config->calculateDependencies(); + $dependencies = $config->calculateDependencies()->getDependencies(); $this->assertContains('test.test_entity_type.id', $dependencies['config']); } diff --git a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php index d0d946e..34abb61 100644 --- a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php +++ b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php @@ -60,7 +60,6 @@ protected function setUp() { $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager') ->disableOriginalConstructor() ->getMock(); - $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE); $container = new ContainerBuilder(); $container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($container); diff --git a/core/modules/migrate/src/Entity/Migration.php b/core/modules/migrate/src/Entity/Migration.php index b79a00d..0d7e3c8 100644 --- a/core/modules/migrate/src/Entity/Migration.php +++ b/core/modules/migrate/src/Entity/Migration.php @@ -590,6 +590,6 @@ public function calculateDependencies() { $this->addDependency('config', $this->getEntityType()->getConfigPrefix() . '.' . $dependency); } - return $this->dependencies; + return $this; } } diff --git a/core/modules/node/src/Tests/Views/FrontPageTest.php b/core/modules/node/src/Tests/Views/FrontPageTest.php index ba8438f..5cd78a8 100644 --- a/core/modules/node/src/Tests/Views/FrontPageTest.php +++ b/core/modules/node/src/Tests/Views/FrontPageTest.php @@ -73,7 +73,7 @@ public function testFrontPage() { 'user', ], ]; - $this->assertIdentical($expected, $view->calculateDependencies()); + $this->assertIdentical($expected, $view->getDependencies()); $view->setDisplay('page_1'); $this->executeView($view); diff --git a/core/modules/quickedit/tests/src/Unit/Access/EditEntityFieldAccessCheckTest.php b/core/modules/quickedit/tests/src/Unit/Access/EditEntityFieldAccessCheckTest.php index 5ac92aa..26a1c86 100644 --- a/core/modules/quickedit/tests/src/Unit/Access/EditEntityFieldAccessCheckTest.php +++ b/core/modules/quickedit/tests/src/Unit/Access/EditEntityFieldAccessCheckTest.php @@ -34,9 +34,7 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase { protected function setUp() { $this->editAccessCheck = new EditEntityFieldAccessCheck(); - $cache_contexts_manager = $this->prophesize(CacheContextsManager::class); - $cache_contexts_manager->assertValidTokens()->willReturn(TRUE); - $cache_contexts_manager->reveal(); + $cache_contexts_manager = $this->prophesize(CacheContextsManager::class)->reveal(); $container = new Container(); $container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($container); diff --git a/core/modules/rdf/src/Entity/RdfMapping.php b/core/modules/rdf/src/Entity/RdfMapping.php index c260f14..f561f15 100644 --- a/core/modules/rdf/src/Entity/RdfMapping.php +++ b/core/modules/rdf/src/Entity/RdfMapping.php @@ -148,7 +148,7 @@ public function calculateDependencies() { $bundle_config_dependency = $entity_type->getBundleConfigDependency($this->bundle); $this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']); - return $this->dependencies; + return $this; } /** diff --git a/core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php b/core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php index 4901d9c..a3198e9 100644 --- a/core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php +++ b/core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php @@ -92,7 +92,7 @@ public function testCalculateDependencies() { ->will($this->returnValue($this->entityType)); $entity = new RdfMapping($values, $this->entityTypeId); - $dependencies = $entity->calculateDependencies(); + $dependencies = $entity->calculateDependencies()->getDependencies(); $this->assertArrayNotHasKey('config', $dependencies); $this->assertContains('test_module', $dependencies['module']); } @@ -123,7 +123,7 @@ public function testCalculateDependenciesWithEntityBundle() { ->will($this->returnValue($this->entityType)); $entity = new RdfMapping($values, $this->entityTypeId); - $dependencies = $entity->calculateDependencies(); + $dependencies = $entity->calculateDependencies()->getDependencies(); $this->assertContains('test_module.type.' . $bundle_id, $dependencies['config']); $this->assertContains('test_module', $dependencies['module']); } diff --git a/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php b/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php index f585bc2..e82b57f 100644 --- a/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php +++ b/core/modules/responsive_image/src/Entity/ResponsiveImageStyle.php @@ -212,7 +212,7 @@ public function calculateDependencies() { array_walk($styles, function ($style) { $this->addDependency('config', $style->getConfigDependencyName()); }); - return $this->dependencies; + return $this; } /** diff --git a/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php b/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php index c916756..5e33a31 100644 --- a/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php +++ b/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php @@ -108,7 +108,7 @@ public function testCalculateDependencies() { ->with('test_group') ->willReturn(array('bartik' => 'theme', 'toolbar' => 'module')); - $dependencies = $entity->calculateDependencies(); + $dependencies = $entity->calculateDependencies()->getDependencies(); $this->assertEquals(['toolbar'], $dependencies['module']); $this->assertEquals(['bartik'], $dependencies['theme']); $this->assertEquals(['image.style.fallback', 'image.style.large', 'image.style.medium', 'image.style.small'], $dependencies['config']); diff --git a/core/modules/serialization/serialization.services.yml b/core/modules/serialization/serialization.services.yml index c510ab1..0eb4e23 100644 --- a/core/modules/serialization/serialization.services.yml +++ b/core/modules/serialization/serialization.services.yml @@ -24,10 +24,7 @@ services: serializer.normalizer.entity_reference_field_item: class: Drupal\serialization\Normalizer\EntityReferenceFieldItemNormalizer tags: - # Set the priority lower than the hal entity reference field item - # normalizer, so that we do not replace that for hal_json. - # @todo Find a better way for this in https://www.drupal.org/node/2575761. - - { name: normalizer, priority: 5 } + - { name: normalizer, priority: 10 } serializer.normalizer.list: class: Drupal\serialization\Normalizer\ListNormalizer tags: diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php index 7abfa2f..9bf67aa 100644 --- a/core/modules/simpletest/src/TestBase.php +++ b/core/modules/simpletest/src/TestBase.php @@ -969,10 +969,6 @@ public function run(array $methods = array()) { $this->httpAuthCredentials = $username . ':' . $password; } - // Force assertion failures to be thrown as AssertionError for PHP 5 & 7 - // compatibility. - \Drupal\Component\Assertion\Handle::register(); - set_error_handler(array($this, 'errorHandler')); // Iterate through all the methods in this class, unless a specific list of // methods to run was passed. diff --git a/core/modules/system/src/Tests/Action/ActionUnitTest.php b/core/modules/system/src/Tests/Action/ActionUnitTest.php index 164b562..7bc57b5 100644 --- a/core/modules/system/src/Tests/Action/ActionUnitTest.php +++ b/core/modules/system/src/Tests/Action/ActionUnitTest.php @@ -99,7 +99,7 @@ public function testDependencies() { 'user', ), ); - $this->assertIdentical($expected, $action->calculateDependencies()); + $this->assertIdentical($expected, $action->calculateDependencies()->getDependencies()); } } diff --git a/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php b/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php index a28b696..25e5dc1 100644 --- a/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php +++ b/core/modules/system/src/Tests/Block/SystemMenuBlockTest.php @@ -162,7 +162,7 @@ public function testSystemMenuBlockConfigDependencies() { 'theme' => 'stark', )); - $dependencies = $block->calculateDependencies(); + $dependencies = $block->calculateDependencies()->getDependencies(); $expected = array( 'config' => array( 'system.menu.' . $this->menu->id() diff --git a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php index 742bd46..cc0d9df 100644 --- a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php +++ b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php @@ -218,13 +218,13 @@ public function testSetGet() { $this->assertEqual('value', $backend->get('TEST8')->data); $this->assertFalse($backend->get('test8')); - // Calling ::set() with invalid cache tags. This should fail an assertion. + // Calling ::set() with invalid cache tags. try { - $backend->set('assertion_test', 'value', Cache::PERMANENT, ['node' => [3, 5, 7]]); - $this->fail('::set() was called with invalid cache tags, runtime assertion did not fail.'); + $backend->set('exception_test', 'value', Cache::PERMANENT, ['node' => [3, 5, 7]]); + $this->fail('::set() was called with invalid cache tags, no exception was thrown.'); } - catch (\AssertionError $e) { - $this->pass('::set() was called with invalid cache tags, runtime assertion failed.'); + catch (\LogicException $e) { + $this->pass('::set() was called with invalid cache tags, an exception was thrown.'); } } @@ -412,8 +412,7 @@ public function testSetMultiple() { $this->assertEqual($cached['cid_5']->data, $items['cid_5']['data'], 'New cache item set correctly.'); - // Calling ::setMultiple() with invalid cache tags. This should fail an - // assertion. + // Calling ::setMultiple() with invalid cache tags. try { $items = [ 'exception_test_1' => array('data' => 1, 'tags' => []), @@ -421,10 +420,10 @@ public function testSetMultiple() { 'exception_test_3' => array('data' => 3, 'tags' => ['node' => [3, 5, 7]]), ]; $backend->setMultiple($items); - $this->fail('::setMultiple() was called with invalid cache tags, runtime assertion did not fail.'); + $this->fail('::setMultiple() was called with invalid cache tags, no exception was thrown.'); } - catch (\AssertionError $e) { - $this->pass('::setMultiple() was called with invalid cache tags, runtime assertion failed.'); + catch (\LogicException $e) { + $this->pass('::setMultiple() was called with invalid cache tags, an exception was thrown.'); } } diff --git a/core/modules/system/src/Tests/Update/UpdatePathTestBaseFilledTest.php b/core/modules/system/src/Tests/Update/UpdatePathTestBaseFilledTest.php index 4ccc6e7..4dceb5d 100644 --- a/core/modules/system/src/Tests/Update/UpdatePathTestBaseFilledTest.php +++ b/core/modules/system/src/Tests/Update/UpdatePathTestBaseFilledTest.php @@ -8,6 +8,7 @@ namespace Drupal\system\Tests\Update; use Drupal\node\Entity\Node; +use Drupal\node\Entity\NodeType; use Drupal\user\Entity\User; /** @@ -415,6 +416,12 @@ public function testUpdatedSite() { foreach ($expected_enabled_themes as $theme) { $this->assertTrue($this->container->get('theme_handler')->themeExists($theme), 'The "' . $theme . '" is still enabled.'); } + + // Ensure that the Book module's node type does not have duplicated enforced + // dependencies. + // @see system_post_update_fix_enforced_dependencies() + $book_node_type = NodeType::load('book'); + $this->assertEqual(['enforced' => ['module' => ['book']]], $book_node_type->get('dependencies')); } /** diff --git a/core/modules/system/src/Tests/Update/UpdatePostUpdateTest.php b/core/modules/system/src/Tests/Update/UpdatePostUpdateTest.php index a295268..55420fa 100644 --- a/core/modules/system/src/Tests/Update/UpdatePostUpdateTest.php +++ b/core/modules/system/src/Tests/Update/UpdatePostUpdateTest.php @@ -62,6 +62,7 @@ public function testPostUpdate() { $updates = array_merge([ 'block_post_update_disable_blocks_with_missing_contexts', 'field_post_update_save_custom_storage_property', + 'system_post_update_fix_enforced_dependencies', 'views_post_update_update_cacheability_metadata', ], $updates); $this->assertEqual($updates, $key_value->get('existing_updates')); diff --git a/core/modules/system/system.post_update.php b/core/modules/system/system.post_update.php new file mode 100644 index 0000000..3a141ce --- /dev/null +++ b/core/modules/system/system.post_update.php @@ -0,0 +1,35 @@ +listAll() as $id) { + $config = $config_factory->get($id); + if ($config->get('dependencies.enforced') !== NULL) { + // Resave the configuration entity. + $entity = $config_manager->loadConfigEntityByName($id); + $entity->save(); + } + } + + return t('All configuration objects with enforced dependencies re-saved.'); +} + +/** + * @} End of "addtogroup updates-8.0.0-beta". + */ diff --git a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php index 64e61c7..bf106f6 100644 --- a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php +++ b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php @@ -124,7 +124,6 @@ protected function setUp() { $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager') ->disableOriginalConstructor() ->getMock(); - $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE); $cache_contexts_manager->expects($this->any()) ->method('validate_tokens'); $container = new Container(); diff --git a/core/modules/system/tests/src/Unit/Menu/MenuLinkTreeTest.php b/core/modules/system/tests/src/Unit/Menu/MenuLinkTreeTest.php index ac6af14..9faa03d 100644 --- a/core/modules/system/tests/src/Unit/Menu/MenuLinkTreeTest.php +++ b/core/modules/system/tests/src/Unit/Menu/MenuLinkTreeTest.php @@ -47,7 +47,6 @@ protected function setUp() { $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager') ->disableOriginalConstructor() ->getMock(); - $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE); $container = new ContainerBuilder(); $container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($container); diff --git a/core/modules/system/tests/themes/test_basetheme/config/install/core.date_format.fancy.yml b/core/modules/system/tests/themes/test_basetheme/config/install/core.date_format.fancy.yml index cdab205..2b962d6 100644 --- a/core/modules/system/tests/themes/test_basetheme/config/install/core.date_format.fancy.yml +++ b/core/modules/system/tests/themes/test_basetheme/config/install/core.date_format.fancy.yml @@ -8,8 +8,6 @@ langcode: en locked: false pattern: 'U' dependencies: - theme: - - test_basetheme enforced: theme: - test_basetheme diff --git a/core/modules/taxonomy/src/Tests/Views/RelationshipNodeTermDataTest.php b/core/modules/taxonomy/src/Tests/Views/RelationshipNodeTermDataTest.php index eed681f..68a2afb 100644 --- a/core/modules/taxonomy/src/Tests/Views/RelationshipNodeTermDataTest.php +++ b/core/modules/taxonomy/src/Tests/Views/RelationshipNodeTermDataTest.php @@ -34,7 +34,7 @@ function testViewsHandlerRelationshipNodeTermData() { 'user', ], ]; - $this->assertIdentical($expected, $view->calculateDependencies()); + $this->assertIdentical($expected, $view->getDependencies()); $this->executeView($view, array($this->term1->id(), $this->term2->id())); $expected_result = array( array( @@ -55,7 +55,7 @@ function testViewsHandlerRelationshipNodeTermData() { $view = Views::getView('test_taxonomy_node_term_data'); // Tests \Drupal\taxonomy\Plugin\views\relationship\NodeTermData::calculateDependencies(). $expected['config'][] = 'taxonomy.vocabulary.views_testing_tags'; - $this->assertIdentical($expected, $view->calculateDependencies()); + $this->assertIdentical($expected, $view->getDependencies()); $this->executeView($view, array($this->term1->id(), $this->term2->id())); $this->assertIdenticalResultset($view, $expected_result, $column_map); } diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php index 4ea9e32..c32f27c 100644 --- a/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php +++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php @@ -121,7 +121,7 @@ public function testFilterUI() { 'user', ], ]; - $this->assertIdentical($expected, $view->calculateDependencies()); + $this->assertIdentical($expected, $view->calculateDependencies()->getDependencies()); } /** diff --git a/core/modules/tour/src/Entity/Tour.php b/core/modules/tour/src/Entity/Tour.php index 72540e0..8a4576c 100644 --- a/core/modules/tour/src/Entity/Tour.php +++ b/core/modules/tour/src/Entity/Tour.php @@ -183,7 +183,7 @@ public function calculateDependencies() { } $this->addDependency('module', $this->module); - return $this->dependencies; + return $this; } } diff --git a/core/modules/tour/src/Tests/TourTest.php b/core/modules/tour/src/Tests/TourTest.php index d0acf45..7f656d3 100644 --- a/core/modules/tour/src/Tests/TourTest.php +++ b/core/modules/tour/src/Tests/TourTest.php @@ -143,7 +143,7 @@ public function testTourFunctionality() { // Ensure that a tour entity has the expected dependencies based on plugin // providers and the module named in the configuration entity. - $dependencies = $tour->calculateDependencies(); + $dependencies = $tour->calculateDependencies()->getDependencies(); $this->assertEqual($dependencies['module'], array('system', 'tour_test')); $this->drupalGet('tour-test-1'); diff --git a/core/modules/user/src/Tests/Views/AccessRoleTest.php b/core/modules/user/src/Tests/Views/AccessRoleTest.php index 6960bc5..043971a 100644 --- a/core/modules/user/src/Tests/Views/AccessRoleTest.php +++ b/core/modules/user/src/Tests/Views/AccessRoleTest.php @@ -44,7 +44,7 @@ function testAccessRole() { 'config' => ['user.role.' . $this->normalRole], 'module' => ['user'], ]; - $this->assertIdentical($expected, $view->calculateDependencies()); + $this->assertIdentical($expected, $view->calculateDependencies()->getDependencies()); $executable = Views::executableFactory()->get($view); $executable->setDisplay('page_1'); @@ -84,7 +84,7 @@ function testAccessRole() { 'config' => $roles, 'module' => ['user'], ]; - $this->assertIdentical($expected, $view->calculateDependencies()); + $this->assertIdentical($expected, $view->calculateDependencies()->getDependencies()); $this->drupalLogin($this->webUser); $this->drupalGet('test-role'); $this->assertResponse(403); diff --git a/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php b/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php index 7ad78ef..29b6247 100644 --- a/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php +++ b/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php @@ -42,9 +42,7 @@ protected function setUp() { parent::setUp(); $this->container = new ContainerBuilder(); - $cache_contexts_manager = $this->prophesize(CacheContextsManager::class); - $cache_contexts_manager->assertValidTokens()->willReturn(TRUE); - $cache_contexts_manager->reveal(); + $cache_contexts_manager = $this->prophesize(CacheContextsManager::class)->reveal(); $this->container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($this->container); diff --git a/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php b/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php index 26bd3a9..849cde5 100644 --- a/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php +++ b/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php @@ -64,9 +64,7 @@ class UserAccessControlHandlerTest extends UnitTestCase { public function setUp() { parent::setUp(); - $cache_contexts_manager = $this->prophesize(CacheContextsManager::class); - $cache_contexts_manager->assertValidTokens()->willReturn(TRUE); - $cache_contexts_manager->reveal(); + $cache_contexts_manager = $this->prophesize(CacheContextsManager::class)->reveal(); $container = new Container(); $container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($container); diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php index 775efdb..e2a3436 100644 --- a/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -286,7 +286,7 @@ public function calculateDependencies() { $this->calculatePluginDependencies($display); } - return $this->dependencies; + return $this; } /** diff --git a/core/modules/views/src/Tests/Entity/FilterEntityBundleTest.php b/core/modules/views/src/Tests/Entity/FilterEntityBundleTest.php index 9be30df..709dd37 100644 --- a/core/modules/views/src/Tests/Entity/FilterEntityBundleTest.php +++ b/core/modules/views/src/Tests/Entity/FilterEntityBundleTest.php @@ -84,7 +84,7 @@ public function testFilterEntity() { 'node' ], ]; - $this->assertIdentical($expected, $view->calculateDependencies()); + $this->assertIdentical($expected, $view->getDependencies()); $this->executeView($view); diff --git a/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php b/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php index e8a7c1b..5a3f359 100644 --- a/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php +++ b/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php @@ -83,9 +83,9 @@ protected function setUp() { } /** - * Tests the calculateDependencies method. + * Tests the getDependencies method. */ - public function testCalculateDependencies() { + public function testGetDependencies() { $expected = []; $expected['test_field_get_entity'] = [ 'module' => [ @@ -135,7 +135,7 @@ public function testCalculateDependencies() { foreach ($this::$testViews as $view_id) { $view = Views::getView($view_id); - $dependencies = $view->calculateDependencies(); + $dependencies = $view->getDependencies(); $this->assertEqual($expected[$view_id], $dependencies); $config = $this->config('views.view.' . $view_id); \Drupal::service('config.storage.staging')->write($view_id, $config->get()); diff --git a/core/modules/views/src/Tests/Handler/AreaEntityTest.php b/core/modules/views/src/Tests/Handler/AreaEntityTest.php index ff1f83f..434463b 100644 --- a/core/modules/views/src/Tests/Handler/AreaEntityTest.php +++ b/core/modules/views/src/Tests/Handler/AreaEntityTest.php @@ -191,7 +191,7 @@ public function doTestRender($entities) { public function doTestCalculateDependencies() { $view = View::load('test_entity_area'); - $dependencies = $view->calculateDependencies(); + $dependencies = $view->calculateDependencies()->getDependencies(); // Ensure that both config and content entity dependencies are calculated. $this->assertEqual([ 'config' => ['block.block.test_block'], diff --git a/core/modules/views/src/Tests/Handler/AreaViewTest.php b/core/modules/views/src/Tests/Handler/AreaViewTest.php index f228937..779b795 100644 --- a/core/modules/views/src/Tests/Handler/AreaViewTest.php +++ b/core/modules/views/src/Tests/Handler/AreaViewTest.php @@ -41,7 +41,7 @@ public function testViewArea() { $view = Views::getView('test_area_view'); // Tests \Drupal\views\Plugin\views\area\View::calculateDependencies(). - $this->assertIdentical(['config' => ['views.view.test_simple_argument']], $view->calculateDependencies()); + $this->assertIdentical(['config' => ['views.view.test_simple_argument']], $view->getDependencies()); $this->executeView($view); $output = $view->render(); diff --git a/core/modules/views/src/Tests/Plugin/BlockDependenciesTest.php b/core/modules/views/src/Tests/Plugin/BlockDependenciesTest.php index 71e278f..6a5064c 100644 --- a/core/modules/views/src/Tests/Plugin/BlockDependenciesTest.php +++ b/core/modules/views/src/Tests/Plugin/BlockDependenciesTest.php @@ -37,7 +37,7 @@ class BlockDependenciesTest extends ViewKernelTestBase { */ public function testExposedBlock() { $block = $this->createBlock('views_exposed_filter_block:test_exposed_block-page_1'); - $dependencies = $block->calculateDependencies(); + $dependencies = $block->calculateDependencies()->getDependencies(); $expected = array( 'config' => array('views.view.test_exposed_block'), 'module' => array('views'), @@ -53,7 +53,7 @@ public function testExposedBlock() { */ public function testViewsBlock() { $block = $this->createBlock('views_block:content_recent-block_1'); - $dependencies = $block->calculateDependencies(); + $dependencies = $block->calculateDependencies()->getDependencies(); $expected = array( 'config' => array('views.view.content_recent'), 'module' => array('views'), diff --git a/core/modules/views/src/Tests/Plugin/DisplayPageTest.php b/core/modules/views/src/Tests/Plugin/DisplayPageTest.php index 6fc4f14..d04d951 100644 --- a/core/modules/views/src/Tests/Plugin/DisplayPageTest.php +++ b/core/modules/views/src/Tests/Plugin/DisplayPageTest.php @@ -144,14 +144,14 @@ public function testMenuLinks() { */ public function testDependencies() { $view = Views::getView('test_page_display'); - $this->assertIdentical([], $view->calculateDependencies()); + $this->assertIdentical([], $view->getDependencies()); $view = Views::getView('test_page_display_route'); $expected = [ 'content' => ['StaticTest'], 'module' => ['views_test_data'], ]; - $this->assertIdentical($expected, $view->calculateDependencies()); + $this->assertIdentical($expected, $view->getDependencies()); $view = Views::getView('test_page_display_menu'); $expected = [ @@ -160,7 +160,7 @@ public function testDependencies() { 'system.menu.tools', ], ]; - $this->assertIdentical($expected, $view->calculateDependencies()); + $this->assertIdentical($expected, $view->getDependencies()); } } diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index d64bb28..d2d1fa5 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -2315,15 +2315,16 @@ public function hasFormElements() { } /** - * Calculates dependencies for the view. + * Gets dependencies for the view. * * @see \Drupal\views\Entity\View::calculateDependencies() + * @see \Drupal\views\Entity\View::getDependencies() * * @return array * An array of dependencies grouped by type (module, theme, entity). */ - public function calculateDependencies() { - return $this->storage->calculateDependencies(); + public function getDependencies() { + return $this->storage->calculateDependencies()->getDependencies(); } /** diff --git a/core/modules/views/templates/views-view-field.html.twig b/core/modules/views/templates/views-view-field.html.twig index 04a20ac..a058548 100644 --- a/core/modules/views/templates/views-view-field.html.twig +++ b/core/modules/views/templates/views-view-field.html.twig @@ -3,6 +3,10 @@ * @file * Default theme implementation for a single field in a view. * + * It is not actually used in default views, as this is registered as a theme + * function which has better performance. For single overrides, the template is + * perfectly okay. + * * Available variables: * - view: The view that the field belongs to. * - field: The field handler that can process the input. @@ -20,4 +24,4 @@ * @ingroup themeable */ #} -{{ output -}} +{{ output }} diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 30c92f3..dd1d196 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -133,6 +133,7 @@ function views_theme($existing, $type, $theme, $path) { // Default view themes $hooks['views_view_field'] = $base + array( 'variables' => array('view' => NULL, 'field' => NULL, 'row' => NULL), + 'function' => 'theme_views_view_field', ); $hooks['views_view_grouping'] = $base + array( 'variables' => array('view' => NULL, 'grouping' => NULL, 'grouping_level' => NULL, 'rows' => NULL, 'title' => NULL), diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 8990584..45499fb 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -209,6 +209,19 @@ function template_preprocess_views_view_grouping(&$variables) { } /** + * Display a single views field. + * + * Interesting bits of info: + * $field->field_alias says what the raw value in $row will be. Reach it like + * this: @code { $row->{$field->field_alias} @endcode + * + * @ingroup themeable + */ +function theme_views_view_field($variables) { + return $variables['output']; +} + +/** * Prepares variables for views field templates. * * Default template: views-view-field.html.twig. diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php index 8168bf2..75c5473 100644 --- a/core/modules/views_ui/src/ViewUI.php +++ b/core/modules/views_ui/src/ViewUI.php @@ -1206,6 +1206,8 @@ public function hasLinkTemplate($key) { * {@inheritdoc} */ public function calculateDependencies() { + $this->storage->calculateDependencies(); + return $this; } /** diff --git a/core/tests/Drupal/Tests/Component/Assertion/InspectorTest.php b/core/tests/Drupal/Tests/Component/Assertion/InspectorTest.php index 7c36bda..55b09d8 100644 --- a/core/tests/Drupal/Tests/Component/Assertion/InspectorTest.php +++ b/core/tests/Drupal/Tests/Component/Assertion/InspectorTest.php @@ -31,36 +31,12 @@ public function testAssertTraversable() { * Tests asserting all members are strings. * * @covers ::assertAllStrings - * @dataProvider providerTestAssertAllStrings */ - public function testAssertAllStrings($input, $expected) { - $this->assertSame($expected, Inspector::assertAllStrings($input)); - } - - public function providerTestAssertAllStrings() { - $data = [ - 'empty-array' => [[], TRUE], - 'array-with-strings' => [['foo', 'bar'], TRUE], - 'string' => ['foo', FALSE], - 'array-with-strings-with-colon' => [['foo', 'bar', 'llama:2001988', 'baz', 'llama:14031991'], TRUE], - - 'with-FALSE' => [[FALSE], FALSE], - 'with-TRUE' => [[TRUE], FALSE], - 'with-string-and-boolean' => [['foo', FALSE], FALSE], - 'with-NULL' => [[NULL], FALSE], - 'string-with-NULL' => [['foo', NULL], FALSE], - 'integer' => [[1337], FALSE], - 'string-and-integer' => [['foo', 1337], FALSE], - 'double' => [[3.14], FALSE], - 'string-and-double' => [['foo', 3.14], FALSE], - 'array' => [[[]], FALSE], - 'string-and-array' => [['foo', []], FALSE], - 'string-and-nested-array' => [['foo', ['bar']], FALSE], - 'object' => [[new \stdClass()], FALSE], - 'string-and-object' => [['foo', new StringObject()], FALSE], - ]; - - return $data; + public function testAssertAllStrings() { + $this->assertTrue(Inspector::assertAllStrings([])); + $this->assertTrue(Inspector::assertAllStrings(['foo', 'bar'])); + $this->assertFalse(Inspector::assertAllStrings('foo')); + $this->assertFalse(Inspector::assertAllStrings(['foo', new StringObject()])); } /** diff --git a/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php b/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php index 2c46a0b..ae5dadc 100644 --- a/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php +++ b/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php @@ -38,7 +38,6 @@ protected function setUp() { ->disableOriginalConstructor() ->getMock(); - $this->cacheContextsManager->method('assertValidTokens')->willReturn(TRUE); $container = new ContainerBuilder(); $container->set('cache_contexts_manager', $this->cacheContextsManager); \Drupal::setContainer($container); diff --git a/core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbManagerTest.php b/core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbManagerTest.php index fd5be62..a9f301d 100644 --- a/core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbManagerTest.php @@ -57,9 +57,7 @@ protected function setUp() { $this->breadcrumb = new Breadcrumb(); $this->container = new ContainerBuilder(); - $cache_contexts_manager = $this->prophesize(CacheContextsManager::class); - $cache_contexts_manager->assertValidTokens()->willReturn(TRUE); - $cache_contexts_manager->reveal(); + $cache_contexts_manager = $this->prophesize(CacheContextsManager::class)->reveal(); $this->container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($this->container); } diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php index 80f6756..a2daba7 100644 --- a/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/CacheTagsInvalidatorTest.php @@ -20,7 +20,8 @@ class CacheTagsInvalidatorTest extends UnitTestCase { /** * @covers ::invalidateTags * - * @expectedException \AssertionError + * @expectedException \LogicException + * @expectedExceptionMessage Cache tags must be strings, array given. */ public function testInvalidateTagsWithInvalidTags() { $cache_tags_invalidator = new CacheTagsInvalidator(); diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheTest.php index 6c30996..c2e61a1 100644 --- a/core/tests/Drupal/Tests/Core/Cache/CacheTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/CacheTest.php @@ -7,7 +7,6 @@ namespace Drupal\Tests\Core\Cache; -use Drupal\Component\Assertion\Inspector; use Drupal\Core\Cache\Cache; use Drupal\Tests\UnitTestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -60,7 +59,6 @@ public function testValidateTags(array $tags, $expected_exception_message) { $this->assertNull(Cache::validateTags($tags)); } - /** * Provides a list of pairs of cache tags arrays to be merged. * diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php index b73bec2..05b51aa 100644 --- a/core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php @@ -35,8 +35,6 @@ public function testMerge(CacheableMetadata $a, CacheableMetadata $b, CacheableM $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager') ->disableOriginalConstructor() ->getMock(); - $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE); - $container = new ContainerBuilder(); $container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($container); @@ -59,7 +57,6 @@ public function testAddCacheableDependency(CacheableMetadata $a, CacheableMetada $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager') ->disableOriginalConstructor() ->getMock(); - $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE); $container = new ContainerBuilder(); $container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($container); diff --git a/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php b/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php index 6b233aa..db8d7b7 100644 --- a/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php @@ -106,7 +106,8 @@ public function testConvertTokensToKeys() { /** * @covers ::convertTokensToKeys * - * @expectedException \AssertionError + * @expectedException \LogicException + * @expectedExceptionMessage "non-cache-context" is not a valid cache context ID. */ public function testInvalidContext() { $container = $this->getMockContainer(); diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php index fa1c006..feca9e9 100644 --- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php @@ -139,19 +139,19 @@ protected function setUp() { /** * @covers ::calculateDependencies + * @covers ::getDependencies */ public function testCalculateDependencies() { // Calculating dependencies will reset the dependencies array. $this->entity->set('dependencies', array('module' => array('node'))); - $this->assertEmpty($this->entity->calculateDependencies()); + $this->assertEmpty($this->entity->calculateDependencies()->getDependencies()); // Calculating dependencies will reset the dependencies array using enforced // dependencies. $this->entity->set('dependencies', array('module' => array('node'), 'enforced' => array('module' => 'views'))); - $dependencies = $this->entity->calculateDependencies(); + $dependencies = $this->entity->calculateDependencies()->getDependencies(); $this->assertContains('views', $dependencies['module']); $this->assertNotContains('node', $dependencies['module']); - $this->assertContains('views', $dependencies['enforced']['module']); } /** @@ -213,6 +213,7 @@ public function testAddDependency() { } /** + * @covers ::getDependencies * @covers ::calculateDependencies * * @dataProvider providerCalculateDependenciesWithPluginCollections @@ -244,7 +245,7 @@ public function testCalculateDependenciesWithPluginCollections($definition, $exp ->method('getPluginCollections') ->will($this->returnValue(array($pluginCollection))); - $this->assertEquals($expected_dependencies, $this->entity->calculateDependencies()); + $this->assertEquals($expected_dependencies, $this->entity->calculateDependencies()->getDependencies()); } /** @@ -289,6 +290,7 @@ public function providerCalculateDependenciesWithPluginCollections() { /** * @covers ::calculateDependencies + * @covers ::getDependencies * @covers ::onDependencyRemoval */ public function testCalculateDependenciesWithThirdPartySettings() { @@ -297,12 +299,12 @@ public function testCalculateDependenciesWithThirdPartySettings() { $this->entity->setThirdPartySetting('test_provider2', 'test', 'test'); $this->entity->setThirdPartySetting($this->provider, 'test', 'test'); - $this->assertEquals(array('test_provider', 'test_provider2'), $this->entity->calculateDependencies()['module']); + $this->assertEquals(array('test_provider', 'test_provider2'), $this->entity->calculateDependencies()->getDependencies()['module']); $changed = $this->entity->onDependencyRemoval(['module' => ['test_provider2']]); $this->assertTrue($changed, 'Calling onDependencyRemoval with an existing third party dependency provider returns TRUE.'); $changed = $this->entity->onDependencyRemoval(['module' => ['test_provider3']]); $this->assertFalse($changed, 'Calling onDependencyRemoval with a non-existing third party dependency provider returns FALSE.'); - $this->assertEquals(array('test_provider'), $this->entity->calculateDependencies()['module']); + $this->assertEquals(array('test_provider'), $this->entity->calculateDependencies()->getDependencies()['module']); } /** diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php index 67db134..1476f6f 100644 --- a/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php @@ -98,7 +98,7 @@ public function testCalculateDependencies() { ->setMethods(array('getFilterFormat')) ->getMock(); - $dependencies = $this->entity->calculateDependencies(); + $dependencies = $this->entity->calculateDependencies()->getDependencies(); $this->assertContains('test_module', $dependencies['module']); } diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php index e062cc9..b0b4c8c 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php @@ -35,9 +35,7 @@ class EntityCreateAccessCheckTest extends UnitTestCase { protected function setUp() { parent::setUp(); - $cache_contexts_manager = $this->prophesize(CacheContextsManager::class); - $cache_contexts_manager->assertValidTokens()->willReturn(TRUE); - $cache_contexts_manager->reveal(); + $cache_contexts_manager = $this->prophesize(CacheContextsManager::class)->reveal(); $container = new Container(); $container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($container); diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php index 3a21211..929ff00 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php @@ -518,8 +518,6 @@ public function testCacheContexts() { $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager') ->disableOriginalConstructor() ->getMock(); - $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE); - $container = new ContainerBuilder(); $container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($container); diff --git a/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php b/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php index 4511ece..a748c5b 100644 --- a/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php @@ -81,10 +81,7 @@ protected function setUp() { $this->defaultMenuTreeManipulators = new DefaultMenuLinkTreeManipulators($this->accessManager, $this->currentUser, $this->queryFactory); - $cache_contexts_manager = $this->prophesize(CacheContextsManager::class); - $cache_contexts_manager->assertValidTokens()->willReturn(TRUE); - $cache_contexts_manager->reveal(); - + $cache_contexts_manager = $this->prophesize(CacheContextsManager::class)->reveal(); $container = new Container(); $container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($container); diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php index c69dcf2..20c680c 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php @@ -488,10 +488,6 @@ protected function setupNullCacheabilityMetadataValidation() { $cache_context_manager = $this->prophesize(CacheContextsManager::class); - foreach ([NULL, ['user.permissions'], ['route'], ['route', 'context.example1'], ['context.example1', 'route'], ['context.example1', 'route', 'context.example2'], ['context.example1', 'context.example2', 'route'], ['context.example1', 'context.example2', 'route', 'user.permissions']] as $argument) { - $cache_context_manager->assertValidTokens($argument)->willReturn(TRUE); - } - $container->set('cache_contexts_manager', $cache_context_manager->reveal()); \Drupal::setContainer($container); } diff --git a/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php b/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php index 72e5893..e695c79 100644 --- a/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php +++ b/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php @@ -60,7 +60,6 @@ public function testMerge(BubbleableMetadata $a, CacheableMetadata $b, Bubbleabl $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager') ->disableOriginalConstructor() ->getMock(); - $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE); $container = new ContainerBuilder(); $container->set('cache_contexts_manager', $cache_contexts_manager); $container->set('renderer', $renderer); @@ -665,7 +664,6 @@ public function testAddCacheableDependency(BubbleableMetadata $a, $b, Bubbleable $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager') ->disableOriginalConstructor() ->getMock(); - $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE); $container = new ContainerBuilder(); $container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($container); diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php index 199d170..e903739 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php @@ -144,7 +144,6 @@ protected function setUp() { $this->cacheContextsManager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager') ->disableOriginalConstructor() ->getMock(); - $this->cacheContextsManager->method('assertValidTokens')->willReturn(TRUE); $current_user_role = &$this->currentUserRole; $this->cacheContextsManager->expects($this->any()) ->method('convertTokensToKeys') diff --git a/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php index 6d04fb7..9d0d148 100644 --- a/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php +++ b/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php @@ -145,9 +145,7 @@ public function roleAccessProvider() { * @dataProvider roleAccessProvider */ public function testRoleAccess($path, $grant_accounts, $deny_accounts) { - $cache_contexts_manager = $this->prophesize(CacheContextsManager::class); - $cache_contexts_manager->assertValidTokens()->willReturn(TRUE); - $cache_contexts_manager->reveal(); + $cache_contexts_manager = $this->prophesize(CacheContextsManager::class)->reveal(); $container = new Container(); $container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($container); diff --git a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php index 6607cb5..2e04b87 100644 --- a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php @@ -63,7 +63,6 @@ protected function setUp() { $cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager') ->disableOriginalConstructor() ->getMock(); - $cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE); $container = new ContainerBuilder(); $container->set('cache_contexts_manager', $cache_contexts_manager); \Drupal::setContainer($container);