Commit 940e609a authored by catch's avatar catch
Browse files

Issue #3134300 by quietone, alexpott, benjifisher: Simplify...

Issue #3134300 by quietone, alexpott, benjifisher: Simplify ReviewForm::buildForm() and the resulting markup
parent 687dcd44
Loading
Loading
Loading
Loading
+13 −35
Original line number Diff line number Diff line
@@ -154,26 +154,15 @@ public function buildForm(array $form, FormStateInterface $form_state) {
      $output = $this->prepareOutput($display[MigrationState::NOT_FINISHED]);
      foreach ($output as $data) {
        $missing_count++;
        // Get the migration status for this $source_module, if a module of the
        // Get the migration status for each source module, if a module of the
        // same name exists on the destination site.
        $missing_module_list['module_list'][] = [
          'source_module' => [
            '#type' => 'html_tag',
            '#tag' => 'span',
            '#value' => $data['source_module_name'],
            '#attributes' => [
              'class' => [
                'upgrade-analysis-report__status-icon',
                'upgrade-analysis-report__status-icon--error',
              ],
            ],
          ],
          'source_machine_name' => [
            '#plain_text' => $data['source_machine_name'],
          ],
          'destination_module' => [
            '#plain_text' => $data['destination'],
        $missing_module_list['module_list']['#rows'][] = [
          [
            'data' => $data['source_module_name'],
            'class' => ['upgrade-analysis-report__status-icon', 'upgrade-analysis-report__status-icon--error'],
          ],
          $data['source_machine_name'],
          $data['destination'],
        ];
      }
    }
@@ -200,24 +189,13 @@ public function buildForm(array $form, FormStateInterface $form_state) {
      $output = $this->prepareOutput($display[MigrationState::FINISHED]);
      foreach ($output as $data) {
        $available_count++;
        $available_module_list['module_list'][] = [
          'source_module' => [
            '#type' => 'html_tag',
            '#tag' => 'span',
            '#value' => $data['source_module_name'],
            '#attributes' => [
              'class' => [
                'upgrade-analysis-report__status-icon',
                'upgrade-analysis-report__status-icon--checked',
              ],
            ],
          ],
          'source_machine_name' => [
            '#plain_text' => $data['source_machine_name'],
          ],
          'destination_module' => [
            '#plain_text' => $data['destination'],
        $available_module_list['module_list']['#rows'][] = [
          [
            'data' => $data['source_module_name'],
            'class' => ['upgrade-analysis-report__status-icon', 'upgrade-analysis-report__status-icon--checked'],
          ],
          $data['source_machine_name'],
          $data['destination'],
        ];
      }
    }
+6 −6
Original line number Diff line number Diff line
@@ -110,19 +110,19 @@ protected function tearDown() {
  protected function assertUpgradePaths(WebAssert $session, array $available_paths, array $missing_paths) {
    // Test the available migration paths.
    foreach ($available_paths as $available) {
      $session->elementExists('xpath', "//span[contains(@class, 'checked') and text() = '$available']");
      $session->elementNotExists('xpath', "//span[contains(@class, 'error') and text() = '$available']");
      $session->elementExists('xpath', "//td[contains(@class, 'checked') and text() = '$available']");
      $session->elementNotExists('xpath', "//td[contains(@class, 'error') and text() = '$available']");
    }

    // Test the missing migration paths.
    foreach ($missing_paths as $missing) {
      $session->elementExists('xpath', "//span[contains(@class, 'error') and text() = '$missing']");
      $session->elementNotExists('xpath', "//span[contains(@class, 'checked') and text() = '$missing']");
      $session->elementExists('xpath', "//td[contains(@class, 'error') and text() = '$missing']");
      $session->elementNotExists('xpath', "//td[contains(@class, 'checked') and text() = '$missing']");
    }

    // Test the total count of missing and available paths.
    $session->elementsCount('xpath', "//span[contains(@class, 'upgrade-analysis-report__status-icon--error')]", count($missing_paths));
    $session->elementsCount('xpath', "//span[contains(@class, 'upgrade-analysis-report__status-icon--checked')]", count($available_paths));
    $session->elementsCount('xpath', "//td[contains(@class, 'upgrade-analysis-report__status-icon--error')]", count($missing_paths));
    $session->elementsCount('xpath', "//td[contains(@class, 'upgrade-analysis-report__status-icon--checked')]", count($available_paths));
  }

  /**