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