MigrateSearchPageTest.php in Drupal 9
File
core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php
View source
<?php
namespace Drupal\Tests\search\Kernel\Migrate\d6;
use Drupal\Core\Database\Database;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
use Drupal\search\Entity\SearchPage;
class MigrateSearchPageTest extends MigrateDrupal6TestBase {
protected static $modules = [
'search',
];
protected function setUp() : void {
parent::setUp();
$this
->executeMigration('search_page');
}
public function testSearchPage() {
$id = 'node_search';
$search_page = SearchPage::load($id);
$this
->assertSame($id, $search_page
->id());
$configuration = $search_page
->getPlugin()
->getConfiguration();
$this
->assertSame([
'comments' => 5,
'promote' => 0,
'recent' => 0,
'relevance' => 2,
'sticky' => 8,
'views' => 1,
], $configuration['rankings']);
$this
->assertSame('node', $search_page
->getPath());
Database::getConnection('default', 'migrate')
->update('variable')
->fields([
'value' => serialize(4),
])
->condition('name', 'node_rank_comments')
->execute();
$migration = $this
->getMigration('search_page');
$migration
->getIdMap()
->prepareUpdate();
$this
->executeMigration($migration);
$configuration = SearchPage::load($id)
->getPlugin()
->getConfiguration();
$this
->assertSame(4, $configuration['rankings']['comments']);
}
}