Commit 24362a9d authored by Damien McKenna's avatar Damien McKenna
Browse files

Issue #3123578 by DamienMcKenna: Some follow-up on D9 test compatibility.

parent 6b545f6c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ Metatag 8.x-1.x-dev, xxxx-xx-xx
#3123578 by DamienMcKenna, Berdir: Add NodeJsonOutput test back again.
#3124042 by Neslee Canil Pinto: Follow-up with more changes.
#3123578 by DamienMcKenna: Removed restui dependency from test's modules list.
#3123578 by DamienMcKenna: Some follow-up on D9 test compatibility.


Metatag 8.x-1.12, 2020-03-30
+3 −3
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ use Drupal\Tests\BrowserTestBase;
/**
 * Confirm the defaults functionality works.
 *
 * @group panelizer
 * @group metatag
 */
class MetatagViewsBasicsTest extends BrowserTestBase {

@@ -65,9 +65,9 @@ class MetatagViewsBasicsTest extends BrowserTestBase {
  }

  /**
   * Confirm the site isn't broken.
   * Confirm the Views functionality works, including UI.
   */
  public function testSiteStillWorks() {
  public function testViewsUi() {
    // Load the front page.
    $this->drupalGet('<front>');
    $this->assertSession()->statusCodeEquals(200);
+5 −5
Original line number Diff line number Diff line
@@ -26,16 +26,16 @@ class NodewordsEntities extends ProcessPluginBase {
      return NULL;
    }

    // This is expected to be an array, if it isn't then something went wrong.
    if (!is_array($value)) {
      throw new MigrateException('Data from Nodewords-D6 was not a serialized array.');
    }

    $metatags = [];

    // Restructure Nodewords-D6 data.
    $tags_map = $this->tagsMap();

    // This is expected to be an array, if it isn't something went wrong.
    if (!is_array($value)) {
      throw new MigrateException('Data from Nodewords-D6 was not a serialized array.');
    }

    // Re-shape D6 entries into for D8 entries.
    $old_tags = array_map(static function ($value) {
      return unserialize($value);
+13 −13
Original line number Diff line number Diff line
@@ -26,26 +26,26 @@ class MetatagEntities extends ProcessPluginBase {
      return NULL;
    }

    $tags_map = $this->tagsMap();

    $metatags = [];

    // Re-shape D7 entries into for D8 entries.
    $old_tags = unserialize($value);

    // This is expected to be an array, if it isn't something went wrong.
    // This is expected to be an array, if it isn't then something went wrong.
    if (!is_array($old_tags)) {
      throw new MigrateException('Data from Metatag-D7 was not a serialized array.');
    }

    foreach ($old_tags as $d7_metatag_name => $data) {
    $tags_map = $this->tagsMap();

    $metatags = [];

    foreach ($old_tags as $d7_metatag_name => $metatag_value) {
      // If there's no data for this tag, ignore everything.
      if (empty($data)) {
      if (empty($metatag_value)) {
        continue;
      }

      // @todo Skip these values for now, maybe some version supported these?
      if (!is_array($data) || empty($data['value'])) {
      if (!is_array($metatag_value) || empty($metatag_value['value'])) {
        continue;
      }

@@ -57,18 +57,18 @@ class MetatagEntities extends ProcessPluginBase {
      $d8_metatag_name = $tags_map[$d7_metatag_name];

      // Convert the nested arrays to a flat structure.
      if (is_array($data['value'])) {
      if (is_array($metatag_value['value'])) {
        // Remove empty values.
        $data['value'] = array_filter($data['value']);
        $metatag_value['value'] = array_filter($metatag_value['value']);
        // Convert the array into a comma-separated list.
        $data = implode(', ', $data['value']);
        $metatag_value = implode(', ', $metatag_value['value']);
      }
      else {
        $data = $data['value'];
        $metatag_value = $metatag_value['value'];
      }

      // Keep the entire data structure.
      $metatags[$d8_metatag_name] = $data;
      $metatags[$d8_metatag_name] = $metatag_value;
    }

    return serialize($metatags);
+5 −0
Original line number Diff line number Diff line
@@ -38,6 +38,11 @@ class NodeJsonOutput extends BrowserTestBase {
    'rest',
  ];

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'bartik';

  /**
   * Create an entity, view its JSON output, confirm Metatag data exists.
   */