Commit 55736558 authored by Siddhant Bhosale's avatar Siddhant Bhosale Committed by Damien McKenna
Browse files

Issue #3158186 by siddhant.bhosale, rahulrasgon, rokzabukovec, sabina.h,...

Issue #3158186 by siddhant.bhosale, rahulrasgon, rokzabukovec, sabina.h, DamienMcKenna: Replace usages of assertions that are deprecated.
parent e46ef6b8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@ Metatag 8.x-1.x-dev, xxxx-xx-xx
#3187583 by jrb: Syntax error when running PHP 7.0.
#3187898 by rutiolma: Comply with migrations using migrate_upgrade.
#3182548 by DamienMcKenna: Fix tests on 8.x-1.x branch for D9.1.
#3158186 by siddhant.bhosale, rahulrasgon, rokzabukovec, sabina.h,
  DamienMcKenna: Replace usages of assertions that are deprecated.


Metatag 8.x-1.15, 2020-12-05
+33 −0
Original line number Diff line number Diff line
# A default migration mapping for Metatag-D7 default configuration.
#
# @see Drupal\metatag\Plugin\migrate\source\d7\MetatagDefault

id: d7_metatag_default
label: Metatag default configuration
migration_tags:
  - Drupal 7

source:
  plugin: d7_metatag_default
  source_module: metatag
  ignore_map: true
  constants:
    langcode: und
    status: true

# @todo What is the correct destination type.
destination:
  plugin: config
  # @todo This needs to be generated dynamically.
  config_name: metatag.metatag_defaults.INSTANCE

# @todo What is needed for the migration processing.
process:
  # These are simple constants that will be kept as-is.
  langcode: 'constants/langcode'
  status: 'constants/status'

  # These come from the actual records.
  id: instance
  label: instance
  tags: config
+64 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\metatag\Plugin\migrate\source\d7;

use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;

/**
 * Drupal 7 Metatag configuration.
 *
 * @MigrateSource(
 *   id = "d7_metatag_default",
 *   source_module = "metatag"
 * )
 */
class MetatagDefault extends DrupalSqlBase {

  /**
   * {@inheritdoc}
   */
  public function query() {
    return $this->select('metatag_config', 'm')
      ->fields('m', ['instance', 'config']);
  }

  /**
   * {@inheritdoc}
   */
  public function fields() {
    $fields = [
      'instance' => $this->t('Configuration instance'),
      'config' => $this->t('Meta tags'),
    ];
    return $fields;
  }

  /**
   * {@inheritdoc}
   */
  public function getIds() {
    $ids['instance']['type'] = 'string';
    $ids['config']['type'] = 'string';
    return $ids;
  }

  /**
   * {@inheritdoc}
   */
  public function prepareRow(Row $row) {
    parent::prepareRow($row);

    // @todo Unserialize the 'config' value to make processing easier.
    $config = $row->getSourceProperty('config');
    try {
      $config = unserialize($config);
      $row->setSourceProperty('config_expanded', $config);
    }
    catch (\Exception $e) {
      // Log an error message about this record.
      throw new MigrateSkipRowException('Unable to unserialize record %blah');
    }
  }

}
+1 −1
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ class DefaultTags extends BrowserTestBase {

      // Check the meta tags.
      $xpath = $this->xpath("//link[@rel='canonical']");
      $this->assertNotEqual((string) $xpath[0]->getAttribute('href'), $front_url);
      $this->assertNotEquals((string) $xpath[0]->getAttribute('href'), $front_url);
      self::assertEquals((string) $xpath[0]->getAttribute('href'), $this_page_url);
    }
  }
+7 −6
Original line number Diff line number Diff line
@@ -43,10 +43,11 @@ class MaintenanceMode extends BrowserTestBase {
  public function testUser1() {
    // Load the user 1 profile page.
    $this->drupalGet('/user/1');
    $session = $this->assertSession();
    // Confirm the page title is correct.
    $this->assertRaw('<title>Access denied | ');
    $this->assertNoRaw('<title>admin | ');
    $this->assertNoRaw('<title>Site under maintenance | ');
    $session->responseContains('<title>Access denied | ');
    $session->responseNotContains('<title>admin | ');
    $session->responseNotContains('<title>Site under maintenance | ');

    // Put the site into maintenance mode.
    \Drupal::state()->set('system.maintenance_mode', TRUE);
@@ -55,9 +56,9 @@ class MaintenanceMode extends BrowserTestBase {
    // Load the user 1 profile page again.
    $this->drupalGet('/user/1');
    // Confirm the page title has changed.
    $this->assertNoRaw('<title>Access denied | ');
    $this->assertNoRaw('<title>admin | ');
    $this->assertRaw('<title>Site under maintenance | ');
    $session->responseNotContains('<title>Access denied | ');
    $session->responseNotContains('<title>admin | ');
    $session->responseContains('<title>Site under maintenance | ');
  }

}
Loading