3 namespace Drupal\Tests\simple_sitemap\Unit;
5 use Drupal\Tests\UnitTestCase;
6 use Drupal\Core\DependencyInjection\ContainerBuilder;
9 * Base for SimplesitemapTest.
11 abstract class SimplesitemapTestBase extends UnitTestCase {
15 protected $backupGlobals = FALSE;
17 protected $simplesitemapMock;
20 * Used to set a Drupal global. Does not need to be a real URL ATM.
22 const BASE_URL = 'https://some-url';
27 public function setUp() {
30 // Create a dummy container.
31 $this->container = new ContainerBuilder();
33 // The string translation service will be used for most test cases.
34 $this->container->set('string_translation', $this->getStringTranslationStub());
36 // Initial config set up. These are the settings the module sets upon
37 // installation (see sitemap_settings.settings.yml).
40 'cron_generate' => TRUE,
41 'remove_duplicates' => TRUE,
42 'batch_process_limit' => 1500,
43 'enabled_entity_types' => [
51 // Mock the digtap service with the above settings.
52 $this->mockSimplesitemapService();
54 // Set this Drupal global as it may be used in tested methods.
55 $GLOBALS['base_url'] = self::BASE_URL;
59 * Mock Drupal Simplesitemap service.
61 protected function mockSimplesitemapService() {
62 // $configFactory = $this->getConfigFactoryStub(['simple_sitemap.settings' => $this->config]);
63 // $this->simplesitemapMock = $this->getMockBuilder('\Drupal\simple_sitemap\Simplesitemap')
64 // ->setConstructorArgs([
66 // // todo: Add constructor args
70 // $this->container->set('simple_sitemap.settings', $this->simplesitemapMock);
71 // \Drupal::setContainer($this->container);.