function MigrateSearchPageTest::testSearchPage

Same name in this branch
  1. 11.x core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php \Drupal\Tests\search\Kernel\Migrate\d6\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. 8.9.x core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php \Drupal\Tests\search\Kernel\Migrate\d6\MigrateSearchPageTest::testSearchPage()
  4. 8.9.x core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php \Drupal\Tests\search\Kernel\Migrate\d7\MigrateSearchPageTest::testSearchPage()
  5. 10 core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php \Drupal\Tests\search\Kernel\Migrate\d6\MigrateSearchPageTest::testSearchPage()
  6. 10 core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php \Drupal\Tests\search\Kernel\Migrate\d7\MigrateSearchPageTest::testSearchPage()

Tests migration of search status and settings to search page entity.

File

core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php, line 54

Class

MigrateSearchPageTest
Tests migration of search page status and settings.

Namespace

Drupal\Tests\search\Kernel\Migrate\d7

Code

public function testSearchPage() : void {
    $this->enableModules([
        'node',
    ]);
    $this->installConfig([
        'search',
    ]);
    $this->executeMigration('d7_search_page');
    $configuration = [
        'rankings' => [
            'comments' => 0,
            'promote' => 0,
            'relevance' => 2,
            'sticky' => 0,
            'views' => 0,
        ],
    ];
    $this->assertEntity('node_search', 'node', TRUE, $configuration);
    $this->assertEntity('user_search', 'user');
    // 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('d7_search_page');
    // Indicate we're rerunning a migration that's already run.
    $migration->getIdMap()
        ->prepareUpdate();
    $this->executeMigration($migration);
    $configuration['rankings']['comments'] = 4;
    $this->assertEntity('node_search', 'node', TRUE, $configuration);
    // Test that a configurable search without a configuration imports. Do this
    // by removing the node rankings from the source database.
    Database::getConnection('default', 'migrate')->delete('variable')
        ->condition('name', 'node_rank_%', 'LIKE')
        ->execute();
    $migration = $this->getMigration('d7_search_page');
    $migration->getIdMap()
        ->prepareUpdate();
    $this->executeMigration($migration);
    $configuration = [
        'rankings' => [],
    ];
    $this->assertEntity('node_search', 'node', TRUE, $configuration);
}

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