View source
<?php
namespace Drupal\Tests\sitemap\Functional\Update;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
use Drupal\sitemap\Plugin\Sitemap\Vocabulary;
use Drupal\views\Views;
class SitemapVersionUpdateTest extends UpdatePathTestBase {
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../fixtures/update/sitemap-config-update-3140108.php.gz',
];
}
public function testUpdateHookN() {
$this
->runUpdates();
$configFactory = \Drupal::configFactory();
$config = $configFactory
->get('sitemap.settings');
$this
->assertEqual($config
->get('page_title'), 'Custom page title', 'page_title is unchanged');
$this
->assertEqual($config
->get('message')['value'], 'Custom sitemap message!', 'message value is unchanged');
$this
->assertEqual($config
->get('message')['format'], 'restricted_html', 'message format is unchanged');
$this
->assertTrue($config
->get('include_css'), 'include_css updated successfully');
$removed = [
'css',
'show_rss_links',
'show_titles',
'order',
'show_front',
'rss_front',
'show_books',
'books_expanded',
'show_menus',
'show_menus_hidden',
'show_vocabularies',
'show_description',
'show_count',
'vocabulary_depth',
'vocabulary_show_links',
'term_threshold',
'rss_taxonomy',
];
foreach ($removed as $key) {
$this
->assertNull($config
->get($key), "{$key} was removed");
}
$this
->assertNotNull($config
->get('plugins'));
$plugins = $config
->get('plugins');
$this
->assertNotEmpty($plugins['frontpage']);
$frontpage = $plugins['frontpage'];
$this
->assertEqual($frontpage['enabled'], FALSE);
$this
->assertEqual($frontpage['weight'], -48);
$this
->assertEqual($frontpage['settings']['title'], 'Front page');
$this
->assertEqual($frontpage['settings']['rss'], '/custom-rss.xml');
$this
->assertNotEmpty($plugins['book:1']);
$book1 = $plugins['book:1'];
$this
->assertEqual($book1['enabled'], TRUE);
$this
->assertEqual($book1['weight'], -41);
$this
->assertEqual($book1['settings']['title'], 'Book 1');
$this
->assertNotEmpty($plugins['book:2']);
$book2 = $plugins['book:2'];
$this
->assertEqual($book2['enabled'], FALSE);
$this
->assertEqual($book2['weight'], -47);
$this
->assertEqual($book2['settings']['title'], 'Book 2');
foreach ([
$book1,
$book2,
] as $book) {
$settings = $book['settings'];
$this
->assertEqual($settings['show_expanded'], TRUE);
}
$this
->assertNotEmpty($plugins['menu:main']);
$main = $plugins['menu:main'];
$this
->assertEqual($main['enabled'], TRUE);
$this
->assertEqual($main['weight'], -50);
$this
->assertEqual($main['settings']['title'], 'Custom menu title');
$this
->assertNotEmpty($plugins['menu:tools']);
$tools = $plugins['menu:tools'];
$this
->assertEqual($tools['enabled'], FALSE);
$this
->assertEqual($tools['weight'], -43);
$this
->assertEqual($tools['settings']['title'], 'Tools');
foreach ([
$main,
$tools,
] as $menu) {
$settings = $menu['settings'];
$this
->assertEqual($settings['show_disabled'], FALSE);
}
$this
->assertNotEmpty($plugins['vocabulary:tags']);
$tags = $plugins['vocabulary:tags'];
$this
->assertEqual($tags['enabled'], TRUE);
$this
->assertEqual($tags['weight'], -42);
$this
->assertEqual($tags['settings']['title'], 'Tags');
$this
->assertNotEmpty($plugins['vocabulary:forums']);
$forum = $plugins['vocabulary:forums'];
$this
->assertEqual($forum['enabled'], TRUE);
$this
->assertEqual($forum['weight'], -49);
$this
->assertEqual($forum['settings']['title'], 'Forums');
$this
->assertNotEmpty($plugins['vocabulary:test']);
$test = $plugins['vocabulary:test'];
$this
->assertEqual($test['enabled'], FALSE);
$this
->assertEqual($test['weight'], -40);
$this
->assertEqual($test['settings']['title'], 'Test');
foreach ([
$tags,
$forum,
$test,
] as $vocab) {
$settings = $vocab['settings'];
$this
->assertEqual($settings['show_description'], TRUE);
$this
->assertEqual($settings['show_count'], TRUE);
$this
->assertEqual($settings['term_depth'], Vocabulary::DEPTH_MAX);
$this
->assertEqual($settings['term_count_threshold'], Vocabulary::THRESHOLD_DISABLED);
$this
->assertEqual($settings['customize_link'], FALSE);
$this
->assertEqual($settings['term_link'], Vocabulary::DEFAULT_TERM_LINK);
$this
->assertEqual($settings['always_link'], FALSE);
$this
->assertEqual($settings['enable_rss'], TRUE);
$this
->assertEqual($settings['rss_link'], Vocabulary::DEFAULT_TERM_RSS_LINK);
$this
->assertEqual($settings['rss_depth'], Vocabulary::DEPTH_MAX);
}
$menuConfig = $configFactory
->get('system.menu.main');
$this
->assertEmpty($menuConfig
->get('third_party_settings.sitemap'));
}
}