public function testLocaleUpdateDevelopmentRelease() { $projects = locale_translation_build_projects(); $this->verbose($projects['drupal']->info['version']); $this->assertEqual($projects['drupal']->info['version'], '8.0.x', 'The branch of the core dev release.'); $this->verbose($projects['contrib']->info['version']); $this->assertEqual($projects['contrib']->info['version'], '12.x-10.x', 'The branch of the contrib module dev release.'); }
public function testLocaleUpdateNotDevelopmentRelease() { // Set available Drupal releases for test. $available = array('title' => 'Drupal core', 'short_name' => 'drupal', 'type' => 'project_core', 'api_version' => '8.x', 'project_status' => 'unsupported', 'link' => 'https://www.drupal.org/project/drupal', 'terms' => '', 'releases' => array('8.0.0-alpha110' => array('name' => 'drupal 8.0.0-alpha110', 'version' => '8.0.0-alpha110', 'tag' => '8.0.0-alpha110', 'version_major' => '8', 'version_minor' => '0', 'version_patch' => '0', 'version_extra' => 'alpha110', 'status' => 'published', 'release_link' => 'https://www.drupal.org/node/2316617', 'download_link' => 'http://ftp.drupal.org/files/projects/drupal-8.0.0-alpha110.tar.gz', 'date' => '1407344628', 'mdhash' => '9d71afdd0ce541f2ff5ca2fbbca00df7', 'filesize' => '9172832', 'files' => '', 'terms' => array()), '8.0.0-alpha100' => array('name' => 'drupal 8.0.0-alpha100', 'version' => '8.0.0-alpha100', 'tag' => '8.0.0-alpha100', 'version_major' => '8', 'version_minor' => '0', 'version_patch' => '0', 'version_extra' => 'alpha100', 'status' => 'published', 'release_link' => 'https://www.drupal.org/node/2316617', 'download_link' => 'http://ftp.drupal.org/files/projects/drupal-8.0.0-alpha100.tar.gz', 'date' => '1407344628', 'mdhash' => '9d71afdd0ce541f2ff5ca2fbbca00df7', 'filesize' => '9172832', 'files' => '', 'terms' => array()))); $available['last_fetch'] = REQUEST_TIME; \Drupal::keyValueExpirable('update_available_releases')->setWithExpire('drupal', $available, 10); $projects = locale_translation_build_projects(); $this->verbose($projects['drupal']->info['version']); $this->assertEqual($projects['drupal']->info['version'], '8.0.0-alpha110', 'The first release with the same major release number which is not a development release.'); }
protected function displayUpdates($language_filter, $output, $table) { $table->setHeaders([$this->trans('commands.locale.translation.status.messages.project'), $this->trans('commands.locale.translation.status.messages.version'), $this->trans('commands.locale.translation.status.messages.local-age'), $this->trans('commands.locale.translation.status.messages.remote-age'), $this->trans('commands.locale.translation.status.messages.info')]); $languages = locale_translatable_language_list(); $status = locale_translation_get_status(); $this->getModuleHandler()->loadInclude('locale', 'compare.inc'); $project_data = locale_translation_build_projects(); if (!$languages) { $output->writeln('[+] <info>' . $this->trans('commands.locale.translation.status.messages.no-languages') . '</info>'); return; } elseif (empty($status)) { $output->writeln('[+] <info>' . $this->trans('commands.locale.translation.status.messages.no-translations') . '</info>'); return; } if ($languages && $status) { $table->setlayout($table::LAYOUT_COMPACT); $status_report = []; foreach ($status as $project_id => $project) { foreach ($project as $langcode => $project_info) { $info = $this->createInfoString($project_info); if ($project_info->type == LOCALE_TRANSLATION_LOCAL || $project_info->type == LOCALE_TRANSLATION_REMOTE) { $local = isset($project_info->files[LOCALE_TRANSLATION_LOCAL]) ? $project_info->files[LOCALE_TRANSLATION_LOCAL] : null; $remote = isset($project_info->files[LOCALE_TRANSLATION_REMOTE]) ? $project_info->files[LOCALE_TRANSLATION_REMOTE] : null; // Remove info because type was found $info = ''; } $local_age = $local->timestamp ? \Drupal::service('date.formatter')->formatTimeDiffSince($local->timestamp) : ''; $remote_age = $remote->timestamp ? \Drupal::service('date.formatter')->formatTimeDiffSince($remote->timestamp) : ''; $project_name = $project_info->name == 'drupal' ? $this->trans('commands.common.messages.drupal-core') : $project_data[$project_info->name]->info['name']; $status_report[$langcode][] = [$project_name, $project_info->version, $local_age, $remote_age, $info]; } } print $language_filter; foreach ($status_report as $langcode => $rows) { if ($language_filter != '' and !($language_filter == $langcode || strtolower($language_filter) == strtolower($languages[$langcode]->getName()))) { continue; } $output->writeln('[+] <info>' . $languages[$langcode]->getName() . '</info>'); foreach ($rows as $row) { $table->addRow($row); } } } $table->render($output); }
/** * Prepare information about projects with available translation updates. * * @param array $status * Translation update status as an array keyed by Project ID and langcode. * * @return array * Translation update status as an array keyed by language code and * translation update status. */ protected function prepareUpdateData(array $status) { $updates = array(); // @todo Calling locale_translation_build_projects() is an expensive way to // get a module name. In follow-up issue // https://www.drupal.org/node/1842362 the project name will be stored to // display use, like here. $this->moduleHandler->loadInclude('locale', 'compare.inc'); $project_data = locale_translation_build_projects(); foreach ($status as $project_id => $project) { foreach ($project as $langcode => $project_info) { // No translation file found for this project-language combination. if (empty($project_info->type)) { $updates[$langcode]['not_found'][] = array('name' => $project_info->name == 'drupal' ? $this->t('Drupal core') : $project_data[$project_info->name]->info['name'], 'version' => $project_info->version, 'info' => $this->createInfoString($project_info)); } elseif ($project_info->type == LOCALE_TRANSLATION_LOCAL || $project_info->type == LOCALE_TRANSLATION_REMOTE) { $local = isset($project_info->files[LOCALE_TRANSLATION_LOCAL]) ? $project_info->files[LOCALE_TRANSLATION_LOCAL] : NULL; $remote = isset($project_info->files[LOCALE_TRANSLATION_REMOTE]) ? $project_info->files[LOCALE_TRANSLATION_REMOTE] : NULL; $recent = _locale_translation_source_compare($local, $remote) == LOCALE_TRANSLATION_SOURCE_COMPARE_LT ? $remote : $local; $updates[$langcode]['updates'][] = array('name' => $project_info->name == 'drupal' ? $this->t('Drupal core') : $project_data[$project_info->name]->info['name'], 'version' => $project_info->version, 'timestamp' => $recent->timestamp); } } } return $updates; }