RestResourceConfigTest.php

Same filename in this branch
  1. 11.x core/modules/jsonapi/tests/src/Functional/RestResourceConfigTest.php
  2. 11.x core/modules/rest/tests/src/Kernel/Entity/RestResourceConfigTest.php
Same filename and directory in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/RestResourceConfigTest.php
  2. 9 core/modules/rest/tests/src/Unit/Entity/RestResourceConfigTest.php
  3. 9 core/modules/rest/tests/src/Kernel/Entity/RestResourceConfigTest.php
  4. 9 core/modules/hal/tests/src/Kernel/rest/Entity/RestResourceConfigTest.php
  5. 8.9.x core/modules/jsonapi/tests/src/Functional/RestResourceConfigTest.php
  6. 8.9.x core/modules/rest/tests/src/Unit/Entity/RestResourceConfigTest.php
  7. 8.9.x core/modules/rest/tests/src/Kernel/Entity/RestResourceConfigTest.php
  8. 10 core/modules/jsonapi/tests/src/Functional/RestResourceConfigTest.php
  9. 10 core/modules/rest/tests/src/Unit/Entity/RestResourceConfigTest.php
  10. 10 core/modules/rest/tests/src/Kernel/Entity/RestResourceConfigTest.php

Namespace

Drupal\Tests\rest\Unit\Entity

File

core/modules/rest/tests/src/Unit/Entity/RestResourceConfigTest.php

View source
<?php

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

use Drupal\rest\Entity\RestResourceConfig;
use Drupal\rest\RestResourceConfigInterface;
use Drupal\Tests\UnitTestCase;

/**
 * @coversDefaultClass \Drupal\rest\Entity\RestResourceConfig
 *
 * @group rest
 */
class RestResourceConfigTest extends UnitTestCase {
    
    /**
     * Asserts that rest methods are normalized to upper case.
     *
     * This also tests that no exceptions are thrown during that method so that
     * alternate methods such as OPTIONS and PUT are supported.
     */
    public function testNormalizeRestMethod() : void {
        $expected = [
            'GET',
            'PUT',
            'POST',
            'PATCH',
            'DELETE',
            'OPTIONS',
            'FOO',
        ];
        $methods = [
            'get',
            'put',
            'post',
            'patch',
            'delete',
            'options',
            'foo',
        ];
        $configuration = [];
        foreach ($methods as $method) {
            $configuration[$method] = [
                'supported_auth' => [
                    'cookie',
                ],
                'supported_formats' => [
                    'json',
                ],
            ];
        }
        $entity = new RestResourceConfig([
            'plugin_id' => 'entity:entity_test',
            'granularity' => RestResourceConfigInterface::METHOD_GRANULARITY,
            'configuration' => $configuration,
        ], 'rest_resource_config');
        $this->assertEquals($expected, $entity->getMethods());
    }

}

Classes

Title Deprecated Summary
RestResourceConfigTest @coversDefaultClass \Drupal\rest\Entity\RestResourceConfig

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