class PathAliasResourceTestBase

Same name and namespace in other branches
  1. 11.x core/modules/path_alias/tests/src/Functional/Rest/PathAliasResourceTestBase.php \Drupal\Tests\path_alias\Functional\Rest\PathAliasResourceTestBase
  2. 10 core/modules/path_alias/tests/src/Functional/Rest/PathAliasResourceTestBase.php \Drupal\Tests\path_alias\Functional\Rest\PathAliasResourceTestBase
  3. 8.9.x core/modules/path_alias/tests/src/Functional/Rest/PathAliasResourceTestBase.php \Drupal\Tests\path_alias\Functional\Rest\PathAliasResourceTestBase

Base class for path_alias EntityResource tests.

Hierarchy

Expanded class hierarchy of PathAliasResourceTestBase

1 file declares its use of PathAliasResourceTestBase
PathAliasHalJsonTestBase.php in core/modules/hal/tests/src/Functional/path_alias/PathAliasHalJsonTestBase.php

File

core/modules/path_alias/tests/src/Functional/Rest/PathAliasResourceTestBase.php, line 12

Namespace

Drupal\Tests\path_alias\Functional\Rest
View source
abstract class PathAliasResourceTestBase extends EntityResourceTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'path',
    'path_alias',
  ];
  
  /**
   * {@inheritdoc}
   */
  protected static $entityTypeId = 'path_alias';
  
  /**
   * {@inheritdoc}
   */
  protected static $patchProtectedFieldNames = [];
  
  /**
   * {@inheritdoc}
   */
  protected static $firstCreatedEntityId = 3;
  
  /**
   * {@inheritdoc}
   */
  protected static $secondCreatedEntityId = 4;
  
  /**
   * {@inheritdoc}
   */
  protected function setUpAuthorization($method) {
    $this->grantPermissionsToTestedRole([
      'administer url aliases',
    ]);
  }
  
  /**
   * {@inheritdoc}
   */
  protected function createEntity() {
    $path_alias = PathAlias::create([
      'path' => '/<front>',
      'alias' => '/frontpage1',
    ]);
    $path_alias->save();
    return $path_alias;
  }
  
  /**
   * {@inheritdoc}
   */
  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(),
        ],
      ],
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getNormalizedPostEntity() {
    return [
      'path' => [
        [
          'value' => '/<front>',
        ],
      ],
      'alias' => [
        [
          'value' => '/frontpage1',
        ],
      ],
    ];
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.