diff --git a/core/includes/form.inc b/core/includes/form.inc index 306fcbf..76106ee 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -4379,12 +4379,12 @@ function form_validate_number(&$element, &$form_state) { // Ensure that the input is greater than the #min property, if set. if (isset($element['#min']) && $value < $element['#min']) { - form_error($element, t('%name must be higher than or equal to %min.', array('%name' => $name, '%min' => $element['#min']))); + form_error($element, t('%name must be higher or equal to %min.', array('%name' => $name, '%min' => $element['#min']))); } // Ensure that the input is less than the #max property, if set. if (isset($element['#max']) && $value > $element['#max']) { - form_error($element, t('%name must be lower than or equal to %max.', array('%name' => $name, '%max' => $element['#max']))); + form_error($element, t('%name must be below or equal to %max.', array('%name' => $name, '%max' => $element['#max']))); } if (isset($element['#step']) && strtolower($element['#step']) != 'any') { diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index b461342..2cbe4c2 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1686,39 +1686,152 @@ function install_check_localization_server($uri) { } /** - * Gets the core release version for localization. + * Gets the core release version and release alternatives for localization. * - * In case core has a development version we fall back to the latest stable - * release. e.g. 8.2-dev falls back to 8.1. 8.0-dev falls back to 7.0. Fallback + * In case core is a development version or the translation file for the release + * is not available, fall back to the latest stable release. For example, + * 8.2-dev might fall back to 8.1 and 8.0-dev might fall back to 7.0. Fallback * is required because the localization server only provides translation files * for stable releases. * + * @param string $version + * (optional) Version of core trying to find translation files for. + * * @return array - * Associative array containing 'core' and 'version' of the release. + * Array of release data. Each array element is an associative array with: + * - core: Core compatibility version (e.g., 8.x). + * - version: Release version (e.g., 8.1). */ -function install_get_localization_release() { - if (strpos(\Drupal::VERSION, 'dev')) { - list($version, ) = explode('-', \Drupal::VERSION); - list($major, $minor) = explode('.', $version); - - // Calculate the major and minor release numbers to fall back to. - // E.g. 8.0-dev falls back to 7.0 and 8.2-dev falls back to 8.1. - if ($minor == 0) { - $major--; +function install_get_localization_release($version = \Drupal::VERSION) { + $releases = array(); + $alternatives = array(); + + // The version string is broken up into: + // - major: Major version (e.g., "8"). + // - minor: Minor version (e.g., "0"). + // - extra: Extra version info (e.g., "alpha2"). + // - extra_text: The text part of "extra" (e.g., "alpha"). + // - extra_number: The number part of "extra" (e.g., "2"). + $info = _install_get_version_info($version); + + // Check if version is a regular stable release (no 'rc', 'beta', 'alhpa, + // 'dev', etc.) + if (!isset($info['extra_text'])) { + // First version alternative: the current version. + $alternatives[] = $version; + // Point-releases: previous minor release (e.g., 8.2 falls back to 8.1). + if ($info['minor'] > 0) { + $alternatives[]= $info['major'] . '.' . ($info['minor'] - 1); } + // Zero release: first release candidate (e.g., 8.0 falls back to 8.0-rc1). else { - $minor--; + $alternatives[] = $info['major'] . '.0-rc1'; } - $release = "$major.$minor"; } else { - $release = \Drupal::VERSION; + switch ($info['extra_text']) { + // Alpha release: current alpha or previous alpha release (e.g. 8.0-alpha2 + // falls back to 8.0-alpha1). + case 'alpha': + $alternatives[] = $version; + if ($info['extra_number'] > 1) { + $alternatives[] = $info['major'] . '.0-alpha' . ($info['extra_number'] - 1); + } + break; + + // Beta release: current beta or previous beta release (e.g. 8.0-beta2 + // falls back to 8.0-beta1) or first alpha release. + case 'beta': + $alternatives[] = $version; + if ($info['extra_number'] > 1) { + $alternatives[] = $info['major'] . '.0-beta' . ($info['extra_number'] - 1); + } + else { + $alternatives[] = $info['major'] . '.0-alpha2'; + } + break; + + // Dev release: the previous point release (e.g., 8.2-dev falls back to + // 8.1) or any unstable release (e.g., 8.0-dev falls back to 8.0-rc1, + // 8.0-beta1 or 8.0-alpha2) + case 'dev': + if ($info['minor'] >= 1) { + $alternatives[] = $info['major'] . '.' . ($info['minor'] - 1); + } + else { + $alternatives[] = $info['major'] . '.0-rc1'; + $alternatives[] = $info['major'] . '.0-beta1'; + $alternatives[] = $info['major'] . '.0-alpha2'; + } + break; + + // Release candidate: the current or previous release candidate (e.g., + // 8.0-rc2 falls back to 8.0-rc1) or the first beta release. + case 'rc': + $alternatives[] = $version; + if ($info['extra_number'] >= 2) { + $alternatives[] = $info['major'] . '.0-rc' . ($info['extra_number'] - 1); + } + else { + $alternatives[] = $info['major'] . '.0-beta1'; + } + break; + } } - return array( - 'core' => "$major.x", - 'version' => $release, - ); + // All releases may a fallback to the previous major release (e.g., 8.1 falls + // back to 7.0, 8.x-dev falls back to 7.0). This will probably only be used + // for early dev releases or languages with an inactive translation team. + $alternatives[] = $info['major'] - 1 . '.0'; + + foreach ($alternatives as $alternative) { + list($core) = explode('.', $alternative); + $releases[] = array( + 'core' => $core . '.x', + 'version' => $alternative, + ); + } + + return $releases; +} + +/** + * Extracts version information from a drupal core version string. + * + * @param string $version + * Version info string (e.g., 8.0, 8.1, 8.0-dev, 8.0-unstable1, 8.0-alpha2, + * 8.0-beta3, and 8.0-rc4). + * + * + * @return array + * Associative array of version info: + * - major: Major version (e.g., "8"). + * - minor: Minor version (e.g., "0"). + * - extra: Extra version info (e.g., "alpha2"). + * - extra_text: The text part of "extra" (e.g., "alpha"). + * - extra_number: The number part of "extra" (e.g., "2"). + */ +function _install_get_version_info($version) { + + $info = array(); + + preg_match('/ + ( + (?P[0-9]+) # Major release number. + \. # . + (?P[0-9]+) # Minor release number. + ) # + ( # + - # - separator for "extra" verion information. + (?P # + (?P[a-z]+) # Release extra text (e.g., "alpha"). + (?P[0-9]*) # Release extra number (no separator between text and number). + ) # + | # OR no "extra" information. + ) + /sx', $version, $matches); + + return $matches; } /** @@ -1863,7 +1976,7 @@ function install_import_translations(&$install_state) { language_delete('en'); // Set up a batch to import translations for the newly added language. - _install_prepare_import(); + _install_prepare_import($langcode); module_load_include('fetch.inc', 'locale'); if ($batch = locale_translation_batch_fetch_build(array(), array($langcode))) { return $batch; @@ -1873,23 +1986,41 @@ function install_import_translations(&$install_state) { /** * Tells the translation import process that Drupal core is installed. + * + * @param string $langcode + * Language code used for the translation. */ -function _install_prepare_import() { +function _install_prepare_import($langcode) { + $matches = array(); global $install_state; - $release = install_get_localization_release(); - db_insert('locale_project') - ->fields(array( - 'name' => 'drupal', - 'project_type' => 'module', - 'core' => $release['core'], - 'version' => $release['version'], - 'server_pattern' => $install_state['server_pattern'], - 'status' => 1, - )) - ->execute(); - module_load_include('compare.inc', 'locale'); - locale_translation_check_projects_local(array('drupal'), array($install_state['parameters']['langcode'])); + // Get the translation files located in the translations directory. + $files = locale_translate_get_interface_translation_files(array('drupal'), array($langcode)); + // We pick the first file which matches the installation language. + $file = reset($files); + $filename = $file->filename; + preg_match('/drupal-([0-9a-z\.-]+)\.' . $langcode . '\.po/', $filename, $matches); + // Get the version information. + if ($version = $matches[1]) { + $info = _install_get_version_info($version); + // Picking the first file does not necessarily result in the right file. So + // we check if at least the major version number is available. + if ($info['major']) { + $core = $info['major'] . '.x'; + db_insert('locale_project') + ->fields(array( + 'name' => 'drupal', + 'project_type' => 'module', + 'core' => $core, + 'version' => $version, + 'server_pattern' => $install_state['server_pattern'], + 'status' => 1, + )) + ->execute(); + module_load_include('compare.inc', 'locale'); + locale_translation_check_projects_local(array('drupal'), array($install_state['parameters']['langcode'])); + } + } } /** @@ -2063,6 +2194,7 @@ function install_check_translations($install_state) { $files_directory = conf_path() . '/files'; $translations_directory = conf_path() . '/files/translations'; $translations_directory_exists = FALSE; + $translation_available = FALSE; $online = FALSE; // First attempt to create or make writable the files directory. @@ -2078,28 +2210,35 @@ function install_check_translations($install_state) { } // Build URLs for the translation file and the translation server. - $release = install_get_localization_release(); + $releases = install_get_localization_release(); $langcode = $install_state['parameters']['langcode']; - $variables = array( - '%project' => 'drupal', - '%version' => $release['version'], - '%core' => $release['core'], - '%language' => $langcode, - ); - $translation_url = strtr($install_state['server_pattern'], $variables); - $elements = parse_url($translation_url); + $translation_urls = array(); + foreach ($releases as $release) { + $variables = array( + '%project' => 'drupal', + '%version' => $release['version'], + '%core' => $release['core'], + '%language' => $langcode, + ); + $translation_urls[] = strtr($install_state['server_pattern'], $variables); + } + $elements = parse_url(reset($translation_urls)); $server_url = $elements['scheme'] . '://' . $elements['host']; // Build the language name for display. $languages = LanguageManager::getStandardLanguageList(); $language = isset($languages[$langcode]) ? $languages[$langcode][0] : $langcode; - // Check if the desirered translation file is available and if the translation - // server can be reached, or in other words if we have an internet connection. - if ($translation_available = install_check_localization_server($translation_url)) { - $online = TRUE; + // Check if any of the desired translation files are available or if the + // translation server can be reached. In other words, check if we are online + // and have an internet connection. + foreach ($translation_urls as $translation_url) { + if ($translation_available = install_check_localization_server($translation_url)) { + $online = TRUE; + break; + } } - else { + if (!$translation_available) { if (install_check_localization_server($server_url)) { $online = TRUE; } diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php b/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php index f0d7b45..3a6474a 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php @@ -17,7 +17,7 @@ * @param array $args * An associative array of replacements to make after translation. Based * on the first character of the key, the value is escaped and/or themed. - * See \Drupal\Component\Utility\String::format() for details. + * See \Drupal\Core\Utility\String::format() for details. * @param array $options * An associative array of additional options, with the following elements: * - 'langcode': The language code to translate to a language other than @@ -27,7 +27,7 @@ * @return string * The translated string. * - * @see \Drupal\Component\Utility\String::format() + * @see \Drupal\Core\Utility\String::format() */ public function translate($string, array $args = array(), array $options = array()); diff --git a/core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php b/core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php index 42fd0c3..3e162b1 100644 --- a/core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php +++ b/core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php @@ -59,6 +59,10 @@ protected function loadLanguage($langcode) { /** * Finds installer translations either for a specific or all languages. * + * Filenames must match the pattern: + * - 'drupal-[number].*.[langcode].po + * - 'drupal-[number].*.*.po + * * @param string $langcode * (optional) The language code corresponding to the language for which we * want to find translation files. If omitted, information on all available @@ -71,7 +75,7 @@ protected function loadLanguage($langcode) { * @see file_scan_directory() */ public function findTranslationFiles($langcode = NULL) { - $files = file_scan_directory($this->directory, '!drupal-\d+\.\d+\.' . (!empty($langcode) ? preg_quote($langcode, '!') : '[^\.]+') . '\.po$!', array('recurse' => FALSE)); + $files = file_scan_directory($this->directory, '!drupal-\d+\.[^\.]+\.' . (!empty($langcode) ? preg_quote($langcode, '!') : '[^\.]+') . '\.po$!', array('recurse' => FALSE)); return $files; } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php index 12236c2..2f376d9 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Entity/CustomBlock.php @@ -266,7 +266,7 @@ public static function baseFieldDefinitions($entity_type) { ); $properties['langcode'] = array( 'label' => t('Language code'), - 'description' => t('The custom block language code.'), + 'description' => t('The comment language code.'), 'type' => 'language_field', ); $properties['info'] = array( @@ -288,9 +288,6 @@ public static function baseFieldDefinitions($entity_type) { 'label' => t('Changed'), 'description' => t('The time that the custom block was last edited.'), 'type' => 'integer_field', - 'property_constraints' => array( - 'value' => array('EntityChanged' => array()), - ), ); return $properties; } diff --git a/core/modules/field/field.install b/core/modules/field/field.install index 5f70ee1..cf7dd11 100644 --- a/core/modules/field/field.install +++ b/core/modules/field/field.install @@ -194,38 +194,35 @@ function field_update_8002() { continue; } - // Do not place deleted fields in entity displays. - if (empty($record->deleted)) { - // Migrate 'widget' settings. - if (isset($data['widget'])) { - $widget_options = $data['widget']; - // Determine name and create initial entry in the $form_displays array. - $form_display_id = $record->entity_type . '.' . $record->bundle . '.default'; - if (!isset($form_displays[$form_display_id])) { - $form_displays[$form_display_id] = _update_8000_entity_get_form_display($record->entity_type, $record->bundle, 'default'); - } - - // We do not need the 'module' key anymore. - unset($widget_options['module']); - $form_displays[$form_display_id]->set("content.$record->field_name", $widget_options); + // Migrate 'widget' settings. + if (isset($data['widget'])) { + $widget_options = $data['widget']; + // Determine name and create initial entry in the $form_displays array. + $form_display_id = $record->entity_type . '.' . $record->bundle . '.default'; + if (!isset($form_displays[$form_display_id])) { + $form_displays[$form_display_id] = _update_8000_entity_get_form_display($record->entity_type, $record->bundle, 'default'); } - // Migrate 'display' settings. - if (isset($data['display'])) { - foreach ($data['display'] as $view_mode => $display_options) { - // Determine name and create initial entry in the $displays array if it - // does not exist yet. - $display_id = $record->entity_type . '.' . $record->bundle . '.' . $view_mode; - if (!isset($displays[$display_id])) { - $displays[$display_id] = _update_8000_entity_get_display($record->entity_type, $record->bundle, $view_mode); - } + // We do not need the 'module' key anymore. + unset($widget_options['module']); + $form_displays[$form_display_id]->set("content.$record->field_name", $widget_options); + } - // The display object does not store hidden fields. - if ($display_options['type'] != 'hidden') { - // We do not need the 'module' key anymore. - unset($display_options['module']); - $displays[$display_id]->set("content.$record->field_name", $display_options); - } + // Migrate 'display' settings. + if (isset($data['display'])) { + foreach ($data['display'] as $view_mode => $display_options) { + // Determine name and create initial entry in the $displays array if it + // does not exist yet. + $display_id = $record->entity_type . '.' . $record->bundle . '.' . $view_mode; + if (!isset($displays[$display_id])) { + $displays[$display_id] = _update_8000_entity_get_display($record->entity_type, $record->bundle, $view_mode); + } + + // The display object does not store hidden fields. + if ($display_options['type'] != 'hidden') { + // We do not need the 'module' key anymore. + unset($display_options['module']); + $displays[$display_id]->set("content.$record->field_name", $display_options); } } } diff --git a/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php b/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php index 2ee23f4..5de9a76 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php +++ b/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileItem.php @@ -50,6 +50,16 @@ class FileItem extends EntityReferenceItem implements ConfigFieldItemInterface { /** * {@inheritdoc} */ + public function getInstance() { + if (!isset($this->instance) && $parent = $this->getParent()) { + $this->instance = $parent->getInstance(); + } + return $this->instance; + } + + /** + * {@inheritdoc} + */ public static function schema(FieldInterface $field) { return array( 'columns' => array( diff --git a/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php b/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php index bf37009..b94cee0 100644 --- a/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php +++ b/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php @@ -8,6 +8,7 @@ use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\Context\ContextInterface; +use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\KeyValueStore\KeyValueStoreInterface; use Drupal\search\SearchPluginManager; @@ -36,7 +37,7 @@ class SearchSettingsForm extends ConfigFormBase { /** * The module handler. * - * @var \Drupal\Core\Extension\ModuleHandlerInterface + * @var \Drupal\Core\Extension\ModuleHandler */ protected $moduleHandler; diff --git a/core/modules/serialization/tests/Drupal/serialization/Tests/Encoder/JsonEncoderTest.php b/core/modules/serialization/tests/Drupal/serialization/Tests/Encoder/JsonEncoderTest.php deleted file mode 100644 index f4dcc1b..0000000 --- a/core/modules/serialization/tests/Drupal/serialization/Tests/Encoder/JsonEncoderTest.php +++ /dev/null @@ -1,39 +0,0 @@ - 'JsonEncoderTest', - 'description' => 'Tests the JsonEncoder class.', - 'group' => 'Serialization', - ); - } - - /** - * Tests the supportsEncoding() method. - */ - public function testSupportsEncoding() { - $encoder = new JsonEncoder(); - - $this->assertTrue($encoder->supportsEncoding('json')); - $this->assertTrue($encoder->supportsEncoding('ajax')); - $this->assertFalse($encoder->supportsEncoding('xml')); - } - -} diff --git a/core/modules/serialization/tests/Drupal/serialization/Tests/Normalizer/ListNormalizerTest.php b/core/modules/serialization/tests/Drupal/serialization/Tests/Normalizer/ListNormalizerTest.php deleted file mode 100644 index 399d8c1..0000000 --- a/core/modules/serialization/tests/Drupal/serialization/Tests/Normalizer/ListNormalizerTest.php +++ /dev/null @@ -1,105 +0,0 @@ - 'TypedDataNormalizer', - 'description' => 'Tests the TypedDataNormalizer class.', - 'group' => 'Serialization', - ); - } - - public function setUp() { - $typed_data = $this->getMock('Drupal\Core\TypedData\TypedDataInterface'); - $typed_data_manager = $this->getMockBuilder('Drupal\Core\TypedData\TypedDataManager') - ->disableOriginalConstructor() - ->setMethods(array('getPropertyInstance')) - ->getMock(); - $typed_data_manager->expects($this->any()) - ->method('getPropertyInstance') - ->will($this->returnValue($typed_data)); - - $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder') - ->setMethods(array('get')) - ->getMock(); - $container->expects($this->any()) - ->method('get') - ->with($this->equalTo('typed_data')) - ->will($this->returnValue($typed_data_manager)); - - \Drupal::setContainer($container); - - $this->normalizer = new ListNormalizer(); - - $this->list = new ItemList(array()); - $this->list->setValue($this->expectedListValues); - } - - /** - * Tests the supportsNormalization() method. - */ - public function testSupportsNormalization() { - $this->assertTrue($this->normalizer->supportsNormalization($this->list)); - $this->assertFalse($this->normalizer->supportsNormalization(new \stdClass())); - } - - /** - * Tests the normalize() method. - */ - public function testNormalize() { - $serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer') - ->setMethods(array('normalize')) - ->getMock(); - $serializer->expects($this->exactly(3)) - ->method('normalize') - ->will($this->returnValue('test')); - - $this->normalizer->setSerializer($serializer); - - $normalized = $this->normalizer->normalize($this->list); - - $this->assertEquals($this->expectedListValues, $normalized); - } - -} diff --git a/core/modules/serialization/tests/Drupal/serialization/Tests/Normalizer/TypedDataNormalizerTest.php b/core/modules/serialization/tests/Drupal/serialization/Tests/Normalizer/TypedDataNormalizerTest.php deleted file mode 100644 index 3e1dafd..0000000 --- a/core/modules/serialization/tests/Drupal/serialization/Tests/Normalizer/TypedDataNormalizerTest.php +++ /dev/null @@ -1,69 +0,0 @@ - 'TypedDataNormalizer', - 'description' => 'Tests the TypedDataNormalizer class.', - 'group' => 'Serialization', - ); - } - - public function setUp() { - $this->normalizer = new TypedDataNormalizer(); - $this->typedData = $this->getMock('Drupal\Core\TypedData\TypedDataInterface'); - } - - /** - * Tests the supportsNormalization() method. - */ - public function testSupportsNormalization() { - $this->assertTrue($this->normalizer->supportsNormalization($this->typedData)); - // Also test that an object not implementing TypedDataInterface fails. - $this->assertFalse($this->normalizer->supportsNormalization(new \stdClass())); - } - - /** - * Tests the normalize() method. - */ - public function testNormalize() { - $this->typedData->expects($this->once()) - ->method('getValue') - ->will($this->returnValue('test')); - - $this->assertEquals('test', $this->normalizer->normalize($this->typedData)); - } - -} diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php index 951d7c0..0f5609b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php @@ -374,8 +374,8 @@ function testNumber() { // Array with all the error messages to be checked. $error_messages = array( 'no_number' => '%name must be a number.', - 'too_low' => '%name must be higher than or equal to %min.', - 'too_high' => '%name must be lower than or equal to %max.', + 'too_low' => '%name must be higher or equal to %min.', + 'too_high' => '%name must be below or equal to %max.', 'step_mismatch' => '%name is not a valid number.', ); diff --git a/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerTranslationVersionUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerTranslationVersionUnitTest.php new file mode 100644 index 0000000..237ce23 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerTranslationVersionUnitTest.php @@ -0,0 +1,122 @@ + 'Installer translation version fallback', + 'description' => 'Tests the translation version fallback used during site installation to determine available translation files.', + 'group' => 'Installer', + ); + } + + protected function setUp() { + parent::setUp(); + require_once DRUPAL_ROOT . '/core/includes/install.core.inc'; + } + + /** + * Asserts version fallback results of install_get_localization_release(). + * + * @param $version + * Version string for which to determine version fallbacks. + * @param $fallback + * Array of fallback versions ordered for most to least significant. + * @param string $message + * (optional) A message to display with the assertion. + * @param string $group + * (optional) The group this message is in. + * + * @return bool + * TRUE if the assertion succeeded, FALSE otherwise. + */ + protected function assertVersionFallback($version, $fallback, $message = '', $group = 'Other') { + $equal = TRUE; + $results = install_get_localization_release($version); + // Check the calculated results with the required results. + // The $results is an array of arrays, each containing: + // 'version': A release version (e.g. 8.0) + // 'core' : The matching core version (e.g. 8.x) + if (count($fallback) == count($results)) { + foreach($results as $key => $result) { + $equal &= $result['version'] == $fallback[$key]; + list($major_release) = explode('.', $fallback[$key]); + $equal &= $result['core'] == $major_release . '.x'; + } + } + else { + $equal = FALSE; + } + $message = $message ? $message : t('Version fallback for @version.', array('@version' => $version)); + return $this->assert((bool) $equal, $message, $group); + } + + /** + * Tests version fallback of install_get_localization_release(). + */ + public function testVersionFallback() { + $version = '8.0'; + $fallback = array('8.0', '8.0-rc1', '7.0'); + $this->assertVersionFallback($version, $fallback); + + $version = '8.1'; + $fallback = array('8.1', '8.0', '7.0'); + $this->assertVersionFallback($version, $fallback); + + $version = '8.12'; + $fallback = array('8.12', '8.11', '7.0'); + $this->assertVersionFallback($version, $fallback); + + $version = '8.0-dev'; + $fallback = array('8.0-rc1', '8.0-beta1', '8.0-alpha2', '7.0'); + $this->assertVersionFallback($version, $fallback); + + $version = '8.9-dev'; + $fallback = array('8.8', '7.0'); + $this->assertVersionFallback($version, $fallback); + + $version = '8.0-alpha3'; + $fallback = array('8.0-alpha3', '8.0-alpha2', '7.0'); + $this->assertVersionFallback($version, $fallback); + + $version = '8.0-alpha1'; + $fallback = array('8.0-alpha1', '7.0'); + $this->assertVersionFallback($version, $fallback); + + $version = '8.0-beta2'; + $fallback = array('8.0-beta2', '8.0-beta1', '7.0'); + $this->assertVersionFallback($version, $fallback); + + $version = '8.0-beta1'; + $fallback = array('8.0-beta1', '8.0-alpha2', '7.0'); + $this->assertVersionFallback($version, $fallback); + + $version = '8.0-rc8'; + $fallback = array('8.0-rc8', '8.0-rc7', '7.0'); + $this->assertVersionFallback($version, $fallback); + + $version = '8.0-rc1'; + $fallback = array('8.0-rc1', '8.0-beta1', '7.0'); + $this->assertVersionFallback($version, $fallback); + + $version = '8.0-foo2'; + $fallback = array('7.0'); + $this->assertVersionFallback($version, $fallback); + + $version = '99.2'; + $fallback = array('99.2', '99.1', '98.0'); + $this->assertVersionFallback($version, $fallback); + } +} \ No newline at end of file diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/FieldUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/FieldUpgradePathTest.php index d615512..100dc85 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/FieldUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/FieldUpgradePathTest.php @@ -69,10 +69,6 @@ public function testEntityDisplayUpgrade() { $body_instance = field_info_instance('node', 'body', 'article'); $this->assertTrue(!isset($body_instance['display'])); - // Check that deleted fields were not added to the display. - $this->assertFalse(isset($displays['default']['content']['test_deleted_field'])); - $this->assertFalse(isset($displays['teaser']['content']['test_deleted_field'])); - // Check that the 'language' extra field is configured as expected. $expected = array( 'default' => array( @@ -112,9 +108,6 @@ public function testEntityFormDisplayUpgrade() { $body_instance = field_info_instance('node', 'body', 'article'); $this->assertTrue(!isset($body_instance['widget'])); - // Check that deleted fields were not added to the display. - $this->assertFalse(isset($form_display['content']['test_deleted_field'])); - // Check that the 'title' extra field is configured as expected. $expected = array( 'weight' => -5, diff --git a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php index a3e7b8c..b9c7a4e 100644 --- a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php +++ b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php @@ -169,9 +169,7 @@ public function testRandomStringValidator() { * TRUE if the random string is valid, FALSE if not. */ public function _RandomStringValidate($string) { - // Return FALSE for the first generated string and any string that is the - // same, as the test expects a different string to be returned. - if (empty($this->firstStringGenerated) || $string == $this->firstStringGenerated) { + if (empty($this->firstStringGenerated)) { $this->firstStringGenerated = $string; return FALSE; }