function MigrateSearchPageTest::testSearchPage

Same name in this branch
  1. 8.9.x core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php \Drupal\Tests\search\Kernel\Migrate\d7\MigrateSearchPageTest::testSearchPage()
Same name in other branches
  1. 9 core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php \Drupal\Tests\search\Kernel\Migrate\d6\MigrateSearchPageTest::testSearchPage()
  2. 9 core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php \Drupal\Tests\search\Kernel\Migrate\d7\MigrateSearchPageTest::testSearchPage()
  3. 10 core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php \Drupal\Tests\search\Kernel\Migrate\d6\MigrateSearchPageTest::testSearchPage()
  4. 10 core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php \Drupal\Tests\search\Kernel\Migrate\d7\MigrateSearchPageTest::testSearchPage()
  5. 11.x core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php \Drupal\Tests\search\Kernel\Migrate\d6\MigrateSearchPageTest::testSearchPage()
  6. 11.x core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php \Drupal\Tests\search\Kernel\Migrate\d7\MigrateSearchPageTest::testSearchPage()

Tests Drupal 6 search settings to Drupal 8 search page entity migration.

File

core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php, line 32

Class

MigrateSearchPageTest
Upgrade search page variables.

Namespace

Drupal\Tests\search\Kernel\Migrate\d6

Code

public function testSearchPage() {
    $id = 'node_search';
    
    /** @var \Drupal\search\Entity\SearchPage $search_page */
    $search_page = SearchPage::load($id);
    $this->assertIdentical($id, $search_page->id());
    $configuration = $search_page->getPlugin()
        ->getConfiguration();
    $this->assertIdentical($configuration['rankings'], [
        'comments' => 5,
        'promote' => 0,
        'recent' => 0,
        'relevance' => 2,
        'sticky' => 8,
        'views' => 1,
    ]);
    $this->assertIdentical('node', $search_page->getPath());
    // Test that we can re-import using the EntitySearchPage destination.
    Database::getConnection('default', 'migrate')->update('variable')
        ->fields([
        'value' => serialize(4),
    ])
        ->condition('name', 'node_rank_comments')
        ->execute();
    
    /** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
    $migration = $this->getMigration('search_page');
    // Indicate we're rerunning a migration that's already run.
    $migration->getIdMap()
        ->prepareUpdate();
    $this->executeMigration($migration);
    $configuration = SearchPage::load($id)->getPlugin()
        ->getConfiguration();
    $this->assertIdentical(4, $configuration['rankings']['comments']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.