abstract class ImageStyleResourceTestBase in Drupal 10
Same name and namespace in other branches
- 8 core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php \Drupal\Tests\image\Functional\Rest\ImageStyleResourceTestBase
- 9 core/modules/image/tests/src/Functional/Rest/ImageStyleResourceTestBase.php \Drupal\Tests\image\Functional\Rest\ImageStyleResourceTestBase
ResourceTestBase for ImageStyle entity.
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, FunctionalTestSetupTrait, TestSetupTrait, BlockCreationTrait, ConfigTestTrait, ExtensionListTestTrait, ContentTypeCreationTrait, NodeCreationTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\Tests\rest\Functional\ResourceTestBase
- class \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase
- class \Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase
- class \Drupal\Tests\image\Functional\Rest\ImageStyleResourceTestBase
- class \Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase
- class \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase
- class \Drupal\Tests\rest\Functional\ResourceTestBase
Expanded class hierarchy of ImageStyleResourceTestBase
File
- core/
modules/ image/ tests/ src/ Functional/ Rest/ ImageStyleResourceTestBase.php, line 11
Namespace
Drupal\Tests\image\Functional\RestView source
abstract class ImageStyleResourceTestBase extends ConfigEntityResourceTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'image',
];
/**
* {@inheritdoc}
*/
protected static $entityTypeId = 'image_style';
/**
* The ImageStyle entity.
*
* @var \Drupal\image\ImageStyleInterface
*/
protected $entity;
/**
* The effect UUID.
*
* @var string
*/
protected $effectUuid;
/**
* {@inheritdoc}
*/
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'administer image styles',
]);
}
/**
* {@inheritdoc}
*/
protected function createEntity() {
// Create a "Camelids" image style.
$camelids = ImageStyle::create([
'name' => 'camelids',
'label' => 'Camelids',
]);
// Add an image effect.
$effect = [
'id' => 'image_scale_and_crop',
'data' => [
'anchor' => 'center-center',
'width' => 120,
'height' => 121,
],
'weight' => 0,
];
$this->effectUuid = $camelids
->addImageEffect($effect);
$camelids
->save();
return $camelids;
}
/**
* {@inheritdoc}
*/
protected function getExpectedNormalizedEntity() {
return [
'dependencies' => [],
'effects' => [
$this->effectUuid => [
'uuid' => $this->effectUuid,
'id' => 'image_scale_and_crop',
'weight' => 0,
'data' => [
'anchor' => 'center-center',
'width' => 120,
'height' => 121,
],
],
],
'label' => 'Camelids',
'langcode' => 'en',
'name' => 'camelids',
'status' => TRUE,
'uuid' => $this->entity
->uuid(),
];
}
/**
* {@inheritdoc}
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
return "The 'administer image styles' permission is required.";
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ImageStyleResourceTestBase:: |
protected | property | The effect UUID. | |
ImageStyleResourceTestBase:: |
protected | property | The ImageStyle entity. | |
ImageStyleResourceTestBase:: |
protected static | property | ||
ImageStyleResourceTestBase:: |
protected static | property | 2 | |
ImageStyleResourceTestBase:: |
protected | function | ||
ImageStyleResourceTestBase:: |
protected | function | ||
ImageStyleResourceTestBase:: |
protected | function | ||
ImageStyleResourceTestBase:: |
protected | function | ||
ImageStyleResourceTestBase:: |
protected | function |