e41f1a1922a0ce1e13f6902af519eb4950aabbe8
[yaffs-website] / web / modules / contrib / simple_sitemap / tests / src / Unit / SimplesitemapTestBase.php
1 <?php
2
3 namespace Drupal\Tests\simple_sitemap\Unit;
4
5 use Drupal\Tests\UnitTestCase;
6 use Drupal\Core\DependencyInjection\ContainerBuilder;
7
8 /**
9  * Base for SimplesitemapTest.
10  */
11 abstract class SimplesitemapTestBase extends UnitTestCase {
12
13   protected $config;
14   protected $container;
15   protected $backupGlobals = FALSE;
16
17   protected $simplesitemapMock;
18
19   /**
20    * Used to set a Drupal global. Does not need to be a real URL ATM.
21    */
22   const BASE_URL = 'https://some-url';
23
24   /**
25    * {@inheritdoc}
26    */
27   public function setUp() {
28     parent::setUp();
29
30     // Create a dummy container.
31     $this->container = new ContainerBuilder();
32
33     // The string translation service will be used for most test cases.
34     $this->container->set('string_translation', $this->getStringTranslationStub());
35
36     // Initial config set up. These are the settings the module sets upon
37     // installation (see sitemap_settings.settings.yml).
38     $this->config = [
39       'max_links' => 2000,
40       'cron_generate' => TRUE,
41       'remove_duplicates' => TRUE,
42       'batch_process_limit' => 1500,
43       'enabled_entity_types' => [
44         'node',
45         'taxonomy_term',
46         'menu_link_content',
47       ],
48       'base_url' => '',
49     ];
50
51     // Mock the digtap service with the above settings.
52     $this->mockSimplesitemapService();
53
54     // Set this Drupal global as it may be used in tested methods.
55     $GLOBALS['base_url'] = self::BASE_URL;
56   }
57
58   /**
59    * Mock Drupal Simplesitemap service.
60    */
61   protected function mockSimplesitemapService() {
62     // $configFactory = $this->getConfigFactoryStub(['simple_sitemap.settings' => $this->config]);
63     //    $this->simplesitemapMock = $this->getMockBuilder('\Drupal\simple_sitemap\Simplesitemap')
64     //      ->setConstructorArgs([
65     //        $configFactory
66     //        // todo: Add constructor args
67     //      ])
68     //      ->setMethods(NULL)
69     //      ->getMock();
70     //    $this->container->set('simple_sitemap.settings', $this->simplesitemapMock);
71     //    \Drupal::setContainer($this->container);.
72   }
73
74 }