Mercurial > hg > cmmr2012-drupal-site
diff core/modules/media/tests/src/Kernel/OEmbedIframeControllerTest.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/media/tests/src/Kernel/OEmbedIframeControllerTest.php Thu Feb 28 13:11:55 2019 +0000 @@ -0,0 +1,56 @@ +<?php + +namespace Drupal\Tests\media\Kernel; + +use Symfony\Component\HttpFoundation\Request; + +/** + * @coversDefaultClass \Drupal\media\Controller\OEmbedIframeController + * + * @group media + */ +class OEmbedIframeControllerTest extends MediaKernelTestBase { + + /** + * Data provider for testBadHashParameter(). + * + * @return array + */ + public function providerBadHashParameter() { + return [ + 'no hash' => [ + '', + ], + 'invalid hash' => [ + $this->randomString(), + ], + ]; + } + + /** + * Tests validation of the 'hash' query string parameter. + * + * @param string $hash + * The 'hash' query string parameter. + * + * @dataProvider providerBadHashParameter + * + * @covers ::render + */ + public function testBadHashParameter($hash) { + /** @var callable $controller */ + $controller = $this->container + ->get('controller_resolver') + ->getControllerFromDefinition('\Drupal\media\Controller\OEmbedIframeController::render'); + + $this->assertInternalType('callable', $controller); + + $this->setExpectedException('\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException', 'This resource is not available'); + $request = new Request([ + 'url' => 'https://example.com/path/to/resource', + 'hash' => $hash, + ]); + $controller($request); + } + +}