Mercurial > hg > cmmr2012-drupal-site
comparison 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 |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\media\Kernel; | |
4 | |
5 use Symfony\Component\HttpFoundation\Request; | |
6 | |
7 /** | |
8 * @coversDefaultClass \Drupal\media\Controller\OEmbedIframeController | |
9 * | |
10 * @group media | |
11 */ | |
12 class OEmbedIframeControllerTest extends MediaKernelTestBase { | |
13 | |
14 /** | |
15 * Data provider for testBadHashParameter(). | |
16 * | |
17 * @return array | |
18 */ | |
19 public function providerBadHashParameter() { | |
20 return [ | |
21 'no hash' => [ | |
22 '', | |
23 ], | |
24 'invalid hash' => [ | |
25 $this->randomString(), | |
26 ], | |
27 ]; | |
28 } | |
29 | |
30 /** | |
31 * Tests validation of the 'hash' query string parameter. | |
32 * | |
33 * @param string $hash | |
34 * The 'hash' query string parameter. | |
35 * | |
36 * @dataProvider providerBadHashParameter | |
37 * | |
38 * @covers ::render | |
39 */ | |
40 public function testBadHashParameter($hash) { | |
41 /** @var callable $controller */ | |
42 $controller = $this->container | |
43 ->get('controller_resolver') | |
44 ->getControllerFromDefinition('\Drupal\media\Controller\OEmbedIframeController::render'); | |
45 | |
46 $this->assertInternalType('callable', $controller); | |
47 | |
48 $this->setExpectedException('\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException', 'This resource is not available'); | |
49 $request = new Request([ | |
50 'url' => 'https://example.com/path/to/resource', | |
51 'hash' => $hash, | |
52 ]); | |
53 $controller($request); | |
54 } | |
55 | |
56 } |