View source
<?php
namespace Drupal\Tests\path_alias\Functional\Rest;
use Drupal\Core\Language\LanguageInterface;
use Drupal\path_alias\Entity\PathAlias;
use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
abstract class PathAliasResourceTestBase extends EntityResourceTestBase {
use BcTimestampNormalizerUnixTestTrait;
public static $modules = [
'path_alias',
];
protected static $entityTypeId = 'path_alias';
protected static $patchProtectedFieldNames = [];
protected static $firstCreatedEntityId = 3;
protected static $secondCreatedEntityId = 4;
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'administer url aliases',
]);
}
protected function createEntity() {
$path_alias = PathAlias::create([
'path' => '/<front>',
'alias' => '/frontpage1',
]);
$path_alias
->save();
return $path_alias;
}
protected function getExpectedNormalizedEntity() {
return [
'id' => [
[
'value' => 1,
],
],
'revision_id' => [
[
'value' => 1,
],
],
'langcode' => [
[
'value' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
],
],
'path' => [
[
'value' => '/<front>',
],
],
'alias' => [
[
'value' => '/frontpage1',
],
],
'status' => [
[
'value' => TRUE,
],
],
'uuid' => [
[
'value' => $this->entity
->uuid(),
],
],
];
}
protected function getNormalizedPostEntity() {
return [
'path' => [
[
'value' => '/<front>',
],
],
'alias' => [
[
'value' => '/frontpage1',
],
],
];
}
protected function getExpectedCacheContexts() {
return [
'user.permissions',
];
}
}