function OEmbedIframeControllerTest::testBadHashParameter

Same name in other branches
  1. 9 core/modules/media/tests/src/Kernel/OEmbedIframeControllerTest.php \Drupal\Tests\media\Kernel\OEmbedIframeControllerTest::testBadHashParameter()
  2. 8.9.x core/modules/media/tests/src/Kernel/OEmbedIframeControllerTest.php \Drupal\Tests\media\Kernel\OEmbedIframeControllerTest::testBadHashParameter()
  3. 10 core/modules/media/tests/src/Kernel/OEmbedIframeControllerTest.php \Drupal\Tests\media\Kernel\OEmbedIframeControllerTest::testBadHashParameter()

Tests validation of the 'hash' query string parameter.

@dataProvider providerBadHashParameter

@covers ::render

Parameters

string $hash: The 'hash' query string parameter.

File

core/modules/media/tests/src/Kernel/OEmbedIframeControllerTest.php, line 53

Class

OEmbedIframeControllerTest
@coversDefaultClass \Drupal\media\Controller\OEmbedIframeController

Namespace

Drupal\Tests\media\Kernel

Code

public function testBadHashParameter($hash) : void {
    
    /** @var callable $controller */
    $controller = $this->container
        ->get('controller_resolver')
        ->getControllerFromDefinition('\\Drupal\\media\\Controller\\OEmbedIframeController::render');
    $this->assertIsCallable($controller);
    $this->expectException('\\Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException');
    $this->expectExceptionMessage('This resource is not available');
    $request = new Request([
        'url' => 'https://example.com/path/to/resource',
        'hash' => $hash,
    ]);
    $controller($request);
}

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