View source
<?php
namespace Drupal\KernelTests\Core\Path;
use Drupal\Core\Language\LanguageInterface;
use Drupal\KernelTests\KernelTestBase;
class AliasStorageTest extends KernelTestBase {
public static $modules = [
'system',
];
protected $storage;
protected function setUp() {
parent::setUp();
$this
->installSchema('system', 'url_alias');
$this->storage = $this->container
->get('path.alias_storage');
}
public function testLoad() {
$this->storage
->save('/test-source-Case', '/test-alias-Case');
$expected = [
'pid' => 1,
'alias' => '/test-alias-Case',
'source' => '/test-source-Case',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
];
$this
->assertEquals($expected, $this->storage
->load([
'alias' => '/test-alias-Case',
]));
$this
->assertEquals($expected, $this->storage
->load([
'alias' => '/test-alias-case',
]));
$this
->assertEquals($expected, $this->storage
->load([
'source' => '/test-source-Case',
]));
$this
->assertEquals($expected, $this->storage
->load([
'source' => '/test-source-case',
]));
}
public function testLookupPathAlias() {
$this->storage
->save('/test-source-Case', '/test-alias');
$this
->assertEquals('/test-alias', $this->storage
->lookupPathAlias('/test-source-Case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
$this
->assertEquals('/test-alias', $this->storage
->lookupPathAlias('/test-source-case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
}
public function testLookupPathSource() {
$this->storage
->save('/test-source', '/test-alias-Case');
$this
->assertEquals('/test-source', $this->storage
->lookupPathSource('/test-alias-Case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
$this
->assertEquals('/test-source', $this->storage
->lookupPathSource('/test-alias-case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
}
public function testAliasExists() {
$this->storage
->save('/test-source-Case', '/test-alias-Case');
$this
->assertTrue($this->storage
->aliasExists('/test-alias-Case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
$this
->assertTrue($this->storage
->aliasExists('/test-alias-case', LanguageInterface::LANGCODE_NOT_SPECIFIED));
}
}