Upgraded drupal core with security updates
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Path / AliasStorageTest.php
1 <?php
2
3 namespace Drupal\KernelTests\Core\Path;
4
5 use Drupal\Core\Language\LanguageInterface;
6 use Drupal\KernelTests\KernelTestBase;
7
8 /**
9  * @coversDefaultClass \Drupal\Core\Path\AliasStorage
10  * @group path
11  */
12 class AliasStorageTest extends KernelTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static $modules = ['system'];
18
19   /**
20    * @var \Drupal\Core\Path\AliasStorage
21    */
22   protected $storage;
23
24   /**
25    * {@inheritdoc}
26    */
27   protected function setUp() {
28     parent::setUp();
29
30     $this->storage = $this->container->get('path.alias_storage');
31   }
32
33   /**
34    * @covers ::load
35    */
36   public function testLoad() {
37     $this->storage->save('/test-source-Case', '/test-alias-Case');
38
39     $expected = [
40       'pid' => 1,
41       'alias' => '/test-alias-Case',
42       'source' => '/test-source-Case',
43       'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
44     ];
45
46     $this->assertEquals($expected, $this->storage->load(['alias' => '/test-alias-Case']));
47     $this->assertEquals($expected, $this->storage->load(['alias' => '/test-alias-case']));
48     $this->assertEquals($expected, $this->storage->load(['source' => '/test-source-Case']));
49     $this->assertEquals($expected, $this->storage->load(['source' => '/test-source-case']));
50   }
51
52   /**
53    * @covers ::lookupPathAlias
54    */
55   public function testLookupPathAlias() {
56     $this->storage->save('/test-source-Case', '/test-alias');
57
58     $this->assertEquals('/test-alias', $this->storage->lookupPathAlias('/test-source-Case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
59     $this->assertEquals('/test-alias', $this->storage->lookupPathAlias('/test-source-case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
60   }
61
62   /**
63    * @covers ::lookupPathSource
64    */
65   public function testLookupPathSource() {
66     $this->storage->save('/test-source', '/test-alias-Case');
67
68     $this->assertEquals('/test-source', $this->storage->lookupPathSource('/test-alias-Case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
69     $this->assertEquals('/test-source', $this->storage->lookupPathSource('/test-alias-case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
70   }
71
72   /**
73    * @covers ::aliasExists
74    */
75   public function testAliasExists() {
76     $this->storage->save('/test-source-Case', '/test-alias-Case');
77
78     $this->assertTrue($this->storage->aliasExists('/test-alias-Case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
79     $this->assertTrue($this->storage->aliasExists('/test-alias-case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
80   }
81
82 }