SimpleSitemapViewsTestBase.php in Simple XML sitemap 4.x
File
modules/simple_sitemap_views/tests/src/Functional/SimpleSitemapViewsTestBase.php
View source
<?php
namespace Drupal\Tests\simple_sitemap_views\Functional;
use Drupal\simple_sitemap\Entity\SimpleSitemapType;
use Drupal\Tests\simple_sitemap\Functional\SimplesitemapTestBase;
use Drupal\simple_sitemap_views\SimpleSitemapViews;
use Drupal\views\Views;
abstract class SimpleSitemapViewsTestBase extends SimplesitemapTestBase {
protected static $modules = [
'simple_sitemap_views',
'simple_sitemap_views_test',
];
protected $sitemapViews;
protected $cron;
protected $testView;
protected $testView2;
protected $sitemapVariant;
protected function setUp() {
parent::setUp();
$this->sitemapViews = $this->container
->get('simple_sitemap.views');
$this->cron = $this->container
->get('cron');
$this->sitemapVariant = 'default';
$this->testView = Views::getView('simple_sitemap_views_test_view');
$this->testView
->setDisplay('page_1');
$this->testView2 = Views::getView('simple_sitemap_views_test_view');
$this->testView2
->setDisplay('page_2');
$sitemap_type = SimpleSitemapType::load('default_hreflang');
$sitemap_type
->set('url_generators', array_merge($sitemap_type
->get('url_generators'), [
'views',
]))
->save();
}
protected function assertIndexSize($size) {
$this
->assertEquals($size, $this->sitemapViews
->getArgumentsFromIndexCount());
}
protected function addRecordToIndex($view_id, $display_id, array $args_ids, array $args_values) {
$args_ids = implode(SimpleSitemapViews::ARGUMENT_SEPARATOR, $args_ids);
$args_values = implode(SimpleSitemapViews::ARGUMENT_SEPARATOR, $args_values);
$query = $this->database
->insert('simple_sitemap_views');
$query
->fields([
'view_id' => $view_id,
'display_id' => $display_id,
'arguments_ids' => $args_ids,
'arguments_values' => $args_values,
]);
$query
->execute();
}
}