EntityTestBundleResourceTestBase.php

Same filename in other branches
  1. 9 core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestBundleResourceTestBase.php
  2. 8.9.x core/modules/rest/tests/src/Functional/EntityResource/EntityTestBundle/EntityTestBundleResourceTestBase.php
  3. 8.9.x core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestBundleResourceTestBase.php
  4. 11.x core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestBundleResourceTestBase.php

Namespace

Drupal\Tests\entity_test\Functional\Rest

File

core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestBundleResourceTestBase.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\entity_test\Functional\Rest;

use Drupal\entity_test\Entity\EntityTestBundle;
use Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase;
abstract class EntityTestBundleResourceTestBase extends ConfigEntityResourceTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'entity_test',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected static $entityTypeId = 'entity_test_bundle';
    
    /**
     * {@inheritdoc}
     */
    protected static $patchProtectedFieldNames = [];
    
    /**
     * @var \Drupal\entity_test\Entity\EntityTestBundle
     */
    protected $entity;
    
    /**
     * {@inheritdoc}
     */
    protected function setUpAuthorization($method) {
        $this->grantPermissionsToTestedRole([
            'administer entity_test_bundle content',
        ]);
    }
    
    /**
     * {@inheritdoc}
     */
    protected function createEntity() {
        $entity_test_bundle = EntityTestBundle::create([
            'id' => 'camelids',
            'label' => 'Camelids',
            'description' => 'Camelids are large, strictly herbivorous animals with slender necks and long legs.',
        ]);
        $entity_test_bundle->save();
        return $entity_test_bundle;
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getExpectedNormalizedEntity() {
        return [
            'dependencies' => [],
            'description' => 'Camelids are large, strictly herbivorous animals with slender necks and long legs.',
            'id' => 'camelids',
            'label' => 'Camelids',
            'langcode' => 'en',
            'status' => TRUE,
            'uuid' => $this->entity
                ->uuid(),
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getNormalizedPostEntity() {
        // @todo Update in https://www.drupal.org/node/2300677.
        return [];
    }

}

Classes

Title Deprecated Summary
EntityTestBundleResourceTestBase

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