RestResourceConfigValidationTest.php

Same filename and directory in other branches
  1. 11.x core/modules/rest/tests/src/Kernel/Entity/RestResourceConfigValidationTest.php

Namespace

Drupal\Tests\rest\Kernel\Entity

File

core/modules/rest/tests/src/Kernel/Entity/RestResourceConfigValidationTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\rest\Kernel\Entity;

use Drupal\KernelTests\Core\Config\ConfigEntityValidationTestBase;
use Drupal\rest\Entity\RestResourceConfig;
use Drupal\rest\RestResourceConfigInterface;

/**
 * Tests validation of rest_resource_config entities.
 *
 * @group rest
 */
class RestResourceConfigValidationTest extends ConfigEntityValidationTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'rest',
        'serialization',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected bool $hasLabel = FALSE;
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() : void {
        parent::setUp();
        $this->entity = RestResourceConfig::create([
            'id' => 'test',
            'plugin_id' => 'entity:date_format',
            'granularity' => RestResourceConfigInterface::METHOD_GRANULARITY,
            'configuration' => [],
        ]);
        $this->entity
            ->save();
    }
    
    /**
     * Tests that the resource plugin ID is validated.
     */
    public function testInvalidPluginId() : void {
        $this->entity
            ->set('plugin_id', 'non_existent');
        $this->assertValidationErrors([
            'plugin_id' => "The 'non_existent' plugin does not exist.",
        ]);
    }

}

Classes

Title Deprecated Summary
RestResourceConfigValidationTest Tests validation of rest_resource_config entities.

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